Sleep Is Being Inconsistent Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
abcjme
Posts: 65
Joined: 08 Mar 2018, 10:48

Sleep Is Being Inconsistent

04 Jul 2018, 09:38

This script makes snapped windows hug the side of the screen better. That way, it's easier to click the scroll-bar rather than the window edges.

With that noted, its operations screw up about 5% of the time. It might do something out of order, or just miss a step entirely. I've tried many different sleep lengths. Some work better than others, but none have worked 100%. Is there a way to get this to work with 100% (or at least 99+%) consistency?

Code: Select all

a::
mousemove, 960, 1080, 0
sleep 64
send !{space}
sleep 128
send m
sleep 64
send {right}
sleep 128
send {enter}
sleep 64
send !{space}
sleep 128
send s
sleep 64
send {left}
sleep 64
send {left}
sleep 128
send {enter}
sleep 64
return
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Sleep Is Being Inconsistent

04 Jul 2018, 11:32

Hi abcjme:
I don't really understand what you want to do
"This script makes snapped windows hug the side of the screen better. That way, it's easier to click the scroll-bar rather than the window edges."
But this will keep the left side of the window where it is and expand the window to the right with each key press.
You really don't need any "sleeps".
hunter99

Code: Select all

;get a copy of CodeQuicktester by GeekDude from here:
;https://autohotkey.com/boards/viewtopic.php?f=6&t=6113

a::
mousemove, 960, 1080, 0
sendinput !{space}m{right}{enter}!{space}s{left 2}{enter}
return
abcjme
Posts: 65
Joined: 08 Mar 2018, 10:48

Re: Sleep Is Being Inconsistent

04 Jul 2018, 12:18

hunter99 wrote:Hi abcjme:
I don't really understand what you want to do
"This script makes snapped windows hug the side of the screen better. That way, it's easier to click the scroll-bar rather than the window edges."
But this will keep the left side of the window where it is and expand the window to the right with each key press.
You really don't need any "sleeps".
hunter99

Code: Select all

;get a copy of CodeQuicktester by GeekDude from here:
;https://autohotkey.com/boards/viewtopic.php?f=6&t=6113

a::
mousemove, 960, 1080, 0
sendinput !{space}m{right}{enter}!{space}s{left 2}{enter}
return
The issue isn't ONLY about my script. It's also about the general phenomenon of a script being inconsistent in its operations, despite having adequate sleep lengths. Anyway, here's a 1-minute demo and explanation of my script:
https://www.dropbox.com/s/m8yor7thnojkf ... r.mp4?dl=0
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Sleep Is Being Inconsistent

04 Jul 2018, 15:14

WinGetPos to obtain the coords of the window you wanna resize.
Compute your desired new coordinates.
WinMove your window using the newly computed coordinates.
no need to mess around with this hotkey sending stuff
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Sleep Is Being Inconsistent  Topic is solved

04 Jul 2018, 15:20

Hi abcjme:
Don't know why the "a" key would work for your script and not mine. Should not need to use sleeps for that script, at least when using "SendInput".
See remarks for Sleep command. It is not a accurate timer.

Try this, it should do what i think you want.

1::
WinGetPos, x,,,, A
WinMove, A,, x, , (A_ScreenWidth-(x-15)) ;adjust the 15 to suit
return

hunter99
abcjme
Posts: 65
Joined: 08 Mar 2018, 10:48

Re: Sleep Is Being Inconsistent

04 Jul 2018, 19:28

hunter99 wrote:Hi abcjme:
Don't know why the "a" key would work for your script and not mine. Should not need to use sleeps for that script, at least when using "SendInput".
See remarks for Sleep command. It is not a accurate timer.

Try this, it should do what i think you want.

1::
WinGetPos, x,,,, A
WinMove, A,, x, , (A_ScreenWidth-(x-15)) ;adjust the 15 to suit
return

hunter99
Ah, that works perfectly! Thank you!!!

For anyone that likes to write super compact code, it'll actually function with as little as this:

Code: Select all

1::
wingetpos x,,,,a
winmove a,,x,,(a_screenwidth-(x-16))
return
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Sleep Is Being Inconsistent

04 Jul 2018, 20:12

It looks like my last post without the comment and my name.
But reason for this post is:
Got to thinking about your original post, you never asked that the window be resized, just moved.
So here it is.
;===================================================
1::
WinGetPos, x,, w,, A
WinMove, A,, A_ScreenWidth-(w-15) ;adjust the 15 to suit
return
;=========================================================
hunter99

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, Google [Bot], joedf, Nerafius and 172 guests