Sign in to follow this  
Followers 0
Valuater

GUIGetCursorInfo() - errors out / no array

8 posts in this topic

GUIGetCursorInfo() errors out ( no array ) when used on a child GUI??

Example

change $IDC = 1 to $IDC = 0 and it will work fine for the parent GUI

#include <GUIConstants.au3>
$IDC = 1
HotkeySet("{Esc}", "GetPos")

$papa = GUICreate("Papa") ;, 400, 400, -1, -1, $WS_CLIPSIBLINGS);, $WS_EX_MDICHILD)
If $IDC >= 1 Then GUISetState()

If $IDC >= 1 Then $kid = GUICreate("Child", 200, 200, 50, 50, $WS_CHILD, -1, $papa)
If $IDC >= 1 Then GUISetBkColor( 0xFFFFFF, $kid)
$x=GUICtrlCreateLabel ("0", 10, 10,50)
$y=GUICtrlCreateLabel ("0", 10, 30,50)
GUISetState()


; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Exit

Func GetPos()
    If $IDC >= 1 Then
        GUISwitch($kid) ; no help
        $a=GUIGetCursorInfo($kid) ; doesn't work
    Else
        $a=GUIGetCursorInfo()
    EndIf
    GUIctrlSetData($x,$a[0]) 
    GUIctrlSetData($y,$a[1]) 
EndFunc

I have tried everything i could think of

thx

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites



Not sure if it was meant to be this way but it makes sense, if the window is a child then everything is still relative to the parent, how would the child window have focus?


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I understand what you are saying, but if i use this script ( only commented out the get cur info )

with $IDC = 1 the info at the top left corner of the child is 0/0

with $IDC = 0 the 0/0 is the top left corner of the parent ????

#include <GUIConstants.au3>
$IDC = 1
HotkeySet("{Esc}", "GetPos")

$papa = GUICreate("Papa") ;, 400, 400, -1, -1, $WS_CLIPSIBLINGS);, $WS_EX_MDICHILD)
If $IDC >= 1 Then GUISetState()

If $IDC >= 1 Then $kid = GUICreate("Child", 200, 200, 50, 50, $WS_CHILD, -1, $papa)
If $IDC >= 1 Then GUISetBkColor( 0xFFFFFF, $kid)
$x=GUICtrlCreateLabel ("0", 10, 10,50)
$y=GUICtrlCreateLabel ("0", 10, 30,50)
GUISetState()


; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Exit

Func GetPos()
    ;If $IDC >= 1 Then
    ;    GUISwitch($kid) ; no help
    ;    $a=GUIGetCursorInfo($kid) ; doesn't work
    ;Else
        $a=GUIGetCursorInfo()
    ;EndIf
    GUIctrlSetData($x,$a[0]) 
    GUIctrlSetData($y,$a[1]) 
EndFunc

actually what i was after is to get a control's info on the child ( like a button ) and i cant get anything..

it doesn't matter if i use the parent, child or "" the parameter

thx

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Func GetPos()
    ;If $IDC >= 1 Then
    ;    GUISwitch($kid) ; no help
    ;    $a=GUIGetCursorInfo($kid) ; doesn't work
    ;Else
    GUISetState(@SW_SHOW, $papa)
    $a = GUIGetCursorInfo()
    ;EndIf
    GUICtrlSetData($x, $a[0])
    GUICtrlSetData($y, $a[1])
    Sleep(1000)
    GUISetState(@SW_SHOW, $kid)
    $a = GUIGetCursorInfo()
    GUICtrlSetData($x, $a[0])
    GUICtrlSetData($y, $a[1])
EndFunc   ;==>GetPos


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Just wanted to clarify something for you Valuater

Here's the reason(s) why the GuiSwitch didn't work for you

GuiSwitch:

Many of the GUI specific functions work on the "current" window - this is usually the last window created with GUICreate. This function allows you to make another window "current". That's does not mean that the referenced window will become active. You have to use WinActivate.

GUIGetCursorInfo:

The mouse cursor position is successful only on an active window created by a GUICreate.

Using GuiSetState or WinActivate should occomplish what your wanting.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Just wanted to clarify something for you Valuater

Here's the reason(s) why the GuiSwitch didn't work for you

GuiSwitch:

GUIGetCursorInfo:

Using GuiSetState or WinActivate should occomplish what your wanting.

thanks for the insight Gary, I am not out of the woods yet, but i would need to clarify the problem i am having ( a demo/example ) unless i can get it to work

thanks again

Valuater

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
$IDC = 1
HotkeySet("{Esc}", "GetPos")

$papa = GUICreate("Papa") ;, 400, 400, -1, -1, $WS_CLIPSIBLINGS);, $WS_EX_MDICHILD)
If $IDC >= 1 Then GUISetState()

If $IDC >= 1 Then $kid = GUICreate("Child", 200, 200, 50, 50, $WS_CHILD, -1, $papa)
If $IDC >= 1 Then GUISetBkColor( 0xFFFFFF, $kid)
$x=GUICtrlCreateLabel ("0", 10, 10,50)
$y=GUICtrlCreateLabel ("0", 10, 30,50)
GUISetState()


; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Exit

Func GetPos()
    If $IDC >= 1 Then GUISetState(@SW_SHOW, $kid)
     $a=GUIGetCursorInfo()
    GUIctrlSetData($x,$a[0])
    GUIctrlSetData($y,$a[1])
EndFunc


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

well guess i got it

#include <GUIConstants.au3>
$IDC = 1
HotkeySet("{Esc}", "GetPos")

$papa = GUICreate("Papa") ;, 400, 400, -1, -1, $WS_CLIPSIBLINGS);, $WS_EX_MDICHILD)
If $IDC >= 1 Then GUISetState()

If $IDC >= 1 Then $kid = GUICreate("Child", 200, 200, 50, 50, $WS_CHILD, -1, $papa)
If $IDC >= 1 Then GUISetBkColor( 0xFFFFFF, $kid)
$x=GUICtrlCreateLabel ("0", 10, 10,50)
$y=GUICtrlCreateLabel ("0", 10, 30,50)

$btn = GUICtrlCreateButton("test", 60, 150, 70, 30)
GUISetState()


; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Exit

Func GetPos()
    GUISetState(@SW_SHOW, $kid)
    $a = GUIGetCursorInfo()
    If $a[4] = $btn Then
        ToolTip("Button active", 20, 20)
    Else
        ToolTip("")
    EndIf
    GUICtrlSetData($x, $a[0])
    GUICtrlSetData($y, $a[1])
EndFunc   ;==>GetPos

thanks again

8)


NEWHeader1.png

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