autoit - Want AutoIt3 HotKeySet to Emulate AutoHotKey Application Filtering -
objective
i building generic solution advanced controlling of arbitrary programs ui using autoit3, invoked pressing various keys, or issuing command.
components
- targetui - program controlled sending clicks , keys
- mainau3 - autoit program doing sending
- mainini - file containing control positions , other info in specialized notation, contains hotkey information. info specific particular targetui - ie. 1 mainini each targetui
- keyhookscript - optional? either autoit or autohotkey script
facts
- hotkeyset() - autoit function allows setting , unsetting of system-wide hotkeys
- autohotkey - scripting language - allows application filtering hotkeys via
#ifwinactive
- mainau3 designed take command param, provided keyhookscript
- mainau3 slow invoke, due parsing of mainini on startup, necc. due program goals
issues
- since mainau3 slow invoke, 1 option have run in background , have own keyhooks, or have keyhookscript communicate somehow
- mainau3 , mainini have more 1 instance -- instance each targetui. causes collision if using
hotkeyset()
in each mainau3 unless set , unset everytime targetuis focus - seems asking trouble
anticipated approach
- it looks need mainau3manager monitors applications , ensures proper mainau3/mainini running needed. need maintain singleton(?) keyhookscript written in autohotkey
questions
- how ill-advised attempt swap out hotkeyset/unset via each mainau3 based on application has focus , targetui?
- given bad approach, communication method best talk running mainau3s?
- how hard create own hooking mechanism in autoit via
_ispressed
, , create "polling problem" if running in each mainau3
communication methods
these ones can think of , want fast , reliable, , coded haha
- file based - create file(s) in directory containing command, let mainau3 delete it/them
- registry - slower files
- hidden window - communicate setting window text (i know!) faster file?
- hidden window -
sendmessage
ugh, hard code - dde - don't me started
decision point
i need communicate running mainau3 regardless, because, reasons. real issue whether embed keyhook mechanism inside mainau3 instances or not.
what if autoit had reliable mechanism keyhooks application specific in autohotkeys #ifwinactive
.
if embed, hate both options of setting , unsetting hotkeyset()
, polling _ispressed()
. again, external keyhook via autohotkey pain too.
i think try embedding hotkeyset()
first, , see how acts.
any advice?
note "communication" one-way - need send commands.
in case gui trying control own gui:
if want hotkeys not system wide, should use
guisetaccelerators ( accelerators [, winhandle] )
guisetaccelerators sets accelerator table used in gui window.
parameters
accelerators 2 dimensional array holding accelerator table (see remarks). winhandle [optional] windows handle returned guicreate() (default used window).
remarks
the array passed function contains hotkey , control id of accelerator. array must defined local/global $aarray[n][2] - n number of accelerator keys set: $aarray[0][0] = hotkey (in hotkeyset() format) of 1st accelerator $aarray[0][1] = control id of 1st accelerator, returned guictrlcreate... $aarray[1][0] = hotkey of 2nd accelerator $aarray[1][1] = control id of 2nd accelerator ... $aarray[n][0] = hotkey of nth accelerator $aarray[n][1] = control id of nth accelerator passing function non-array unset accelerators given winhandle.
example:
#include <guiconstantsex.au3> #include <msgboxconstants.au3> example() func example() guicreate("custom msgbox", 225, 80) guictrlcreatelabel("please select button.", 10, 10) local $idyes = guictrlcreatebutton("yes", 10, 50, 65, 25) local $idno = guictrlcreatebutton("no", 80, 50, 65, 25) local $idexit = guictrlcreatebutton("exit", 150, 50, 65, 25) ; set guiaccelerators button controlids, these being ctrl + y , ctrl + n local $aaccelkeys[2][2] = [["^y", $idyes],["^n", $idno]] guisetaccelerators($aaccelkeys) guisetstate(@sw_show) ; display gui. while 1 switch guigetmsg() case $gui_event_close msgbox($mb_systemmodal, "you selected", "close") exitloop case $idyes msgbox($mb_systemmodal, "you selected", "yes") ; displays if button selected or hotkey combination ctrl + y pressed. case $idno msgbox($mb_systemmodal, "you selected", "no") ; displays if button selected or hotkey combination ctrl + n pressed. case $idexit msgbox($mb_systemmodal, "you selected", "exit") exitloop endswitch wend guidelete() ; delete gui. endfunc ;==>example
if controlling external gui maybe try fiddling any gui make work
Comments
Post a Comment