Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Solved] Gui, 1:Destroy makes my onMessage() stop working?



  • Please log in to reply
6 replies to this topic
gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
maybe i'm missing something here, but when monitoring WM_Input via:
OnMessage("0xFF",WM_Input")
Gui, 1:Add, Text, , Hi
Return
WM_INPUT(wParam, lParam){
 Critical
 ToolTip, %A_Now%
 Return 0
}
~F4::Gui, 1:Close

is this supposed to happen? even when the gui is created after the message is being monitored?
thanks for any help
- gwarble

functional code is buggy version 0.46 of EitherMouse
<!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?p=536765#p536765">viewtopic.php?p=536765#p536765</a><!-- l -->
i'll make a working example for this thread if there isn't a quick answer someone has about a change in how onMessage is linked with gui number (old code ported forward, so its still using gui number)
and closing another gui doesn't exhibit this problem...
thanks

0x150--ISO
  • Members
  • 657 posts
  • Last active: Apr 07 2012 09:06 PM
  • Joined: 01 Jan 2011
this may or may not have baring on the "bug", I just noticed some bad syntax
OnMessage("0xFF",[color=#BF0000]"[/color]WM_Input")
are you testing this with a full RAWINPUT struct? or some other way??

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
Thanks, but i was just writing that off the cuff... I'll post real code when i get a chance, otherwise u can try that buggy version of eithermouse (tray option to extract source) 0.46

at the end of the code if you change gui, 1:destroy to gui 1:hide, and leave gui2:destroy, the wm_input keeps triggering properly

heh, also note besides that missing ", the two extra "'s around 0xFF

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Conjecture: When you registered for raw input, you specified the handle of a window to which WM_INPUT messages should be sent. Maybe this window happened to be Gui 1, but that has no relevance to the OS. After a window is destroyed, it no longer exists and therefore cannot receive messages. Furthermore, recreating the Gui means creating a completely new window, typically with a different handle.

how onMessage is linked with gui number

Each window message has two parameters, a target window and a message number. If a message monitor function has been registered for that number, it is called. It does not matter whether the target window is a Gui, but if it is, A_Gui is set accordingly.

Tip: If all you need is a destination for window messages, you can use the script's main window, which is usually hidden but exists for as long as the script is running.

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
Thanks,

I thought i was already using the scripts main window by using hwnd retreived with:
Hwnd:=WinExist("ahk_pid " DllCall("GetCurrentProcessId"))
to register for raw input

but its acting like that is whats happening, ill investigate the existance of that hwnd

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
✓  Best Answer
That will return the script's top-most window, which is generally going to be a GUI if one exists. You can either narrow down the criteria - add ahk_class AutoHotkey - or use A_ScriptHwnd instead of WinExist.

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
perfect, thanks a ton!
New variable i didn't know about, perfectly applicable

i didn't realize i had changed the gui creation/registerRaw order that must be it, was inadvertantly using the gui's hwnd for the registerRaw... so technically the onMessage is still monitoring WM_Input but the system is no longer sending the messages because i lost the rawRegistration hwnd

EDIT: marked as solved
Preferred solution in _L: A_ScriptHWnd variable