Sign in to follow this  
Followers 0
b0x4it

While-Loop Interuption after Screen-Saver

4 posts in this topic

#1 ·  Posted (edited)

I have a code whit a while-loop that is running all the time. I made the executable version of it and it is in the list of processes in task manager. It works perfectly without any issue, but when I leave computer untouched for long time to goes to screen-saver mode, the loop stops. After this, when I touch the mouse the executable is still in the list of the running processes, but it does not do what it does before this. If this happened, the only solution is to exist the process and re-run the exe file again.

I should say that I disabled the sleep after a specific idle time. So this happens by just screen-saver or dimming the screen.

I have sleep(100) in the loop.

Any idea why this is happening and how I can avoid this is highly appreciated!

Edited by b0x4it

Share this post


Link to post
Share on other sites



It all depends on what your script is doing, without knowing that we'd be guessing.

Post your script or at least a reproducer script that demonstrates the problem.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Sure, below is the simplified version of my cose (please excuse any typo).

This code is basicly the engine of my hotkeys. One of the hotkeys are just active when I am in an specific application. Once I leave that application, this code disable the hotkey. This is working perfectly, but when I leave my computer ON for long time (usually after it going to screen-saver mode), the while-loop is not working anymore. The executable is still in the running process list. I test this using the TestHotkey function which enables $temp2. When the loop is active, it shows the messagebox, but when the issue happens, no message box will appear! Any idea or solution?

Local $fActive = False

HotKeySet("+^!f", "TestHotkey")
HotKeySet("+^!{F4}", "ExitHotkey")

While 1

    If WinActive("Application Pro 4.5") <> 0 AND NOT $fActive Then
        HotKeySet("n", "ApplicationSendKey")
        $fActive = True
    ElseIf WinActive("Application Pro 4.5") = 0 AND $fActive Then
        HotKeySet("n")
        $fActive = False
    EndIf

    If $temp2 = True Then
        MsgBox(0, "", "loop is active")
        $temp2 = False
    EndIf

    Sleep(100)

WEnd

;#####################################################################################################

Func ApplicationSendKey()
    ;... some code
EndFunc   ;==>ApplicationSendKey

Func TestHotkey()
    $temp2 = True
EndFunc   ;==>TestHotkey

Func ExitHotkey()
    Exit
EndFunc   ;==>ExitHotkey

Share this post


Link to post
Share on other sites

I found the problem. It has nothing to do with what I was thinking. The issue for another internal While-Loop, and it is now fixed. Sorry for this!

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  
Followers 0