Sign in to follow this  
Followers 0
buzz44

GUIGetMsg(), GUIGetCursorInfo()

6 posts in this topic

The below should exit when you mouse-up on the label, but often you have to click it a couple times for AutoIt to capture it.

If I wanted it to exit when click it, that is mouse-down, I could use If $msg = $test or If $CInfo[2] And $CInfo[4] = $test.

Is there a way I can speed up the below? Or atleast make it fire when the clicked happens? Or is there another way to get the control ID beneath the mouse.

#include <GUIConstants.au3>

GUICreate("My GUI")

$test = GUICtrlCreateLabel ("Click me...",  10, 30, 50)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    $CInfo = GUIGetCursorInfo()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $GUI_EVENT_PRIMARYUP And $CInfo[4] = $test Then Exit
Wend

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites



This works perfectly for me...

#include <GUIConstants.au3>

GUICreate("My GUI")

$test = GUICtrlCreateLabel ("Click me...",  10, 30, 50)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE OR $msg = $test Then ExitLoop
Wend

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes I know but that works when you want it to exit when you click the label, or in other words mouse down. I'm looking to make it exit when you mouse-up on the label. My code in my first post works but you often have to click the label a couple times for AutoIt to catch it, which in unacceptable.

Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

Ooh, I see. What about this one ?

#include <GUIConstants.au3>

GUICreate("My GUI")

$test = GUICtrlCreateLabel ("Click me...",  10, 30, 50)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    $curInfo = GUIGetCursorInfo()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    While $curInfo[4] = $test AND $curInfo[2] = 1
        Sleep(5)
        $curInfo = GUIGetCursorInfo()
        If $curInfo[2] = 0 AND $curInfo[4] = $test Then ExitLoop 2
    WEnd    
Wend

Share this post


Link to post
Share on other sites

Yes I know but that works when you want it to exit when you click the label, or in other words mouse down. I'm looking to make it exit when you mouse-up on the label. My code in my first post works but you often have to click the label a couple times for AutoIt to catch it, which in unacceptable.

<{POST_SNAPBACK}>

Have tested this when i was searching for a way to catch a doubbleclick, not all controls respond with a primairyup event on single click, this event is mostly triggered when you doubbleclick (dont know why)

trow in a consolewrite to check wich controls have this event (all the msg)

Share this post


Link to post
Share on other sites

Ooh, I see. What about this one ?

#include <GUIConstants.au3>

GUICreate("My GUI")

$test = GUICtrlCreateLabel ("Click me...",  10, 30, 50)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    $curInfo = GUIGetCursorInfo()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    While $curInfo[4] = $test AND $curInfo[2] = 1
        Sleep(5)
        $curInfo = GUIGetCursorInfo()
        If $curInfo[2] = 0 AND $curInfo[4] = $test Then ExitLoop 2
    WEnd    
Wend

<{POST_SNAPBACK}>

Thanks. It seems to work fine in this example but I'll have to test it in my project as alot of things are happening.

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

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