Jump to content

Detecting mouseclicks


esteban
 Share

Recommended Posts

Ok Im trying to write a script that will detect where the mouse is clicked and also the delay between the events. What i have right now works excellent if I am only recording single clicks. I know why this is happening See "decides to write or not". I added this because the coordinates were being written to the file hundreds of times and I only wanted 1 per click. So now if I click in the same place 2 times in a row the second click is not written.

Does any one have any suggestions for me to record double clicks and prevent writing the same thing multiple times? any input would be very helpful.

CODE

$file1 = FileOpen("Positions.txt", 1)

$file2 = FileOpen("delays.txt", 1)

$pos1=_arraycreate(1,2)

$delay=0

$begin=0

$pos = ""

$dll = DllOpen("user32.dll")

$write = 0

While 1

;left mouse

If _IsPressed("01", $dll) Then

$pos = MouseGetPos()

;decides to write or not

If $pos1[0] <> $pos[0] Then

$delay=TimerDiff($Begin)

$write = 1

$Begin=Timerinit()

EndIf

;writes the position and the delay to files

If $write = 1 Then

FileWrite($file1,'"left"'&","& $pos[0] & "," & $pos[1] & @CRLF)

if $delay<>0 then

Filewrite($file2,$delay& @crlf)

EndIf

$pos1 = $pos

$write = 0

EndIf

EndIf

If _IsPressed(20, $dll) Then

Filewrite($file2,"1"& @crlf)

FileClose($file1)

ExitLoop

EndIf

Wend

Link to comment
Share on other sites

I did actually find your topic in my search, but I didn't pay much attention to it because the command is GUI oriented.I have a slight gui phobia. The help pages confused me too. Thanks for your input. I have to find something relatively simple, as i have no idea how to use DLLs.

Link to comment
Share on other sites

I did actually find your topic in my search, but I didn't pay much attention to it because the command is GUI oriented.I have a slight gui phobia. The help pages confused me too. Thanks for your input. I have to find something relatively simple, as i have no idea how to use DLLs.

Link to comment
Share on other sites

haha, srry it didnt work for you, if you ever need any GUI's I make them ok...not standard but they work nicely...

try using something along these lines:

While 1
   $Event=GUIGetMsg()
   select
      case $Event=$GUI_EVENT_PRIMARYDOWN
         sleep(500) ;ammount of delay to consider a double click
         $Event=GUIGetMsg()
         If $Event=$GUI_EVENT_PRIMARYDOWN then
            ;This area could be considered the Double Click code
         Else
            ;this could be considered the single click code
         EndIf
   EndSelect
WEnd

I can only think of GUI I based checking....so maybe you can refrence it?

*This code was not tested...simply a theory*

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Link to comment
Share on other sites

Psibernetic You are a genius. I got what i needed from your example. I couldent detect those double clicks because of the way i program, I dont usually use case or select in my scripts and if i use that with your delay idea i think i can do it. thank you !

Edited by esteban
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...