Jump to content

Sleep


Recommended Posts

I think not. Nothing works when the program sleeps; I think it is the same like pausing the program from its tray menu.

Use While Wend loops instead to see if it does the trick:

While 1

Wend

The idea behind this is that the program actually never sleeps, but it falls into an infinite loop. To see the difference, if you add a sleep delay into that While Wend loop, and you try to press your hotkey, you 'll see that sometimes the hotkey is not working. This happens because your keypress happens by luck when the Sleep() function is being executed. When the Sleep() function ends and only the loop's part is executed, you would be able to press your hotkey and call its function. So the more the Sleep() time you use, the less possibility you have to call your hotkey's function.

Edited by erebus
Link to comment
Share on other sites

I think not. Nothing works when the program sleeps; I think it is the same like pausing the program from its tray menu.

Use While Wend loops instead to see if it does the trick:

While 1

Wend

The idea behind this is that the program actually never sleeps, but it falls into an infinite loop. To see the difference, if you add a sleep delay into that While Wend loop, and you try to press your hotkey, you 'll see that sometimes the hotkey is not working. This happens because your keypress happens by luck when the Sleep() function is being executed. When the Sleep() function ends and only the loop's part is executed, you would be able to press your hotkey and call its function. So the more the Sleep() time you use, the less possibility you have to call your hotkey's function.

so how can i execute the same action (i mean the message box every 10000) while the function working?

Link to comment
Share on other sites

...Nothing works when the program sleeps; I think it is the same like pausing the program from its tray menu...

This is not true. Several things work "when the program sleeps" - HotKeys and Adlibs are but two.

Run this and let me know if the HotKeys that are set do not work for you 100% of the time.

HotKeySet("a", "_on")
HotKeySet("s", "_off")

While 1
    Sleep(2147483647) ;24 days of sleep
WEnd

Func _on()
    ToolTip("The tooltip is on.")
EndFunc   ;==>_on

Func _off()
    ToolTip("")
EndFunc   ;==>_off

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

...Will the exit function work while in sleep mode?

Yes, but the sleep mode is not the problem. The function will not work while the MsgBox is awaiting a user's interaction. Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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