Execute PostMessage commands from array

Get help with using AutoHotkey and its commands and hotkeys
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Execute PostMessage commands from array

01 May 2017, 09:58

Hi,
Im curious wether it might be possible to execute PostMessage commands directly from an multidimensional associative array (will eventually be COM calls as well)? I have no intentions to take the easy road and split off the string and fill in the command strings (if avoidable). After all, Im here to learn different methods ;) Maybe there is some way to execute commands from a value/string/memory?
Have been playing with Run and Send. Code looks like this:

Code: Select all

CHSwitchCom := {0: ["PostMessage, 0xB2C2, 0x0815, 0x08C,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 0
     ,          1: ["PostMessage, 0xB2C2, 0x0815, 0x08D,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 1
     ,          2: ["PostMessage, 0xB2C2, 0x0815, 0x08E,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 2
     ,          3: ["PostMessage, 0xB2C2, 0x0815, 0x08F,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 3
     ,          4: ["PostMessage, 0xB2C2, 0x0815, 0x090,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 4
     ,          5: ["PostMessage, 0xB2C2, 0x0815, 0x091,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 5
     ,          6: ["PostMessage, 0xB2C2, 0x0815, 0x092,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 6
     ,          7: ["PostMessage, 0xB2C2, 0x0815, 0x093,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 7
     ,          8: ["PostMessage, 0xB2C2, 0x0815, 0x094,, ahk_class TfrmMain"]   ; Sends DVBViewer Channelswitch 8
     ,          9: ["PostMessage, 0xB2C2, 0x0815, 0x095,, ahk_class TfrmMain"] } ; Sends DVBViewer Channelswitch 9
;MsgBox % CHSwitchCom[Key 7, 1]
CHSwichCode := 3
msgbox % CHSwitchCom[Key . CHSwichCode, 1]
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Re: Execute PostMessage commands from array

01 May 2017, 12:59

The answer was HotKeyIts dynacall:

Code: Select all

debug := "PostMessage, 0xB2C2, 0x0815, 0x08E,, ahk_class TfrmMain"	 
ahkExec(debug)
ahkExec(Script){
static ahkExec
if !ahkExec
ahkExec:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkExec"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkExec","PTR"),"i==s")
Errorlevel := ahkExec[Script]
}
No problem for me since im already using AHK_H, but for users of my application that installs AHK_l this will fail.
Are there any current working solutions that might work with AHK_l? Unfortunately HotKeyIt:s Exec() function does not work for PostMessages https://autohotkey.com/board/topic/3739 ... namically/

Return to “Ask For Help”

Who is online

Users browsing this forum: BarryGil, Bing [Bot], boiler, Google [Bot], mikeyww and 37 guests