Sign in to follow this  
Followers 0
Wath

Mouse position show constantly

8 posts in this topic

Hi all!

I need your helps! I would like to post on a GUI surface the mouse coordinates to input fields and i want them to change when I move the cursor.

Could someone help me?

$pos = MouseGetPos()
        GUICtrlCreateLabel("Mouse coord.:", 300, 5)
        GUICtrlCreateLabel("X:", 300, 20)
        GUICtrlCreateLabel("Y:", 350, 20)
        GUICtrlCreateInput($pos[0],275,35, 40, 20)
        GUICtrlCreateInput($pos[1],335,35, 40, 20)

It isn't working well because it is just show the position of the mouse at one time.

Thx!

Wath

Share this post


Link to post
Share on other sites



GUICtrlCreateLabel("Mouse coord.:", 300, 5)
GUICtrlCreateLabel("X:", 300, 20)
GUICtrlCreateLabel("Y:", 350, 20)
$X = GUICtrlCreateInput($pos[0], 275, 35, 40, 20)
$y = GUICtrlCreateInput($pos[1], 335, 35, 40, 20)
While 1
    $pos = MouseGetPos()
    GUICtrlSetData($X, $pos[0])
    GUICtrlSetData($y, $pos[0])
    Sleep(10)
WEnd


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

GUICtrlCreateLabel("Mouse coord.:", 300, 5)
GUICtrlCreateLabel("X:", 300, 20)
GUICtrlCreateLabel("Y:", 350, 20)
$X = GUICtrlCreateInput($pos[0], 275, 35, 40, 20)
$y = GUICtrlCreateInput($pos[1], 335, 35, 40, 20)
While 1
    $pos = MouseGetPos()
    GUICtrlSetData($X, $pos[0])
    GUICtrlSetData($y, $pos[0])
    Sleep(10)
WEnd

Hi!

I got the folowing error.

$X = GUICtrlCreateInput($pos[0],275,35,40,20)

$X = GUICtrlCreateInput($pos^ERROR

Error: Subscript used with non-Array variable.

I tried to put the while statement before the input fields but it was made unfinished loop.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try declaring $pos[2] before the whole script

EDIT:

Local $pos[2]

$test = GUICreate("test")
GUICtrlCreateLabel("Mouse coord.:", 300, 5)
GUICtrlCreateLabel("X:", 300, 20)
GUICtrlCreateLabel("Y:", 350, 20)
$X = GUICtrlCreateInput($pos[0], 275, 35, 40, 20)
$y = GUICtrlCreateInput($pos[1], 335, 35, 40, 20)
GUISetState(@SW_SHOW, $test)

While 1
    $pos = MouseGetPos()
    GUICtrlSetData($X, $pos[0])
    GUICtrlSetData($y, $pos[1])
    Sleep(10)
WEnd

This works fine for me

Edited by AoRaToS
1 person likes this

s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

Hi!

I got the folowing error.

$X = GUICtrlCreateInput($pos[0],275,35,40,20)

$X = GUICtrlCreateInput($pos^ERROR

Error: Subscript used with non-Array variable.

I tried to put the while statement before the input fields but it was made unfinished loop.

Ahh yeah now it's working well.

Thx for the fast help!

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