Jump to content

record mouseclick position when mouseclick?


joeyone
 Share

Recommended Posts

  • Moderators

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.

Link to comment
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)

Link to comment
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

:)

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
Link to comment
Share on other sites

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
Link to comment
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
Link to comment
Share on other sites

  • 11 years later...
 
 
 
 
Quote
On 10/10/2007 at 10:59 PM, PsaltyDS said:

#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

 

Thankyou but this didnt work, still stuck in loop.

 

Link to comment
Share on other sites

Record 12-y necropost.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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...