OSC2AHK/msgtest.ahk

46 lines
1.0 KiB
AutoHotkey

#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
hWnd := WinExist()
stdout := FileOpen("tmp.log", "w")
stdout.WriteLine("START")
retOnMsg := OnMessage(0x1000, "msghandler")
stdout.WriteLine("OnMessage:")
stdout.WriteLine(retOnMsg)
OnExit("exithandler")
hModule := DllCall("LoadLibrary", "Str", "x64\Debug\OSC2AHK.dll", "Ptr") ; Avoids the need for DllCall() in the loop to load the library.
stdout.WriteLine("DLL handle:")
stdout.WriteLine(hModule)
ret := DllCall("OSC2AHK.dll\testMsg", UInt,hWnd, UInt,0x1000)
stdout.WriteLine("DLL call:")
stdout.WriteLine(ret)
DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 7002)
stdout.Close()
return
msghandler(wParam, lParam, msg, hwnd) {
stdout := FileOpen("tmp.log", "a")
stdout.WriteLine("Received MSG!")
stdout.WriteLine(wParam)
stdout.WriteLine(lParam)
stdout.Close()
}
exithandler() {
stdout := FileOpen("tmp.log", "a")
stdout.WriteLine("The End")
stdout.Close()
}
do_exit:
ExitApp
return ; unnecessary redundancy?
Esc::GoSub, do_exit