AHK won't detect "Confirm Save As" button Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
t4akawolf
Posts: 12
Joined: 30 Jul 2016, 03:30

AHK won't detect "Confirm Save As" button

12 Jun 2019, 11:58

Part of a script I'm working on appends a prefix to an automated saved-file's name. Here's the relevant code:

Code: Select all

WinWaitActive, Save As, , 20
if ErrorLevel
{
	MsgBox, Try saving manually please.
}
else
{
	Send {Home}
	Send CNM
	Send {Space} {Enter}
	WinWaitActive, Confirm Save As, , 20
	if ErrorLevel
		{
			Send {Tab}
			Send {Enter}
		}
	else
		{
			Sleep 300
		}
	Send ^w
}
return
If no file pre-exists with the new filename, the script works fine. Otherwise, it gets stuck on the Confirm Save As dialog box, instead of Tabbing to "Yes" and hitting Enter.

Can someone tell me why this is happening and how to fix it?
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: AHK won't detect "Confirm Save As" button  Topic is solved

12 Jun 2019, 12:26

try putting some sleep after win Activate

and I swap Confirm Save As Activatation

Code: Select all

WinWaitActive, Save As,, 20
if ErrorLevel
{
	MsgBox, Try saving manually please.
}
else
{
	Sleep, 250  ;added Sleep
	Send {Home}
	Send CNM
	Send {Space}{Enter}
	WinWaitActive, Confirm Save As, , 20
	if ErrorLevel
	{
		Sleep 300
	}
	else
	{
		Sleep, 250  ;added Sleep
		Send {Tab}
		Send {Enter}
	}
	Send ^w
}
return
:wave: There is always more than one way to solve a problem. ;)
t4akawolf
Posts: 12
Joined: 30 Jul 2016, 03:30

Re: AHK won't detect "Confirm Save As" button

12 Jun 2019, 12:53

I don't understand. Why swap the two?

Isn't {Tab} {Enter} supposed to happen IF there is an Error (which in this case is the Confirm Save As box opening)?
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: AHK won't detect "Confirm Save As" button

12 Jun 2019, 12:57

ErrorLevel mean done waiting for the window

Code: Select all

	WinWaitActive, Confirm Save As, , 20
	if ErrorLevel
	{
		msgbox, I waited 20 second and the window didn't Activated
	}
	else
	{
		msgbox, I found the window send your keys now
	}
:wave: There is always more than one way to solve a problem. ;)
t4akawolf
Posts: 12
Joined: 30 Jul 2016, 03:30

Re: AHK won't detect "Confirm Save As" button

12 Jun 2019, 13:04

. . . I feel stupid.

I clearly used it the right way the first time. Not sure how I misunderstood the function immediately after :wtf:

Thank you. It worked.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], mikeyww and 329 guests