Skip to content

Commit

Permalink
Fordragon16, failed attempt to implement playEvents via python (#195)
Browse files Browse the repository at this point in the history
* changes in __init__.py prevent Dragon 16 from halting by an ESP error.
* try the playEvents fix of Dane in __init__.py
* remove dependencies for natlink (put them in natlinkcore if necessary)
* failed attempt to implement playEvents with python.
  • Loading branch information
quintijn authored Jun 4, 2024
1 parent 9e4b229 commit a48702f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pythonsrc/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers=[
"Topic :: Software Development :: Libraries :: Python Modules"
]
dependencies=[
"dtactions >= 1.6.1"

]

[project.urls]
Expand Down
51 changes: 47 additions & 4 deletions pythonsrc/src/natlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import winreg
import ctypes
import contextlib
from dtactions.vocola_sendkeys import ext_keys
import win32api
import win32gui
from dtactions.vocola_sendkeys import ext_keys ### , SendInput
W32OutputDebugString = ctypes.windll.kernel32.OutputDebugStringW

#copied from pydebugstring.
Expand Down Expand Up @@ -82,11 +84,37 @@ def playString(a, hook=0):
# normal case:
return ext_keys.send_input(a)


def playEvents16(events):
"""a short version, written by Dany Finlay
"""
print(f'try a playEvents on Dragon16: {events}')
# Check that *events* is a list.
if not isinstance(events, list):
raise TypeError("events must be a list of 3-tuples")

print('playEvents not implemented for Dragon 16 (yet)')
# try to attach to (repository) \dtactions\vocola_sendkeys
# SendInput.send_input(events)


# this is the attempt of Dane, which fails.
# # Post each 3-tuple event to the foreground window.
# hwnd = win32gui.GetForegroundWindow()
# for event in events:
# if not (isinstance(event, tuple) and len(event) == 3 and
# all((isinstance(i, int) for i in event))):
# raise TypeError("events must be a list containing 3-tuples of"
# " integers")
#
# message, wParam, lParam = event
# win32api.PostMessage(hwnd, message, wParam, lParam)

def playEvents(a):
"""causes a halt (ESP error) in Dragon 16.
"""
if getDNSVersion() >= 16:
outputDebugString("ignore playEvents, it halts with Dragon 16 (ESP error)")
playEvents16(a)
return None
return _playEvents(a)

Expand Down Expand Up @@ -150,8 +178,23 @@ def NatlinkConnector():
natDisconnect()


def _test_playEvents():
"""perform a few mouse moves
"""
import time
wm_mousemove = 0x0200
positionsx = [10, 500, 500, 10, 10]
positionsy = [10, 10, 500, 500, 10]
for x, y in zip(positionsx, positionsy):
playEvents( [(wm_mousemove, x, y)] )
time.sleep(1)



if __name__ == "__main__":
outputDebugString(f'getDNSVersion: {getDNSVersion()} (type: {type(getDNSVersion())}))')
playString('abcde')
playEvents(tuple())
# playString('abcde')
# playEvents( [(0,0,0)] )
_test_playEvents()


0 comments on commit a48702f

Please sign in to comment.