forked from C-Love/dhs-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbzio.py
More file actions
71 lines (45 loc) · 1.89 KB
/
Copy pathbzio.py
File metadata and controls
71 lines (45 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""BlueZone I/O functions for Python."""
import win32com.client
bz = win32com.client.Dispatch("BZWhll.WhllObj")
def Connect(screen_to_connect):
"""Connect to a BlueZone Screen."""
bz.connect(screen_to_connect)
# TODO: error if not connected?
def Focus():
"""Bring the BlueZone Display session window into the foreground."""
bz.Focus()
def CursorCol():
"""Return current cursor column of the connected BZ screen."""
return bz.GetCursor(0, 0)[2]
def CursorRow():
"""Return current cursor row of the connected BZ screen."""
return bz.GetCursor(0, 0)[1]
def MsgBox(message_to_deliver):
"""Display a simple pop-up box from within the BlueZone window."""
bz.MsgBox(message_to_deliver)
def ReadScreen(LengthVal, RowVal, ColumnVal):
"""Retrieve data from the host screen."""
ret_details = bz.ReadScreen("", LengthVal, RowVal, ColumnVal)
# ret_details is a list with two items, 0 (any error code, 0 for success), and 1 (the text it read from BZ)
if ret_details[0] != 0:
raise ValueError("Either the row or column variable are too high.")
return ret_details[1]
def Search(SearchStr):
"""Search the host screen for some specified text."""
return bz.Search(SearchStr, 1, 1)
def SendKey(KeyStr):
"""Send a sequence of keys to the display session."""
bz.SendKey(KeyStr)
def SetCursor(RowVal, ColumnVal):
"""Set the host screen cursor position."""
bz.SetCursor(RowVal, ColumnVal)
def Transmit():
"""Send a transmit key and wait until the window refreshes."""
SendKey("<enter>")
WaitReady(0, 0)
def WaitReady(TimeoutVal, ExtraWaitVal):
"""Suspend script execution until the host screen is ready for keyboard input."""
bz.WaitReady(TimeoutVal, ExtraWaitVal)
def WriteScreen(WriteStr, RowVal, ColumnVal):
"""Paste the specified text into the host screen."""
bz.WriteScreen(WriteStr, RowVal, ColumnVal)