Rookie Autohotkey ???

What other productivity software are you working with...
Post Reply
Regmos
Posts: 268
Joined: 22 Dec 2012 07:27
Location: Copenhagen

Rookie Autohotkey ???

Post by Regmos »

Hi.

Very poor "scripter" relying on the expertise in this brilliant forum :)

I have made a simpel AHK script that launches a few programs including SUMo which starts and performs an update check.

Code: Select all

run "C:\Program Files\XYplorer\XYplorer.exe" /win=min
sleep 1000
run "C:\Program Files\PhraseExpress\phraseexpress.exe"
sleep 1000
Run "C:\Users\Regmos\AppData\Roaming\Dropbox\bin\Dropbox.exe" /home
Sleep 3000
Run "C:\Users\Regmos\Documents\Portable Apps\sumo\SUMo.exe"
Sleep 20000
send {F5} ; or {Enter} doesn't matter
Is there a way to replace the long "sleep 20000" and make AHK wait for the "Kontrollér" (Check) button to become active (Server online). The server is not always reliable, and 20 seconds can feel like a long time if it is.

Image

I have tried WinWait and WinWaitActive but i can't figure out what to wait for.

Image

Does anyone know the secret :?:
Kind regards
Regmos

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Rookie Autohotkey ???

Post by binocular222 »

Post in AHK forum is better for sure.
Anyway, using AU3_spy.exe, what is the difference between active and inactive state?
It's highly likely that there's no difference, then there're still several ways:
- Search particular pixel in that SUMO window (the statusbar) to see when the "online" word popup
- Check internet connection between SUMO and the internet. I think that when it finnish checking, the connection will cease
- Analyze the data package transfer from server to your computer, which is erh, way beyond my knowledge
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

highend
Posts: 13277
Joined: 06 Feb 2011 00:33

Re: Rookie Autohotkey ???

Post by highend »

You're looking for:

ControlGet, OutputVar, Cmd [, Value, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]

Cmd = Enabled
Returns 0 / 1

E.g.
ControlGet, value, Enabled, , TJvImgBtn6, ahk_class TMainDlg
MsgBox, %value%

And for the waiting part...

Code: Select all

SetTimer, CheckSumoButton, 250
return

CheckSumoButton:
ControlGet, value, Enabled, , TJvImgBtn6, ahk_class TMainDlg
if value
    ; do something
return
One of my scripts helped you out? Please donate via Paypal

Regmos
Posts: 268
Joined: 22 Dec 2012 07:27
Location: Copenhagen

Re: Rookie Autohotkey ???

Post by Regmos »

Thanks :D
I'm working on it and I think I'm beginning to understand a little bit.
I'll be back 8)
Kind regards
Regmos

Regmos
Posts: 268
Joined: 22 Dec 2012 07:27
Location: Copenhagen

Re: Rookie Autohotkey ???

Post by Regmos »

Still struggling. It's a bit harder than I imagined :(

What i want, is the script to run an update check and close down afterwards. When using the code below, it starts SUMo, the script closes and nothing else happens.

Code: Select all

Run "C:\Users\Regmos\Documents\Portable Apps\sumo\SUMo.exe"
sleep 2000
SetTimer, CheckSumoButton, 250
return

CheckSumoButton:
ControlGet, value, Enabled, , TJvImgBtn6, ahk_class TMainDlg
if 1
    send {F5}
return
If I add a shortcut (+!s::) or #Persistent it works like expected, but i keeps looping like a madman, performing update check after update check.
Is there a way to stop that ? I have tried to Exit, to ExitApp and putting it to sleep, but that doesn't work, and I have no idea what else to do :?
Kind regards
Regmos

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Rookie Autohotkey ???

Post by bdeshi »

Set the timer off after the button is enabled.

Code: Select all

if 1
{
    send {F5}
    SetTimer, CheckSumoButton, off
}
Disclaimer: just a guess, didn't try. AFK.
EDIT: see binocular222's post below. Didn't notice that if 1 at all! :oops:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13277
Joined: 06 Feb 2011 00:33

Re: Rookie Autohotkey ???

Post by highend »

Code: Select all

Run "C:\Users\Regmos\Documents\Portable Apps\sumo\SUMo.exe"
sleep 2000
SetTimer, CheckSumoButton, 250
return

CheckSumoButton:
ControlGet, value, Enabled, , TJvImgBtn6, ahk_class TMainDlg
if 1
    send {F5}
return
Why do you still use a sleep command? The timer will do what you need.
Wouldn't it just work to add ExitApp after send{F5}?
One of my scripts helped you out? Please donate via Paypal

Regmos
Posts: 268
Joined: 22 Dec 2012 07:27
Location: Copenhagen

Re: Rookie Autohotkey ???

Post by Regmos »

SammaySarkar wrote:Set the timer off after the button is enabled.
Sorry, didn't work.
highend wrote:Why do you still use a sleep command? The timer will do what you need
To give SUMo a chance to appear. If I don't put it to sleep, it seems like the script is looking elsewhere for the "CheckSumoButton" and the desktop starts flickering.
Wouldn't it just work to add ExitApp after send{F5}?
Unfortunately not. It just terminates the script right after SUMo has started, and nothing else happens.

I think I'll go back to using SUMo the old fashioned way, and click "Kontrollér" with my mouse. Thanks a lot for the effort :D
Kind regards
Regmos

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Rookie Autohotkey ???

Post by binocular222 »

You are almost there. The line "if 1" is blatantly wrong

Code: Select all

Run "C:\Users\Regmos\Documents\Portable Apps\sumo\SUMo.exe"
sleep 2000
SetTimer, CheckSumoButton, 250
return

CheckSumoButton:
ControlGet, OutputVar, Enabled, , TJvImgBtn6, ahk_class TMainDlg
if OutputVar
  Sendinput {F5}
Exitapp
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

highend
Posts: 13277
Joined: 06 Feb 2011 00:33

Re: Rookie Autohotkey ???

Post by highend »

No need to give up...

Code: Select all

#Persistent

Run "C:\Users\Regmos\Documents\Portable Apps\sumo\SUMo.exe"

SetTimer, CheckSumoButton, 250
return

CheckSumoButton:
ControlGet, value, Enabled, , TJvImgBtn6, ahk_class TMainDlg
if value
{
	ControlSend, , {F5}, ahk_class TMainDlg
	Exitapp
}
return
Use this. Tested, works. And ofc you don't need the sleep command^^
One of my scripts helped you out? Please donate via Paypal

Regmos
Posts: 268
Joined: 22 Dec 2012 07:27
Location: Copenhagen

Re: Rookie Autohotkey ???

Post by Regmos »

highend wrote:...Tested, works...
This is getting weird. Something must be rotten in the state of Denmark.

Your last script starts SUMo and then the script closes. If I remove ExitApp, it works but keeps looping. Something must be wrong in my end :?

Thanks a lot for trying, but I think I'll settle for the extra click.
Kind regards
Regmos

Regmos
Posts: 268
Joined: 22 Dec 2012 07:27
Location: Copenhagen

Re: Rookie Autohotkey ???

Post by Regmos »

I decided to give it another go, and this works.

Code: Select all

run "...previous step..."
Run "C:\Users\Regmos\Documents\Portable Apps\sumo\SUMo.exe"
winwait, SUMo                                                                             
Loop {
     Sleep 200
     ControlGet bEnabled, Enabled, , TJvImgBtn6, ahk_class TMainDlg
     If bEnabled
          Break
}                                                                             
send {F5}                                                               
winwaitclose                                                         
sleep 2000                                                             
run "...next step...."
It only took a year, but patience seems to be rewarded 8)
Kind regards
Regmos

Post Reply