Hi guys, I want to introduce the following function to my script:
"If a mouse click is detected on the active window -> gui destroyed"
How can I proceed?
Thank you very much
Mouse click is detected -> gui destroyed. How?
Mouse click is detected -> gui destroyed. How?
Last edited by teosc on 03 Jul 2017, 05:03, edited 1 time in total.
Re: Mouse click is detected -> gui destroyed. How?
I'm assuming that by "on the active window" you mean the GUI window. If so:
Assign your GUI's hwnd to a variable called GuiID by adding +HwndGuiID to your first GUI command, and add this conditional hotkey definition:
If you mean any window as long as it's active, then set a LButton hotkey, and destroy the GUI if the window under the mouse is the active window. If it's not, just send a click so it behaves normally.
Assign your GUI's hwnd to a variable called GuiID by adding +HwndGuiID to your first GUI command, and add this conditional hotkey definition:
Code: Select all
#IfWinActive, ahk_id %GuiID%
LButton::Gui, Destroy
Re: Mouse click is detected -> gui destroyed. How?
Thanks, but in this way the click function is canceled .... because it looks like hotkeys.
Each command with the LButton does not run.
Or am I wrong?
Each command with the LButton does not run.
Or am I wrong?
Re: Mouse click is detected -> gui destroyed. How?
The hotkey is activated only if the GUI window is active. That's what the directive in the first line does.
If you're talking about the 2nd approach, that's why you send a click otherwise.
If you're talking about the 2nd approach, that's why you send a click otherwise.
Re: Mouse click is detected -> gui destroyed. How?
Can not destroy gui "after" any command sent to the active window?
I'm looking but I do not find a solution...
I'm looking but I do not find a solution...
Re: Mouse click is detected -> gui destroyed. How?
I don't know what you mean by any command sent to the active window. Commands sent by who or what? You want to destroy the gui any time any command is sent to whichever window is active?
Re: Mouse click is detected -> gui destroyed. How?
----> The gui keeps getting created because the settimer is still running and creating them. <----
If this is going to be more than a one time use consider hiding the gui and not destroying it.
Then show and hide as needed.
HTH
If this is going to be more than a one time use consider hiding the gui and not destroying it.
Then show and hide as needed.
HTH
Re: Mouse click is detected -> gui destroyed. How?
boiler wrote:I don't know what you mean by any command sent to the active window. Commands sent by who or what? You want to destroy the gui any time any command is sent to whichever window is active?
Yes, after each command or typing or any interaction sent by me manually in the active window, for example after a mouse click or a typing of some letter or number with keyboard, ecc.
Sorry for my bad english
Re: Mouse click is detected -> gui destroyed. How?
This is not valid. #IfWinActive does not support variables.boiler wrote:#IfWinActive, ahk_id %GuiID%
If you want to detect mouse clicks on the GUI itself and do not need the mouse hook for some other reason, it is much better to use OnMessage(0x201, ...) than a mouse hotkey. However, I guess that's not what teosc wants.
Re: Mouse click is detected -> gui destroyed. How?
Re. #IfWinActive you could do something like this:
Although as was said, OnMessage has its benefits.
Code: Select all
Gui, +Lastfound +AlwaysOnTop +Toolwindow +HwndhWnd
GroupAdd, WinGroupGui, % "ahk_id " hWnd
;...
return
#IfWinActive, ahk_group WinGroupGui
LButton::Gui, Destroy
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Mouse click is detected -> gui destroyed. How?
I'm trying to introduce "onmessage" in my script to destroy / hide frame border after any click or typing in the active window.
But it does not seem to work, where am I wrong?
But it does not seem to work, where am I wrong?
Last edited by teosc on 03 Jul 2017, 05:03, edited 1 time in total.
Re: Mouse click is detected -> gui destroyed. How?
A few issues with your script:
- You should have a return after your border_color assignment to mark the end of the auto-execute section of your script.
- You should have gotten a nonexistent function error with IfWinExist("A"). However, if you add a space between the If and WinExist to make it legal syntax, then it's a meaningless line. The result of that conditional statement will always be true because the active window (whatever it happens to be at that time) exists by definition.
- You shouldn't have a function call inside of the DrawRect subroutine (or any subroutine, really). Move the Guidestroy function to the end of the script, or before the MButton hotkey definition.
- You should put the OnMessage(0x201, "Guidestroy") line up in the auto-execute section. It will automatically trigger a call to Guidestroy when the GUI is clicked on.
-There will be likely be more things to clean up, but it doesn't make sense to talk about them until the above items are cleaned up.
- You should have a return after your border_color assignment to mark the end of the auto-execute section of your script.
- You should have gotten a nonexistent function error with IfWinExist("A"). However, if you add a space between the If and WinExist to make it legal syntax, then it's a meaningless line. The result of that conditional statement will always be true because the active window (whatever it happens to be at that time) exists by definition.
- You shouldn't have a function call inside of the DrawRect subroutine (or any subroutine, really). Move the Guidestroy function to the end of the script, or before the MButton hotkey definition.
- You should put the OnMessage(0x201, "Guidestroy") line up in the auto-execute section. It will automatically trigger a call to Guidestroy when the GUI is clicked on.
-There will be likely be more things to clean up, but it doesn't make sense to talk about them until the above items are cleaned up.
Re: Mouse click is detected -> gui destroyed. How?
boiler wrote:A few issues with your script:
- You should have a return after your border_color assignment to mark the end of the auto-execute section of your script.
- You should have gotten a nonexistent function error with IfWinExist("A"). However, if you add a space between the If and WinExist to make it legal syntax, then it's a meaningless line. The result of that conditional statement will always be true because the active window (whatever it happens to be at that time) exists by definition.
- You shouldn't have a function call inside of the DrawRect subroutine (or any subroutine, really). Move the Guidestroy function to the end of the script, or before the MButton hotkey definition.
- You should put the OnMessage(0x201, "Guidestroy") line up in the auto-execute section. It will automatically trigger a call to Guidestroy when the GUI is clicked on.
-There will be likely be more things to clean up, but it doesn't make sense to talk about them until the above items are cleaned up.
Many many many thanks.
The observation regarding the ifwinexist function is right, what I want is that not every "message 0x201" is considered but only those sent in the active window and next popup window (by third app) the script resume drawing board!
(But I do not know how to do it )
I'm trying to implement your suggestions, this is how I changed but not successful.
Last edited by teosc on 03 Jul 2017, 05:13, edited 1 time in total.
Re: Mouse click is detected -> gui destroyed. How?
OnMessage is only going to detect clicks on your GUI, not any other window. And even if that's OK, as Lexikos suggested, it's probably still not a fit for your goal. But I'm not fully understanding what your goal is. If you are first trying to determine if the window was already active when it got clicked on, OnMessage will alert you after it was clicked, and it will be made active by clicking on it before you have a chance to see if it already was.
That's why I was suggesting using a LButton hotkey because you hijack it before it registers a click, and you can see if the window under the mouse is active and you can destroy the GUI. If it's not, then you can send the click so it will behave as a normal mouse click.
That's why I was suggesting using a LButton hotkey because you hijack it before it registers a click, and you can see if the window under the mouse is active and you can destroy the GUI. If it's not, then you can send the click so it will behave as a normal mouse click.
Re: Mouse click is detected -> gui destroyed. How?
It is exactly what I would like to do but also in the active window I would like the lbutton to be considered first as a command and only then as a hotkey.boiler wrote: That's why I was suggesting using a LButton hotkey because you hijack it before it registers a click, and you can see if the window under the mouse is active and you can destroy the GUI. If it's not, then you can send the click so it will behave as a normal mouse click.
When I click on a point i would like before the Lclick would be considered as a simple click, and only then as hotkey for destroy gui ... without setting a double click!
It's possible?
Re: Mouse click is detected -> gui destroyed. How?
I don't know what you mean that you want it considered first as a command then as a hotkey. By setting it as a hoykey, you can have it do whatever you want. You can execute other commands, you can send a mouse click, or whatever.
Re: Mouse click is detected -> gui destroyed. How?
Edit, tyboiler wrote:I don't know what you mean that you want it considered first as a command then as a hotkey. By setting it as a hoykey, you can have it do whatever you want. You can execute other commands, you can send a mouse click, or whatever.
Last edited by teosc on 03 Jul 2017, 05:13, edited 2 times in total.
Re: Mouse click is detected -> gui destroyed. How?
What do you mean by "find the command on 'Find Seat'"? Do you mean you want to determine if the mouse is over the Find Seat button, and if so, then destroy the frame Gui without sending a click? And if it's not on that button, then send a click as normal?
If so, that's exactly what I described in the approach I outlined.
If so, that's exactly what I described in the approach I outlined.
Re: Mouse click is detected -> gui destroyed. How?
No no, much more simply I would like any click made on the active window ... actually appear as a click rather than as a hotkey.boiler wrote:What do you mean by "find the command on 'Find Seat'"? Do you mean you want to determine if the mouse is over the Find Seat button, and if so, then destroy the frame Gui without sending a click? And if it's not on that button, then send a click as normal?
If so, that's exactly what I described in the approach I outlined.
If I click somewhere in the active window, such as "Find Seat", I would like to actually click on Find Seat and only after it is considered as a variable to destroy gui.
If I set LButton as hotkeys to destroy the frame border, the click I send does not occur on the Find Seat button but is eaten by AHK as a hotkey.