Increase reliability of my script? Topic is solved

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

Increase reliability of my script?

06 Mar 2020, 06:57

Dear all,

My script

I have a script which allows me to enter a complaint number in an input box.
Saves this number as a variable. Waits for save-as window to pop up. Pushes this variable to the filename box.

Code: Select all

InputBox, complaint, Enter complaint
sleep, 1500
send ^+{s}  ;shortcut for file-> save as
WinWait, Save As
sleep, 1000
send %complaint% initial assessment
sleep, 100	

having trouble

Many times the input box pops up, I enter my number then nothing happens after. Its as if the script just stops.
I introduced a sleep of 1500 and winwait to deal with this problem. However issue remains.
6-march input box.PNG
6-march input box.PNG (24.6 KiB) Viewed 243 times
6-march save as.png
6-march save as.png (92.97 KiB) Viewed 243 times



Your help is always appreciated
Thanks
J
vsub
Posts: 410
Joined: 29 Sep 2015, 03:39

Re: Increase reliability of my script?  Topic is solved

06 Mar 2020, 07:13

What program triggers the Save as dialog?

Here some ideas

Code: Select all

F1::
Keywait,F1
WinGet,ID,ID,A
InputBox, complaint, Enter complaint
WinActivate,ahk_id %ID%
send ^+{s}  ;shortcut for file-> save as
WinWaitActive, Save As ; WainWait executes the next command immediately after the window appear which can case problems
ControlSetText,Edit1,% complaint "initial assessment",A
Send,{Enter}
Return

Or

Code: Select all

F1::
Keywait,F1
WinGet,ID,ID,A
InputBox, complaint, Enter complaint
WinMenuSelectItem,% ID,,File,Save as ;ths will work even if the windows is not active but depending on the program,it may not support this
WinWaitActive, Save As ; WainWait executes the next command immediately after the window appear which can case problems
ControlSetText,Edit1,% complaint "initial assessment",A
Send,{Enter}
Return
JKnight_xbt33
Posts: 86
Joined: 18 Sep 2019, 02:06

Re: Increase reliability of my script?

10 Mar 2020, 05:25

Thanks for your response,
I used your script. It didnt work as intended because it proceeded to edit1 before the save as window was active.

So i experimented and put back the sleep after the winwait active and it worked perfectly.

Also another note is compared to my send command the ControlSetText,Edit1 command was far more efficient pasting the text into the window immediately.

The combined script below is working for me 100% of the time:

Code: Select all

#UseHook On

^#t::
setkeydelay , -1
WinGet,ID,ID,A
InputBox, complaint, Enter complaint
WinActivate,ahk_id %ID%
send ^+{s}  ;shortcut for file-> save as
WinWaitActive, Save As ; WainWait executes the next command immediately after the window appear which can case problems
sleep, 1000
ControlSetText,Edit1, %complaint% initial assessment,A
sleep, 100	

once again I appreciate the help & idea
best
J

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, Bing [Bot], Byg, Eureka and 160 guests