Moderators SmOke_N Posted July 1, 2006 Moderators Posted July 1, 2006 (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.taurus905Well, 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 July 1, 2006 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.
taurus905 Posted July 1, 2006 Author Posted July 1, 2006 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. 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
taurus905 Posted July 1, 2006 Author Posted July 1, 2006 (edited) I found it! GUIRegisterMsg(13, "_Display_Key_Coords") Thanks Emperor. Gary and SmOke_N for putting me on the right track. I'm happy again. taurus905 Edited July 1, 2006 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
GaryFrost Posted July 1, 2006 Posted July 1, 2006 I found it! GUIRegisterMsg(13, "_Display_Key_Coords")Thanks Emperor. Gary and SmOke_N for putting me on the right track.I'm happy again.taurus905How about a link to where you got the value 13 for this? SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
taurus905 Posted July 1, 2006 Author Posted July 1, 2006 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. 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
GaryFrost Posted July 1, 2006 Posted July 1, 2006 hmmm would like to see how that's working, looks like 13 is WM_QUERYOPEN SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
taurus905 Posted July 1, 2006 Author Posted July 1, 2006 hmmm would like to see how that's working, looks like 13 is WM_QUERYOPENGary,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
taurus905 Posted July 2, 2006 Author Posted July 2, 2006 hmmm would like to see how that's working, looks like 13 is WM_QUERYOPENGary, 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 expandcollapse popup; 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
GaryFrost Posted July 2, 2006 Posted July 2, 2006 (edited) give this a try: expandcollapse popup; 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 July 2, 2006 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.
taurus905 Posted July 2, 2006 Author Posted July 2, 2006 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
GaryFrost Posted July 2, 2006 Posted July 2, 2006 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: expandcollapse popup#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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now