Page 1 of 1

Sleep Is Being Inconsistent

Posted: 04 Jul 2018, 09:38
by abcjme
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

Re: Sleep Is Being Inconsistent

Posted: 04 Jul 2018, 11:32
by hunter99
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

Re: Sleep Is Being Inconsistent

Posted: 04 Jul 2018, 12:18
by abcjme
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

Re: Sleep Is Being Inconsistent

Posted: 04 Jul 2018, 15:14
by swagfag
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

Re: Sleep Is Being Inconsistent  Topic is solved

Posted: 04 Jul 2018, 15:20
by hunter99
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

Re: Sleep Is Being Inconsistent

Posted: 04 Jul 2018, 19:28
by abcjme
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

Re: Sleep Is Being Inconsistent

Posted: 04 Jul 2018, 20:12
by hunter99
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