Jump to content
Sign in to follow this  
Frit

Mouse Pos

Recommended Posts

Frit

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
SmOke_N

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


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.

Share this post


Link to post
Share on other sites
Frit

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
SmOke_N

If GUICtrlRead($combo) = 'Item1' Then


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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.