Jump to content
Sign in to follow this  
gamerman2360

Mouse Stuff

Recommended Posts

gamerman2360

First my script:

#include <GUIConstants.au3>
GUICreate("MouseRecorder")
HotKeySet("{ESC}", "Terminate")
$file = FileOpen("C:\Documents and Settings\Administrator\Desktop\New Text document.txt", 2)
Global $time

While 1
    While 1
        $i = GUIGetCursorInfo()
        If $i[2] = 1 Then
            $dif = TimerDiff($time)
            FileWriteLine($file, $dif);needs to not write the first time
            ExitLoop
        EndIf
    WEnd
    
    While 1
        $i = GUIGetCursorInfo()
        If $i[2] = 0 Then
            $time = TimerInit()
            ExitLoop
        EndIf
    WEnd
WEnd

Func Terminate()
    FileClose($file)
    Sleep(3000)
    Run("C:\Documents and Settings\Administrator\Desktop\New Text document.txt");I can't get the run to work.
    Exit
EndFunc  ;==>Terminate

Now my problem, is there a way to make it not take away all the CPU? If I run it in a lower priorty it works but i dont know if it affects the results.

Edited by gamerman2360

Share this post


Link to post
Share on other sites
buzz44

Try adding a Sleep(1) in the main loop.

Edit: Actually make that the loop with FileWriteLine()

Edited by Burrup

qq

Share this post


Link to post
Share on other sites
gamerman2360

#include <GUIConstants.au3>
GUICreate("MouseRecorder")
HotKeySet("{ESC}", "Terminate")
$file = FileOpen("C:\Documents and Settings\Administrator\Desktop\New Text document.txt", 2)
Global $time

While 1
    While 1
        $i = GUIGetCursorInfo()
        If $i[2] = 1 Then
            $dif = TimerDiff($time)
            ExitLoop
        EndIf
    WEnd
    
    While 1
        $i = GUIGetCursorInfo()
        If $i[2] = 0 Then
            $time = TimerInit()
            ExitLoop
        EndIf
    WEnd
    Sleep(1)
    FileWriteLine($file, $dif);needs to not write the first time
WEnd

Func Terminate()
    FileClose($file)
    Sleep(3000)
    Run("C:\Documents and Settings\Administrator\Desktop\New Text document.txt");I can't get the run to work.
    Exit
EndFunc ;==>Terminate

So this? I don't see how the FileWriteLine() change helps.

Share this post


Link to post
Share on other sites
buzz44

I mean move the Sleep(1) not FileWriteLine() lol, like this...

#include <GUIConstants.au3>
GUICreate("MouseRecorder")
HotKeySet("{ESC}", "Terminate")
$file = FileOpen("C:\Documents and Settings\Administrator\Desktop\New Text document.txt", 2)
Global $time

While 1
    While 1
        $i = GUIGetCursorInfo()
        If $i[2] = 1 Then
            $dif = TimerDiff($time)
            FileWriteLine($file, $dif);needs to not write the first time
            ExitLoop
        EndIf
        Sleep(1)
    WEnd
    While 1
        $i = GUIGetCursorInfo()
        If $i[2] = 0 Then
            $time = TimerInit()
            ExitLoop
        EndIf
    WEnd
WEnd

qq

Share this post


Link to post
Share on other sites
LxP

You mat find that a larger Sleep() value may help to further lower CPU usage (from recent posts it appears that Sleep(1) can be as bad as no Sleep() at all...).

Share this post


Link to post
Share on other sites
buzz44

Well I tested first and it drop's the CPU usage dramatically.


qq

Share this post


Link to post
Share on other sites
seandisanti

You mat find that a larger Sleep() value may help to further lower CPU usage (from recent posts it appears that Sleep(1) can be as bad as no Sleep() at all...).

<{POST_SNAPBACK}>

Actually i think the most recent stuff on sleep says that sleep(1) = sleep(15) rather than no sleep at all

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.