Sign in to follow this  
Followers 0
Frit

Mouse Pos

5 posts in this topic

Hi all!

I want to know a simple code that isn't working here.

It's about getting the mouse coordinates (mousegetpos), put them into a variable and show in a label.

Global $pos
HotKeySet( "{ESC}", "Exit" )
HotKeySet( "{F1}", "Getpos" )



GUICreate( 210, 100)
GUICtrlCreateLabel( $pos[0] & "," & $pos[1]), 10, 10)


While 1
GuiSetstate()
Wend

Func Getpos()
        $pos = MouseGetPos ( )
    EndFunc 




While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        
    EndSelect
WEnd

Func Exit()
    Exit
EndFunc

Everything goes well, without any error, but the pos isn't shown in the label.

Thank you.

Share this post


Link to post
Share on other sites



There was actually another issue with your 'Exit' function:

#include <guiconstants.au3>
Global $pos
HotKeySet( "{ESC}", "ExitNow" )
HotKeySet( "{F1}", "MouseSetPos" )

GUICreate( 210, 100)
Global $label = GUICtrlCreateLabel('', 10, 10, 100, 20)


GuiSetstate()
Func MouseSetPos()
    Local $pos = MouseGetPos()
    GUICtrlSetData($label, $pos[0] & ',' & $pos[1])
EndFunc

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd

Func ExitNow()
    Exit
EndFunc


[center]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.[/center]

Share this post


Link to post
Share on other sites

Hmm, thanks, works well.

To do not need to make a new thread, I'll ask for something more.

The following code was made to send "item1 activated" each 5 sec if It's selected in the combo. If somebody wants to help...

Global $combo
$combo = GUICtrlCreateCombo ("Item1", 10, 60, 100, 20)

While 1
    If $combo = "Item1" Then
        Sleep (5000)
        Send ("Item1 activated + {ENTER}")
    EndIf
WEnd

Share this post


Link to post
Share on other sites

If GUICtrlRead($combo) = 'Item1' Then


[center]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.[/center]

Share this post


Link to post
Share on other sites

Ok :)

Thank you again.

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