Wait for window, then send a cancel command

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
taylope1
Posts: 5
Joined: 15 Oct 2019, 04:15

Wait for window, then send a cancel command

15 Oct 2019, 04:21

So I have an annoying feature of a program that I don't want end users to touch. Unfortunately it appears I must wait for the pop up to appear otherwise it does not write the data I need to a directory.

So this is the window:
window popup.jpg
window popup.jpg (21.43 KiB) Viewed 1153 times
and here is the spy info:
window spy output.jpg
window spy output.jpg (37.51 KiB) Viewed 1153 times
Here is a script i tried to bodge (I know i am sending an Enter not a cancel)

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Modified original script
setTitleMatchMode 3
loop{
winwait,Advanced Uninstaller Pro
winActivate,Advanced Uninstaller Pro
send {Enter}
}
esc::exitapp


Its just not doing what I need. I see no popup at all now so its like its killing it rather than allowing it. Please help.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Wait for window, then send a cancel command

15 Oct 2019, 08:05

If the window needs to appear for a small amount of time before you dismiss it so that it can write its data, you could try adding a Sleep, 500 before the line where you send the Enter key. But I would first make sure it's really recognizing the popup when it occurs and isn't reacting to some hidden window with the same title or something. I would run this script and make sure message appears only after the popup window:

Code: Select all

loop {
	winwait,Advanced Uninstaller Pro
	MsgBox, % Popup has appeared
}
esc::exitapp
taylope1
Posts: 5
Joined: 15 Oct 2019, 04:15

Re: Wait for window, then send a cancel command

16 Oct 2019, 08:01

Thanks for the looper checcker. I have now got it to find the window and activate it, but i cannot get it to close. Here's the new code.

Code: Select all

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Modified original script
setTitleMatchMode 3
loop{
winwait,ahk_class TfUninstallBubble ahk_title Advanced Uninstaller PRO
Sleep 2000
winActivate,ahk_class TfUninstallBubble ahk_title Advanced Uninstaller PRO
Sleep 300
Send, {ESC}
}
esc::exitapp

I've tried Winclose and Send !{F4} as well. FYI if I type ALT F4 then it closes the popup window. So close, and so important to me. Any more help approcaited.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Wait for window, then send a cancel command

16 Oct 2019, 08:47

I'm not seeing how you ever really got it to find the window if you used ahk_class TfUninstallBubble ahk_title Advanced Uninstaller PRO because ahk_title isn't a thing. It needs to be Advanced Uninstaller PRO ahk_class TfUninstallBubble.
taylope1
Posts: 5
Joined: 15 Oct 2019, 04:15

Re: Wait for window, then send a cancel command

16 Oct 2019, 10:44

Thanks Boiler. I have updated script but it actually still performs the same. Windows get activated but will not close..any ideas?

Code: Select all

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Modified original script
setTitleMatchMode 3
loop{
winwait,Advanced Uninstaller PRO ahk_class TfUninstallBubble
Sleep 2000
winActivate,Advanced Uninstaller PRO ahk_class TfUninstallBubble
WinClose
}
esc::exitapp
[Mod edit: [code][/code] tags added]

FYI I cannot kill the process as this is needed in case that was a potential suggestion.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Wait for window, then send a cancel command

16 Oct 2019, 11:10

This isn't the problem most likely, but to be safe, I would add the following after your WinActivate command:

Code: Select all

WinWaitActive, Advanced Uninstaller PRO ahk_class TfUninstallBubble
Then try the following options in place of WinClose:

Code: Select all

Send, {Alt down}{F4}{Alt up}
or:

Code: Select all

WinKill, Advanced Uninstaller PRO ahk_class TfUninstallBubble
And I would use the title info as shown instead of leaving it out like you did with WinClose in case another window becomes active, you don't want to kill that. Note that WinKill doesn't kill the process. If this is just a popup of a program that is still running, it would just kill that window.
taylope1
Posts: 5
Joined: 15 Oct 2019, 04:15

Re: Wait for window, then send a cancel command

16 Oct 2019, 12:33

Thanks again but alas it does not kill the window still....most annoying...
latest script.jpg
latest script.jpg (69.85 KiB) Viewed 1023 times
Any more ideas?
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Wait for window, then send a cancel command

16 Oct 2019, 12:52

ControlClick the x or cancel control. If there isn't a control, you can try sending it at exact (client-based) coordinates. I have several persistent windows such as this, and giving them the interaction they expect usually gives positive results. It has for me, anyways.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Wait for window, then send a cancel command

16 Oct 2019, 13:11

Since the title you found for this window doesn't match what is shown on the actual popup (Application uninstall clean-up) and because the close button on it is not standard, it seems it's not an actual stand-alone window but probably drawn within the application's larger window. In that case, then I expect MasonJar13's suggstion of clicking the red X or whatever else will properly dismiss it is going to be the only way.
taylope1
Posts: 5
Joined: 15 Oct 2019, 04:15

Re: Wait for window, then send a cancel command

17 Oct 2019, 02:41

Tried MouseClick and Click using client position cords still nowt....

here is the current code

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Modified original script
setTitleMatchMode 3
loop{
winwait,Advanced Uninstaller PRO ahk_class TfUninstallBubble
Sleep 2000
winActivate,Advanced Uninstaller PRO ahk_class TfUninstallBubble
WinWaitActive, Advanced Uninstaller PRO ahk_class TfUninstallBubble
CoordMode, Mouse, Client
MouseClick, left, 382, 15
}
esc::exitapp

If I use my keyboard an Alt F4 will close it....

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Giresharu, inseption86, KruschenZ, mikeyww, songdg, Swiftly9767 and 284 guests