Jump to content

Recommended Posts

Posted

Hi all. I ve made this small program to scroll through my document during reading it. It will spare me a lot of mouse clicks. The only problem is that i cant get it out from sleep can anyone help me with this please? Thanks in advance.

HotKeySet("1", "slow_down")
HotKeySet("2", "speed_up")


sleep(4000)
$original_window = WinGetTitle("", "")
$new_window=$original_window
$sleep_time=10000
while $new_window=$original_window 
    send("{DOWN}",0)
    sleep($sleep_time)
    $new_window = WinGetTitle("", "")
WEnd

Func slow_down()
;MsgBox(0,"test",$sleep_time)
    $sleep_time=$sleep_time/2
    TrayTip("Speed", $sleep_time, 5, 1)
    
EndFunc


Func speed_up()
;MsgBox(0,"test",$sleep_time)
    $sleep_time=$sleep_time*2
    TrayTip("Speed", $sleep_time, 5, 1)
EndFunc
Posted

Try this:

replace

$sleep_time=10000

with

Global $sleep_time=10000
Hi Zedna. Thank you very much for your fast reply. Actually i realize now that i didnt describe the problem well. The problem at the moment is when i press 1 which corresponds to decreasing the sleep time, it first finish the original sleep command which is 10 sec. What i want to do is when i redefine the sleep time it sleeps the new time and not the old time. The code in the current form is working fine but this problem is quite annoying.
Posted

HotKeySet("1", "slow_down")
HotKeySet("2", "speed_up")

Global $IsBreak = 0

sleep(4000)
$original_window = WinGetTitle("", "")
$new_window=$original_window
$sleep_time=10000
while $new_window=$original_window 
    send("{DOWN}",0)
    MySleep($sleep_time)
    $new_window = WinGetTitle("", "")
WEnd

Func slow_down()
;MsgBox(0,"test",$sleep_time)
    $sleep_time=$sleep_time/2
    TrayTip("Speed", $sleep_time, 5, 1)
    $IsBreak = 1
EndFunc


Func speed_up()
;MsgBox(0,"test",$sleep_time)
    $sleep_time=$sleep_time*2
    TrayTip("Speed", $sleep_time, 5, 1)
    $IsBreak = 1
EndFunc

Func MySleep($msec)
    For $i = 1 To $msec/100
        Sleep(100)
        If $IsBreak = 1 Then
            $IsBreak = 0
            Return
        EndIf
    Next
EndFunc

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...