Jump to content

Recommended Posts

  • Moderators
Posted (edited)

SmOke_N,

I am storing the last button that has focus. Are you saying that I could use an _IsPressed() for the tab key?

I will have to look at that.

I guess part of my concern was that I am now using OnEvent mode and was not sure of the best way to procede.

Thanks for the idea.

taurus905

Well, maybe you could use GUIRegisterMsg() or something since your using OnEventMode(), and you'll need to ask Gary about that one, I screw it up more times than I get it right. Edited by SmOke_N

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.

Posted

Well, maybe you could use GUIRegisterMsg() or something since your using OnEventMode(), and you'll need to ask Gary about that one, I screw it up more times than I get it right.

SmOke_N,

That's exactly what I was thinking. Atleast the GUIRegisterMsg() and asking Gary; not the you screwing up part. :D

Gary showed me how to use GUIRegisterMsg() to dynamically get the position and size of my window. It would be great if he could show me how to automatically tell which button in my gui had focus. Because it can be changed four ways; Tab key, Arrow key, Left mouse-click and Right mouse-click. And I want to be able to have my tooltip change as soon as it does without having to use a loop to check its status.

Thanks for your input.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted (edited)

I found it! :D

GUIRegisterMsg(13, "_Display_Key_Coords")

Thanks Emperor. Gary and SmOke_N for putting me on the right track.

I'm happy again.

taurus905

Edited by taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted

How about a link to where you got the value 13 for this?

Gary,

No link.

I just used trial-and-error until it turned into trial-and-success. :D

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted

hmmm would like to see how that's working, looks like 13 is WM_QUERYOPEN

Gary,

I need to do a few things today. But when I get back I will put together a small example script. That also helps me to better understand whats happening than trying to follow a long script.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted

hmmm would like to see how that's working, looks like 13 is WM_QUERYOPEN

Gary,

I am pretty sure you are right. I boiled down my large script to this short example.

Notice that if you comment out line 19:

$gui_state = WinGetState("Dynamic Tooltip Buttons")

It no longer works.

You can use the tab key, arrow keys or a left mouse-click to change focus and the tooltip.

I stumbled across this. I would be interested to see what else can be done with this method.

taurus905

; Dynamic Tooltip Buttons.au3 - by taurus905 - July 1st, 2006
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Dim $button[5], $button_x[5], $button_y[5], $button_w[5], $button_h[5], $focus_num

$gui = GUICreate("Dynamic Tooltip Buttons", 300, 150, -1, -1)
$button[1] = GUICtrlCreateButton("One", 60, 25, 50, 25)
$button[2] = GUICtrlCreateButton("Two", 180, 30, 60, 30)
$button[3] = GUICtrlCreateButton("Three", 70, 80, 70, 35)
$button[4] = GUICtrlCreateButton("Four", 190, 85, 80, 40)

GUISetOnEvent($GUI_EVENT_CLOSE, "_sys_event_handler", $gui)
GUIRegisterMsg(13, "_update_tooltip")
GUISetState(@SW_SHOW, $gui)

While 1
    Sleep(350)
    $gui_state = WinGetState("Dynamic Tooltip Buttons")
WEnd
Exit

Func _sys_event_handler()
    If $GUI_EVENT_CLOSE Then Exit
EndFunc

Func _update_tooltip()
    $focus_str = ControlGetFocus("Dynamic Tooltip Buttons")
    If $focus_str = "" Then $focus_str = "Button1"
    $focus_split = StringSplit($focus_str, "Button", 1)
    $focus_num = $focus_split[2]
    $coor = ControlGetPos("Dynamic Tooltip Buttons", "", $button[$focus_num])
    $button_x[$focus_num] = $coor[0]
    $button_y[$focus_num] = $coor[1]
    $button_w[$focus_num] = $coor[2]
    $button_h[$focus_num] = $coor[3]
    ToolTip("Button " & $focus_num & ": X=" & $button_x[$focus_num] & "  Y=" & $button_y[$focus_num] & "  W=" & $button_w[$focus_num] & "  H=" & $button_h[$focus_num])
EndFunc

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted (edited)

give this a try:

; Dynamic Tooltip Buttons.au3 - by taurus905 - July 1st, 2006
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global Const $WM_NOTIFY = 0x004E
Global Const $BN_SETFOCUS = 6
Global Const $WM_COMMAND = 0x111

Dim $button[5], $button_x[5], $button_y[5], $button_w[5], $button_h[5], $focus_num

$gui = GUICreate("Dynamic Tooltip Buttons", 300, 150, -1, -1)
$button[1] = GUICtrlCreateButton("One", 60, 25, 50, 25)
$button[2] = GUICtrlCreateButton("Two", 180, 30, 60, 30)
$button[3] = GUICtrlCreateButton("Three", 70, 80, 70, 35)
$button[4] = GUICtrlCreateButton("Four", 190, 85, 80, 40)

GUISetOnEvent($GUI_EVENT_CLOSE, "_sys_event_handler", $gui)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $gui)

While 1
    Sleep(10)
WEnd
Exit

Func _sys_event_handler()
    If $GUI_EVENT_CLOSE Then Exit
EndFunc   ;==>_sys_event_handler

Func WM_COMMAND($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $lParam
    Local $hwndFrom, $code
    $hwndFrom = _LoWord($wParam)
    $code = _HiWord($wParam)
    For $focus_num = 1 To 4
        Switch $hwndFrom
            Case $button[$focus_num]
                Switch $code
                    Case $BN_SETFOCUS
                        $coor = ControlGetPos("Dynamic Tooltip Buttons", "", $button[$focus_num])
                        $button_x[$focus_num] = $coor[0]
                        $button_y[$focus_num] = $coor[1]
                        $button_w[$focus_num] = $coor[2]
                        $button_h[$focus_num] = $coor[3]
                        ToolTip("Button " & $focus_num & ": X=" & $button_x[$focus_num] & "  Y=" & $button_y[$focus_num] & "  W=" & $button_w[$focus_num] & "  H=" & $button_h[$focus_num])
                EndSwitch
        EndSwitch
    Next
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Posted

give this a try:

Gary,

This looks very interesting. I like the fact that it uses even less cpu. I would like to learn more about what its doing so I could read and write programs that use this method. I will look more closely at it later today. Do you have any links?

I am currently using WinGetState() in my other program to let me know when my gui:

1 = Window exists

2 = Window is visible

4 = Windows is enabled

8 = Window is active

I don't like that it has to be in a message loop.

Is there a way to monitor these events without looping?

I only need to know when WinGetState = 15.

Thanks,

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Posted

Gary,

This looks very interesting. I like the fact that it uses even less cpu. I would like to learn more about what its doing so I could read and write programs that use this method. I will look more closely at it later today. Do you have any links?

I am currently using WinGetState() in my other program to let me know when my gui:

1 = Window exists

2 = Window is visible

4 = Windows is enabled

8 = Window is active

I don't like that it has to be in a message loop.

Is there a way to monitor these events without looping?

I only need to know when WinGetState = 15.

Thanks,

taurus905

I would probably start here

Here's a little bit more with the use of buttons:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global Const $WM_COMMAND = 0x111
Global Const $BN_CLICKED = 0;
Global Const $BN_DISABLE = 4;
Global Const $BN_DOUBLECLICKED = 5;
Global Const $BN_SETFOCUS = 6
Global Const $BN_KILLFOCUS = 7;

Dim $button[5], $button_x[5], $button_y[5], $button_w[5], $button_h[5], $focus_num

$gui = GUICreate("Dynamic Tooltip Buttons", 300, 150, -1, -1)
$button[1] = GUICtrlCreateButton("One", 60, 25, 50, 25)
$button[2] = GUICtrlCreateButton("Two", 180, 30, 60, 30)
$button[3] = GUICtrlCreateButton("Three", 70, 80, 70, 35)
$button[4] = GUICtrlCreateButton("Four", 190, 85, 80, 40)

GUISetOnEvent($GUI_EVENT_CLOSE, "_sys_event_handler", $gui)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $gui)

While 1
    Sleep(10)
WEnd
Exit

Func _sys_event_handler()
    If $GUI_EVENT_CLOSE Then Exit
EndFunc   ;==>_sys_event_handler

Func WM_COMMAND($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $lParam
    Local $hwndFrom, $code
    $hwndFrom = _LoWord($wParam)
    $code = _HiWord($wParam)
    For $focus_num = 1 To 4
        Switch $hwndFrom
            Case $button[$focus_num]
                Switch $code
                    Case $BN_CLICKED
                        ConsoleWrite(_DebugHeader("Button CLICKED: "  & $button[$focus_num]))
                    Case $BN_DISABLE
                        ConsoleWrite(_DebugHeader("Button DISABLE: "  & $button[$focus_num]))
                    Case $BN_DOUBLECLICKED
                        ConsoleWrite(_DebugHeader("Button DOUBLECLICKED: "  & $button[$focus_num]))
                    Case $BN_KILLFOCUS
                        ConsoleWrite(_DebugHeader("Button KILLFOCUS: "  & $button[$focus_num]))
                    Case $BN_SETFOCUS
                        $coor = ControlGetPos("Dynamic Tooltip Buttons", "", $button[$focus_num])
                        $button_x[$focus_num] = $coor[0]
                        $button_y[$focus_num] = $coor[1]
                        $button_w[$focus_num] = $coor[2]
                        $button_h[$focus_num] = $coor[3]
                        ToolTip("Button " & $focus_num & ": X=" & $button_x[$focus_num] & "  Y=" & $button_y[$focus_num] & "  W=" & $button_w[$focus_num] & "  H=" & $button_h[$focus_num])
                EndSwitch
        EndSwitch
    Next
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc   ;==>_DebugHeader

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...