Jump to content

Need help with MouseGetPos


Recommended Posts

Hi, recently i was making a clicker(not a spammer nor a gamebot, just warning in advance) and i made a function to get the mouse position, this was pretty easy, follows what i got:

Global $pos

While 1
HotKeySet("{F1}","getpos")
WEnd

Func getpos()
$pos = MouseGetPos()
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
EndFunc

What i really want is get this determined positions, save them formated the way i want in a .txt file for example, if i got the following coords:

X: 156 Y: 593

X: 789 Y: 1007

X: 229 Y: 980

I want them to be sended to the .txt file this way:

MouseClick("Left",156,593)

MouseClick("Left",789,1007)

MouseClick("Left",229,980)

What I need is a mouseclick function maker to ease my use of this determined function.

Theres a way to do this? Can someone help?

Link to comment
Share on other sites

I've just read it, and made like this, still i get 'Error parsing function call'

Here is what I got:

Global $pos, $file

$file = FileOpen("test.txt", 1)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

While 1
HotKeySet("{F7}","Write")
HotKeySet("{F8}","Close")
WEnd

Func Write()
$pos = MouseGetPos()
FileWriteLine($file, "MouseClick("Left"," & $pos[0] & "," & $pos[1] & ")")
EndFunc

Func Close()
FileClose($file)
MsgBox(0, "Closing", "Closing...Have a nice day.")
Exit
EndFunc

Any idea what could be?

Link to comment
Share on other sites

@ahmet

Thanks for your support and for pointing me in the right directon. I followed you sleep inside while looping and worked fine.

This is the code case anyone in the future need:

Global $pos, $file

$file = FileOpen("coords.txt", 1)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

HotKeySet("{F7}","Write")
HotKeySet("{F8}","Close")

While 1
Sleep(100)
WEnd

Func Write()
$pos = MouseGetPos()
FileWriteLine($file, 'MouseClick("Left",' & $pos[0] & "," & $pos[1] & ")")
EndFunc

Func Close()
FileClose($file)
MsgBox(0, "Closing", "Closing...All coordinates were saved.")
Exit
EndFunc

Now I wonder if you or someone could help me in something else.

This time what I need is a function which will call all my MouseClick() events inside that .txt to the code itself and use it for example:

The .txt:

MouseClick("Left",550,549)
MouseClick("Left",901,550)
MouseClick("Left",517,398)
MouseClick("Left",421,449)
MouseClick("Left",439,489)
MouseClick("Left",852,561)
MouseClick("Left",648,343)
MouseClick("Left",455,447)

The Function to call the .txt:

HotKeySet("{F9}","_Call")

While 1
Sleep(100)
WEnd

Func _Call()
    ;call all those mouseclick() events inside the .txt and execute them here
    Sleep(1000)
EndFunc

My goal with this is save program code, instead of put like 3 or 4 function of clicking events i could leave the MouseClick() coords inside a .txt and call to one single function inside the program.

Thanks in advance. Any doubt ask me.

EDIT --

Nvm I found it how. Theres the code in the future if someone need it.

Func _Call()
    $file = FileOpen("coords.txt", 0)
    
    If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
    EndIf

    ; Read in lines of text until the EOF is reached
    While 1
        $line = FileReadLine($file)
        If @error = -1 Then ExitLoop
        Execute($line); Run the line readed from the file
    Wend

EndFunc
Edited by LordRaven
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...