Press a button in a window popup
Press a button in a window popup
A window will popup.
The title will always be the same.
The size will always be the same.
There will be 2 buttons. I need to press one of them when it pops up.
Ladies and gentlemen, how do I begin?
The title will always be the same.
The size will always be the same.
There will be 2 buttons. I need to press one of them when it pops up.
Ladies and gentlemen, how do I begin?
Re: Press a button in a window popup
Hallo,
use WinSpy and then something like this:
use WinSpy and then something like this:
Code: Select all
#Persistent
SetTimer, Timer, 500
Timer:
IF WinActive("WinTitle")
ControlClick, Control-or-Pos, WinTitle
Return
Re: Press a button in a window popup
Thanks @Rohwedder for the quick response.
Is this WinSpy?
Does WinActive work if the pop-up goes to the background?
Is your code written in AHK v1 or v2?
For ControlClick, once I have my XY coordinates, would I simply modify your line like this?
Code: Select all
ControlClick, Control-or-Pos, WinTitle
ControlClick, x55 y77, Some Window Title
Are partial window titles matched?
Re: Press a button in a window popup
Unfortunately the program's main window and its pop-up will have the same window title.
I need to click the pop-up.
How to unique differentiate them?
I need to click the pop-up.
How to unique differentiate them?
Re: Press a button in a window popup
Is this WinSpy?
… Yes
Does WinActive work if the pop-up goes to the background?
No, but WinExist() can do that. However, some windows do not react in background, they want to be activated first.
Is your code written in AHK v1 or v2?
v1 (the v2 Timers are more cumbersome!)
For ControlClick, once I have my XY coordinates, would I simply modify your line like this?
… Yes
Do I need quotes in that Window Title if there are spaces?
No, it would not work with quotes (except as an expression).
Are partial window titles matched?
No but you could use:
… Yes
Does WinActive work if the pop-up goes to the background?
No, but WinExist() can do that. However, some windows do not react in background, they want to be activated first.
Is your code written in AHK v1 or v2?
v1 (the v2 Timers are more cumbersome!)
For ControlClick, once I have my XY coordinates, would I simply modify your line like this?
… Yes
Do I need quotes in that Window Title if there are spaces?
No, it would not work with quotes (except as an expression).
Are partial window titles matched?
No but you could use:
Code: Select all
SetTitleMatchMode, 2
Re: Press a button in a window popup
So what do I do if it's still not working...Rohwedder wrote: ↑07 Oct 2022, 12:19Is this WinSpy?
… Yes
Does WinActive work if the pop-up goes to the background?
No, but WinExist() can do that. However, some windows do not react in background, they want to be activated first.
Is your code written in AHK v1 or v2?
v1 (the v2 Timers are more cumbersome!)
For ControlClick, once I have my XY coordinates, would I simply modify your line like this?
… Yes
Do I need quotes in that Window Title if there are spaces?
No, it would not work with quotes (except as an expression).
Are partial window titles matched?
No but you could use:Code: Select all
SetTitleMatchMode, 2
How do I:
detect if this window pops up
make it active (if not)
click at these coordinates (but which coordinates do I use)
I'm not even sure if I'm getting into your IF statement you posted, so how do I debug it? since we don't have print messages.
Re: Press a button in a window popup
Do the program's main window and its pop-up have the same title and ahk_class?
If so, do you see any message box if you run this code and the pop-up appears?
If so, do you see any message box if you run this code and the pop-up appears?
Code: Select all
#Persistent
SetTimer, GetNumberOfwindowsTitle, 200
Return
GetNumberOfwindowsTitle:
; Replace "Title" by the title of the window
WinGet, numberOfwindows, count, Title
If (count > 1)
MsgBox, Number of windows: %count%
Return
Re: Press a button in a window popup
Unfortunately, WinSpys "Follow Mouse" was not enabled in the upper right corner.
Also, the Autohotkey search for HwndWrapper says that it is a very recalcitrant window class!
search.php?keywords=HwndWrapper
Maybe you will find something usable there.
Also, the Autohotkey search for HwndWrapper says that it is a very recalcitrant window class!
search.php?keywords=HwndWrapper
Maybe you will find something usable there.
Re: Press a button in a window popup
No messages.GEV wrote: ↑08 Oct 2022, 01:38Do the program's main window and its pop-up have the same title and ahk_class?
If so, do you see any message box if you run this code and the pop-up appears?
Code: Select all
#Persistent SetTimer, GetNumberOfwindowsTitle, 200 Return GetNumberOfwindowsTitle: ; Replace "Title" by the title of the window WinGet, numberOfwindows, count, Title If (count > 1) MsgBox, Number of windows: %count% Return
Playing further with this reveals that, even if I type the exact window title, it's not being detected at all, WinGet doesn't seem to be able to get it.
Re: Press a button in a window popup
Rohwedder wrote: ↑08 Oct 2022, 01:39Unfortunately, WinSpys "Follow Mouse" was not enabled in the upper right corner.
Also, the Autohotkey search for HwndWrapper says that it is a very recalcitrant window class!
search.php?keywords=HwndWrapper
Maybe you will find something usable there.
Re: Press a button in a window popup
Sorry,
the right syntax is
the right syntax is
Code: Select all
#Persistent
SetTimer, GetNumberOfwindowsTitle, 200
Return
GetNumberOfwindowsTitle:
; Replace "Title" by the title of the window
WinGet, numberOfwindows, count, Title
If (numberOfwindows > 1)
MsgBox, Number of windows: %numberOfwindows%
Return
Re: Press a button in a window popup
Alright where am I going wrong here?
This sends a click, but not at the coordinates that I need.
If I put my cursor above the button I need it to click, then it clicks that button, otherwise not.
I've tried Click and ControlClick.
What am I missing?
This sends a click, but not at the coordinates that I need.
If I put my cursor above the button I need it to click, then it clicks that button, otherwise not.
I've tried Click and ControlClick.
What am I missing?
Code: Select all
#Persistent
; SetTitleMatchMode, 2
SetControlDelay 1
SetTimer, checkWindow, 1000
checkWindow(){
if WinExist("title"){
WinGetPos, , , W, H
;MsgBox, Window size is %W%x%H%
if (W = 1251 and H = 747) {
;MsgBox, Calling WinActivate and trying to click
WinActivate
;ControlClick, x215 y169
;Click, x215 y169
Return
}
}
}
Return
Re: Press a button in a window popup
I ended up having to do click in this lengthy way:
Code: Select all
#Persistent
; SetTitleMatchMode, 2
SetControlDelay 1
SetTimer, checkWindow, 5000
checkWindow(){
if WinExist("title"){
WinGetPos, , , W, H
if (W = 1251 and H = 747) {
WinActivate
Sleep, 333
Click, 34, 697 Left, , Down
Sleep, 10
Click, 34, 697 Left, , Up
Sleep, 10
Return
}
}
}
Return