These are lower level wrappers around the raw dll functions. Functions have been combined and simplified where reasonable. Only the minimal extraction/conversion has been preformed on c return types.
start(filename=None, script='', options='', params='')¶
Wrapper around ahkdll and ahktextdll.
Start a new ahk thread from file or a string. Defaults to an empty script with no options or params. Filename is preferred over script if provided.
Using any option besides ahk.start() seems not to work. Specifying a file doesn’t cause it to run, passing a string doesn’t cause it to be executed?
Returns: Thread handle for created instance (see thread functions).
Wrapper around ahkReady.
Returns True if ahk is ready to use. By default this polls the dll function until it is ready. By calling with nowait=True the immediate result is returned instead. By calling with retries > 1 state will be checked at most retries times.
add_lines(script='', filename=None, duplicates=False, ignore=True)¶
Wrapper around addFile and addScript.
Adds lines to the running script from file or string. Lines added from string are evaluated immediately, lines added from file are not evaluated. Defaults to an empty script, no duplicates, and ignore errors. Filename is preferred over script if provided.
Returns: Pointer address to first line in added script (see execute_line).
Wrapper around ahkExec.
Execute provided ahk commands. No lines are added to the active script.
Returns: True if successful, else False.
Wrapper around ahkLabel.
GoSub/GoTo like function, branch to labeled location. Defaults to nowait=False, i.e. GoSub mode. Using nowait=True, i.e. GoTo mode, is unreliable and may fail entirely.
Returns: True if label exists, else False.
Wrapper around ahkFunction.
Call the indicated function.
Returns: Result of function call as a string.
Wrapper around ahkPostFunction.
Call the indicated function but discard results.
Returns: True if function exists, else False.
Wrapper around ahkassign.
Assigns the string value to the variable name.
Returns: True for success and False for failure.
Wrapper around ahkgetvar.
Get the string value of a variable from ahk. Call with pointer=True to request a reference to the variable.
Returns: A string representing the value, or a c_char_p.
Wrapper around ahkTerminate.
Terminate the script, removing all hotkeys and hotstrings. The default timeout is 1ms, must be positive > 0.
Wrapper around ahkReload.
Terminates and restarts the script.
Wrapper around ahkFindFunc.
The following doesn’t seem to work, any advice welcome.
Get a pointer address to the named function. To use this you must first create a ctypes CFUNCTYPE prototype:
proto = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_char_p)
Then call the prototype with the address as an argument to get a function:
func = proto(address)
Now it can be called:
result = func(5)
Returns: The address of the function as an integer.
Wrapper around ahkFindLabel.
Get a pointer address to a label...
Returns: The address of the label as an integer.
Wrapper around ahkPause.
Pause or unpause the script. Calling with pause_=True pauses, pause_=False un-pauses. Calling with pause_=None just reports current state without changing it.
Returns: True if the script is paused, else False.
exec_line(line=None, mode=3, wait=False)¶
Wrapper around ahkExecuteLine.
Execute starting from the provided line address. If line=None the address of the first line will be returned. Four modes of execution are available:
- No execution, but the next line address is returned.
- Run until a return statement is found.
- Run until the end of the current block.
- (default) execute only one line.
Setting wait=True will block until end of execution.
Returns: A line pointer address.