Jump to content
Sign in to follow this  
Gif

Sleep

Recommended Posts

Gif

Do Functions work when the program sleeps?

example :

hotkeyset("!^e", "e_qu")

While 1
sleep(100000)
msgbox(0, "error", "error", 4)
Wend

Func e_qu()
   exit
EndFunc

Will the exit function work while in sleep mode?

Edited by c4nm7

Share this post


Link to post
Share on other sites
erebus

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

Share this post


Link to post
Share on other sites
Gif

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?

Share this post


Link to post
Share on other sites
herewasplato

...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]

Share this post


Link to post
Share on other sites
herewasplato

...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]

Share this post


Link to post
Share on other sites
herewasplato

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

You might take a look at SplashTextOn ().

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

Share this post


Link to post
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
Sign in to follow this  

×