Sign in to follow this  
Followers 0
JackDinn

odd problem, intermittent hotkey delay

5 posts in this topic

#1 ·  Posted (edited)

Im 99% sure it something to do with my script but im dammed if i can figure it out what. When my prog is minimized to the tray it sits in this loop (below) this is when i sometimes have noticed that when i hit a hotkey for anything in windows say note pad ctrl alt N in my case it causes a delay and freezes my comp completely. it lasts for up to 5 seconds but can be shorter it happens on any hot key iv set in windows but only happens approx 10% of the time. i have tried removing the _ReduceMemory() func but still does it, i have included the script for it as it is part of the loop. I have also tried removing the tooltip commands.

I cant see any reason for this reaction at all but it diffidently dont happen when my script is not running. iv also tried to reproduce it with a small test script but have been unable to as yet (it a difficult fault as it happens so infrequently)

im really stumped but thought id just see if anyone else has ever noticed anything like it before ?

The loop it's happening in :-

Func wait()
    GUISetState(@SW_HIDE, $form1)
    $c = @MIN
    $memdown = @MIN
    $tgm = 0
    TraySetToolTip("JDAST. " & $timex & " Minute Cycles." & @CRLF & "Next Cycle in " & $timex - $trigger & " minutes")
    _reducememory()
    While $trigger < $timex
        $tgm = TrayGetMsg()
        If $tgm = $trayshow Or $tgm = $TRAY_EVENT_PRIMARYDOWN Then
            GUISetState(@SW_SHOW, $form1)
            GUISetState(@SW_RESTORE, $form1)
            main()
        EndIf
        If $tgm = $trayexit Then Exit
        If $tgm = $pause Then;;;;;;;;;;;;;;;;;;; tray pause
            If $pausetesting = 0 Then
                $pausetesting = 1
                TrayItemSetText($pause, "Un-Pause")
                TraySetIcon("Shell32.dll", -110)
            Else
                $pausetesting = 0
                TrayItemSetText($pause, "Pause")
                TraySetIcon("")
            EndIf
        EndIf
        If @MIN <> $c Then
            $trigger += 1
            $c = @MIN
        EndIf
        If $memdown <> @MIN Then
            TraySetToolTip("JDAST. " & $timex & " Minute Cycles." & @CRLF & "Next Cycle in " & $timex - $trigger & " minutes")
            _reducememory()
            $memdown = @MIN
        EndIf
    WEnd
    $trigger = 0
EndFunc ;==>wait

The _reducememory() func, although iv already tried taking this out from the loop.

Func _ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

Thx all.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites



Maybe add a sleep call here and there.

Share this post


Link to post
Share on other sites

Maybe add a sleep call here and there.

? a sleep call . why, its got a TrayGetMsg() which is a proper way to to not hold the uPro to ransom just like GUIGetMsg ()

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

or is it not the same , hmmm...


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

o and there's only 1 thing in the whole script that could possibly pull out from the loop

GUIRegisterMsg($WM_PAINT, "_ReDraw")

but this is not getting called as the Form is hidden (Minimized to tray) when the loop is running


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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