alternative way to trigger SaveAs dialog Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
JKnight_xbt33
Posts: 86
Joined: 18 Sep 2019, 02:06

alternative way to trigger SaveAs dialog

02 Apr 2020, 07:44

Dear all,
I had made a thread: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=73262
The suggestions helped me make my script more reliable...for a while.

Then one day I noticed the issue re-occuring. I decided to manually trigger SaveAs and to my surprise the script carried on working from there.

Problem: it seems therefore using send ^+{s} to trigger SaveAs is unreliable. Sometimes the SaveAs menu pops up and other times I will have to manually click it to make it work.

I wanted to use ComObject but I am afraid ComObject will trigger the whole process of saving the file in a folder. Which I don't want.

Code: Select all

^#y::
setkeydelay , -1
WinGet,ID,ID,A
InputBox, complaint, Enter complaint
WinActivate,ahk_id %ID%
send ^+{s}  ;shortcut for file-> save as
WinWaitActive, Save As ; 
sleep, 1000
ControlSetText,Edit1, %complaint% initial assessment,A
Is there more reliable way to trigger SaveAs in PDF files?
your help is always appreciated
J
User avatar
boiler
Posts: 4614
Joined: 21 Dec 2014, 02:44

Re: alternative way to trigger SaveAs dialog

02 Apr 2020, 09:03

Which program’s Save As dialog box are you trying to open?

Instead of:

Code: Select all

Send ^+s
(the { } you had around the s are not required)

...this can be more reliable:

Code: Select all

Send, {Ctrl down}{Shift down}s{Shift up}{Ctrl up}
...or even this:

Code: Select all

Send, {Ctrl down}{Shift down}
Sleep, 50
Send, s
Sleep, 50
Send, {Shift up}{Ctrl up}
JKnight_xbt33
Posts: 86
Joined: 18 Sep 2019, 02:06

Re: alternative way to trigger SaveAs dialog

03 Apr 2020, 08:02

I am triggering SaveAs on pdf files opened on internet explorer.

I'll try the second script you posted with the 50ms sleep.

After a few weeks of using this I'll be able to know how reliable it is.

Update: I've just tested the suggestion on 5 different PDF files. It worked on 2 out of 5 of the files even if I reload the script.

Conclusion: some sort of matrix glitch, I don't know what to make of it. Perhaps in a few months-year when am more familiar on AHK I'll look back and understand.

Appreciated
J
User avatar
boiler
Posts: 4614
Joined: 21 Dec 2014, 02:44

Re: alternative way to trigger SaveAs dialog

03 Apr 2020, 09:24

Just have it try again until it works. This should work every time:

Code: Select all

loop {
	Send, ^+s
	Sleep, 500
} until WinActive("Save As ahk_class #32770")
JKnight_xbt33
Posts: 86
Joined: 18 Sep 2019, 02:06

Re: alternative way to trigger SaveAs dialog

06 Apr 2020, 07:51

Great so I tried the latest script 9 times.

7/9 times no issues.
2/9 times it paused after the 1st input box, but when I simply clicked on PDF the script carried on as normal.

conclusion: This is the most reliable version yet. The issue with needing to click inside the PDF shows the script is sometimes losing focus for the PDF file. This explains why it carried on as normal after i clicked in the PDF, because the loop is continuously firing the SaveAs shortcut.

Improvements I can make:
after the input box I can put a short controlclick for the PDF window which will force the focus. Saves me having to click if it pauses.

Many thanks
User avatar
boiler
Posts: 4614
Joined: 21 Dec 2014, 02:44

Re: alternative way to trigger SaveAs dialog  Topic is solved

06 Apr 2020, 08:50

Edit: Glad it works, but see I pasted the same line twice without editing the second one. The following is what I meant and would be even more reliable:

Code: Select all

loop {
	WinActivate,ahk_id %ID%
	WinWaitActive,ahk_id %ID%
	Send, ^+s
	Sleep, 500
} until WinActive("Save As ahk_class #32770")
Last edited by boiler on 07 Apr 2020, 05:29, edited 2 times in total.
JKnight_xbt33
Posts: 86
Joined: 18 Sep 2019, 02:06

Re: alternative way to trigger SaveAs dialog

07 Apr 2020, 04:12

Perfect, no issues seen with this script.

:D
User avatar
boiler
Posts: 4614
Joined: 21 Dec 2014, 02:44

Re: alternative way to trigger SaveAs dialog

07 Apr 2020, 05:30

Noticed a mistake. See how I edited it in that post. Meant for the second line to be WinWaitActive, not another WinActivate.
teadrinker
Posts: 1487
Joined: 29 Mar 2015, 09:41
Contact:

Re: alternative way to trigger SaveAs dialog

07 Apr 2020, 06:00

@boiler
WinActivate wrote:Six attempts will be made to activate the target window over the course of 60ms. Thus, it is usually unnecessary to follow WinActivate with WinWaitActive or IfWinNotActive.
User avatar
boiler
Posts: 4614
Joined: 21 Dec 2014, 02:44

Re: alternative way to trigger SaveAs dialog

07 Apr 2020, 06:04

teadrinker wrote:
07 Apr 2020, 06:00
@boiler
WinActivate wrote:Six attempts will be made to activate the target window over the course of 60ms. Thus, it is usually unnecessary to follow WinActivate with WinWaitActive or IfWinNotActive.
Good to know. Thanks.

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, boiler, Eureka, JawGBoi, just me, Zeppy and 124 guests