Jump to content
Sign in to follow this  
Munky

Mouse Position Grabber

Recommended Posts

Munky

Tried creating a script that uses a hotkey to grab the current mouse position then write it to a file, but all attempts failed, for some reason FileWrite and FileWriteLine werent working properly? even tried writing "BLAH" instead of the mouse positions, but that failed too...

just wondering if anyone has any ideas?

Share this post


Link to post
Share on other sites
Outshynd

First step: posting your script.

Share this post


Link to post
Share on other sites
Munky

CODE

HotKeySet("{Enter}", "Write")

HotKeySet("{Escape}", "Kill")

;sets fileopen

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

;writes

Func Write()

$pos = MouseGetPos()

FileWrite($file, $pos[0] & " , " & $pos[1] & @CRLF)

EndFunc

;kills

Func Kill()

Exit

EndFunc

Share this post


Link to post
Share on other sites
Outshynd

Looks good to me. Test to see if $file = -1 after the FileOpen call, maybe? Don't really know why it would be but I can't think of anything else.

Share this post


Link to post
Share on other sites
Valuater

maybe...

HotKeySet("{F9}", "Write")
HotKeySet("{ESC}", "Kill")

;sets fileopen
$file = FileOpen( @ScriptDir & "\test.txt", 1)

While 1
    Sleep(20)
WEnd

;writes
Func Write()
    $pos = MouseGetPos()
    FileWrite($file, $pos[0] & " , " & $pos[1] & @CRLF)
EndFunc   ;==>Write

;kills
Func Kill()
    FileClose($file)
    Exit
EndFunc   ;==>Kill

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

Looks good to me. Test to see if $file = -1 after the FileOpen call, maybe? Don't really know why it would be but I can't think of anything else.

missing a While/Wend loop

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Munky

There we go :P must have been the while loop....

Thanx

Share this post


Link to post
Share on other sites
Valuater

Welcome

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Outshynd

Ha. Word to the wise: answering support questions while too sick to leave bed because you can't find anything else to do isn't always the best idea. :P

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  

×