Jump to content

A simple script that tells your mouse coordinates


sandman
 Share

Recommended Posts

GetMousePosition.au3This is an extremely simple script, and I am sure some of you have made much better ones and maybe already posted them here, but for those who don't have one of these, here's what it does:

Gives your mouse coordinates. Simple, huh?

You are free to edit and redistribute this but please put my name in the credits somewhere.

Just press the Home key whenever you need to know what screen coordinates your mouse is at and you will soon find out.

The code:

HotKeySet("{HOME}", "MouseGetCoords")

While 1
 Sleep(100)
Wend

Func MouseGetCoords()
    $pos = MouseGetPos()
    MsgBox(0, "Mouse position", $pos[0] & "," & $pos[1])
EndFunc

Credits:

Rizzet, for helping out on keeping the program running after one Home key press.. I know I'm not very good at this. :">

Jon, for making this language!

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

GetMousePosition.au3This is an extremely simple script, and I am sure some of you have made much better ones and maybe already posted them here, but for those who don't have one of these, here's what it does:

Gives your mouse coordinates. Simple, huh?

You are free to edit and redistribute this but please put my name in the credits somewhere.

Just press the Home key whenever you need to know what screen coordinates your mouse is at and you will soon find out.

The code:

HotKeySet("{HOME}", "MouseGetCoords")

While 1
 Sleep(100)
Wend

Func MouseGetCoords()
    $pos = MouseGetPos()
    MsgBox(0, "Mouse position", $pos[0] & "," & $pos[1])
EndFunc

Credits:

Rizzet, for helping out on keeping the program running after one Home key press.. I know I'm not very good at this. :">

Jon, for making this language!

Simple and usefull...

Thanks for posting

Ed

Link to comment
Share on other sites

Here's what I use (Less intrusive, and no need to click OK button):

HotKeySet("{HOME}", "_ToggleMouseCoords")
HotKeySet("{ESC}", "_ExitScript")

Global $Showing = False

While 1
 Sleep(100)
Wend

Func _ToggleMouseCoords()
    $Showing = Not $Showing
    
    If $Showing Then
        $pos = MouseGetPos()
        ToolTip('(' & $pos[0] & ',' & $pos[1] & ')',$pos[0],$pos[1])
    Else
        ToolTip('')
    EndIf
EndFunc

Func _ExitScript()
    Exit
EndFunc

{HOME} key to toggle on/off, {ESC} to exit script

----[ SandyD ]---
Link to comment
Share on other sites

Thanks for all your replies.. now I'm off to make something else. :whistle:

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

Im happy to help

Here is a little script that i use to get mouse cords and colors, i use this pretty often

#include <GUIConstants.au3>

Global $times

HotKeySet("{tab}", "_cords")
HotKeySet("{del}", "_cords2")
HotKeySet("+{esc}", "_Exit")

Opt("SendKeyDelay",100)
Opt("PixelCoordMode",0)
Opt("MouseCoordMode",0)

GUICreate("Mouse pos", 220, 300, -1, -1)

$button10= GUICtrlCreateButton("Clear", 20, 210, 65, 30)
$output3 = GUICtrlCreateLabel("", 20, 160, 80, 20, 0x1000)
$output4 = GUICtrlCreateLabel("", 20, 185, 80, 20, 0x1000)
$output2 = GUICtrlCreateLabel("", 20, 135, 80, 20, 0x1000)
$output1 = GUICtrlCreateLabel("", 20, 110, 80, 20, 0x1000)
$cn = GUICtrlCreateLabel("", 110, 110, 70,20, 0x1000)
$c = GUICtrlCreateedit("", 110, 135, 70,20, 0x1000)
$cb = GUICtrlCreateLabel("", 190, 135, 20,20, 0x1000)
$m1 = GUICtrlCreateLabel("", 110, 160, 70, 20, 0x1000)
$m2 = GUICtrlCreateLabel("", 110, 185, 70, 20, 0x1000)
GuiSetState ()

$times = 0

while 1
    $Mousecords = MouseGetPos()
    $PixCol = Pixelgetcolor($Mousecords[0], $Mousecords[1])
    GUICtrlSetData($cn, $PixCol)
    GUICtrlSetBkColor($cn, $PixCol)
    GUICtrlSetData($m1, $Mousecords[0])
    GUICtrlSetData($m2, $Mousecords[1])
    $msg = GUIGetMsg()
        Select
        Case $msg = $button10
             GUICtrlSetData($c, "")
             GUICtrlSetData($m1, "")
             GUICtrlSetData($m2, "")
             GUICtrlSetData($output1, "")
             GUICtrlSetData($output2, "")
             GUICtrlSetData($output3, "")
             GUICtrlSetData($output4, "")
             GUICtrlSetBkColor($cb, 15526360)
         EndSelect
     If $msg = $GUI_EVENT_CLOSE Then Exit
Wend

Func _cords()
    If not @error Then
        $times = $times + 1
        GUICtrlSetData($m1, $Mousecords[0])
        GUICtrlSetData($m2, $Mousecords[1])
        If $times = 1 then 
            GUICtrlSetData($output1, $Mousecords[0])
            GUICtrlSetData($output2, $Mousecords[1])
        elseif $times = 2 then 
            GUICtrlSetData($output3, $Mousecords[0])
            GUICtrlSetData($output4, $Mousecords[1])
        elseif $times = 3 then 
            GUICtrlSetData($c, $PixCol)
            GUICtrlSetBkColor($cb, $PixCol)
            $times = 0
        endif
    endif
endfunc

Func _cords2()
    $Mousecords = MouseGetPos()
    If not @error Then
        GUICtrlSetData($c, $PixCol)
        GUICtrlSetBkColor($cb, $PixCol)
    endif
endfunc

Func _Exit()
    Exit
EndFunc
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...