Sign in to follow this  
Followers 0
joeyone

record mouseclick position when mouseclick?

6 posts in this topic

if i want to record the mousecursor xy position by only left clicking with the mouse is this possible

if its possible what code to use?

Share this post


Link to post
Share on other sites

if i want to record the mousecursor xy position by only left clicking with the mouse is this possible

if its possible what code to use?

Loop (Or AdlibEnable) + _IsPressed() + MouseGetPos()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Loop (Or AdlibEnable) + _IsPressed() + MouseGetPos()

i think this will work but i have som problem with the loop

i can only get it to click one time then the script shuts down

i want it to track for mouseclicks more than ones how can i be able to do that?

code

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1

If _IsPressed("01", $dll) Then

MsgBox(0,"_IsPressed", "End Key Pressed")

ExitLoop

EndIf

WEnd

DllClose($dll)

Share this post


Link to post
Share on other sites

i think this will work but i have som problem with the loop

i can only get it to click one time then the script shuts down

i want it to track for mouseclicks more than ones how can i be able to do that?

code

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1

If _IsPressed("01", $dll) Then

MsgBox(0,"_IsPressed", "End Key Pressed")

ExitLoop

EndIf

WEnd

DllClose($dll)

Didn't spend much time thinking about what the _IsPressed() example from the help file was doing...?

Take out the ExitLoop, and get the mouse pos:

#include <Misc.au3>

HotKeySet("{END}", "_Quit") ; Hit "END" to quit

$dll = DllOpen("user32.dll")
While 1
    If _IsPressed("01", $dll) Then
        $avMousePos = MouseGetPos()
        ToolTip("x = " & $avMousePos[0] & "  y = " & $avMousePos[1])
    EndIf
WEnd

Func _Quit()
    DllClose($dll)
    Exit
EndFunc   ;==>_Quit

:)

1 person likes this

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Didn't spend much time thinking about what the _IsPressed() example from the help file was doing...?

Take out the ExitLoop, and get the mouse pos:

#include <Misc.au3>

HotKeySet("{END}", "_Quit") ; Hit "END" to quit

$dll = DllOpen("user32.dll")
While 1
    If _IsPressed("01", $dll) Then
        $avMousePos = MouseGetPos()
        ToolTip("x = " & $avMousePos[0] & "  y = " & $avMousePos[1])
    EndIf
WEnd

Func _Quit()
    DllClose($dll)
    Exit
EndFunc   ;==>_Quit

:)

it works well. the only problem is that it saves down the mouse position multiple times for each position click in my ini file i write the position information to

is it possible to just write down just one record of each mouseclick and not multiple for each click?

#include <Misc.au3>

$idnumber = 0

$dll = DllOpen("user32.dll")
While 1
    If _IsPressed("01", $dll) Then
        $avMousePos = MouseGetPos()
        $posx = $avMousePos[0]
        $posy = $avMousePos[1]
        $idnumber += 1
        IniWrite("C:\Documents and Settings\Skrivbord\position.ini",";" & $idnumber ,"pos " , "MouseClick("&"left , "& $posx & ", " & $posy &", 1, 1)")
        sleep(100)
    EndIf
WEnd

Func _Quit()
    DllClose($dll)
    Exit
EndFunc;==>_Quit
Edited by joeyone

Share this post


Link to post
Share on other sites

it works well. the only problem is that it saves down the mouse position multiple times for each position click in my ini file i write the position information to

is it possible to just write down just one record of each mouseclick and not multiple for each click?

Yeah, the script loops many times before you can get your finger off the button. Try it this way:

#include <Misc.au3>

HotKeySet("{END}", "_Quit") ; Hit "END" to quit
$dll = DllOpen("user32.dll")
While 1
    If _IsPressed("01", $dll) Then
        $avMousePos = MouseGetPos()
        ToolTip("x = " & $avMousePos[0] & "  y = " & $avMousePos[1])
        Do
        Until Not _IsPressed("01", $dll)
    EndIf
WEnd

Func _Quit()
    DllClose($dll)
    Exit
EndFunc   ;==>_Quit

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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