Aciano Posted July 21, 2006 Posted July 21, 2006 Hi. Can anyone clue me in on how to show ToolTip on a dropdown menu item and how to change Statusbar text when mouse cursor is over a dropdown menu item? It would be highly appreciated and probably helpful for others, I did some searching, but couldn't find it here. Txs
Moderators SmOke_N Posted July 21, 2006 Moderators Posted July 21, 2006 Hi. Can anyone clue me in on how to show ToolTip on a dropdown menu item and how to change Statusbar text when mouse cursor is over a dropdown menu item? It would be highly appreciated and probably helpful for others, I did some searching, but couldn't find it here. TxsHave any code for us to work with or do we make our own 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.
Aciano Posted July 21, 2006 Author Posted July 21, 2006 #include <guiconstants.au3> $Winhl = GUICreate('TITLE', 400, 285) Global $defaultstatus = "Ready" Global $status $filemenu = GUICtrlCreateMenu("&File") $file1 = GUICtrlCreateMenuitem("Label 1", $filemenu) $file2 = GUICtrlCreateMenuitem("Label 2", $filemenu) $file8 = GUICtrlCreateMenuitem("Label 3", $filemenu) $file9 = GUICtrlCreateMenuitem("Label 4", $filemenu) $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 250, 400, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit Here is something you can start with. If possible try to make it both in one GUI. Txs for such fast response.
Moderators SmOke_N Posted July 21, 2006 Moderators Posted July 21, 2006 Wow, this is a job for someone that knows GUIRegisterMsg() pretty well, I can't get the handle of the sub menus so there's not much I can do, If I could have, I would have been able to fix the statusbar thing too.... I'm looking over Holgers stuff now on icon placement seeing if there's anything I can steal from there , but I'm afraid the hours have surpassed my brain at the moment, so I don't think I'm going to be much help 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.
Aciano Posted July 21, 2006 Author Posted July 21, 2006 Smoke - at least you tried... so that is what I thought. If it was not hard I would more likely figure it out myself. I even thought about Mouse functions, but I didnt came up with anything.
Moderators SmOke_N Posted July 21, 2006 Moderators Posted July 21, 2006 (edited) Smoke - at least you tried... so that is what I thought. If it was not hard I would more likely figure it out myself. I even thought about Mouse functions, but I didnt came up with anything.Wouldn't really work without pixel functions that way, but that's not how it should be done, I know if you can make a sub menu have a sub menu, then you can obviously get the handle of the damn thing... I'm just too tired to figure out how... I thought I had it 5 minutes ago... but then I woke up Edit:And GUIGetMsg() pics it up... so... let me try another thing.Edit2:Nope... Sorry man! Hope you get it... I'd like to know now as well. Edited July 21, 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.
eltorro Posted July 21, 2006 Posted July 21, 2006 You can try the following code. I assume your running beta. expandcollapse popup;Menu Help ;Stephen Podhajecki [eltorro] gehossafats@netmdc.com #Include <GuiConstants.au3> #include <Array.au3> Global $USE_TOOLTIP = TRUE Global $DEBUG = True Local $aCtrlArray[1], $aCtrlMsgArray[1],$ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2] Global $defaultstatus = "Ready" Global $status Global $Timer Global Const $WM_MENUSELECT = 0x011F GUIRegisterMsg($WM_MENUSELECT,"MouseOverMenu") $Form1 = GUICreate('TITLE', 400, 285) $filemenu = GUICtrlCreateMenu("&File") _AddCtrl($filemenu,"FileMenu") $file1 = GUICtrlCreateMenuitem("Label 1", $filemenu) _AddCtrl($file1,"This is Label1") $file2 = GUICtrlCreateMenuitem("Label 2", $filemenu) _AddCtrl($file2,"Label 2 at Your Service") $file3 = GUICtrlCreateMenuitem("Label3", $filemenu) _AddCtrl($file3,"Pleased to meet you from Label 3") $file4 = GUICtrlCreateMenuitem("Label 4", $filemenu) _AddCtrl($file4,"Well, you get the picture, Label 4") $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 250, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) $statuslabel2 =GUICtrlCreateLabel($defaultstatus, 300, 250, 100, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) $file11= GUICtrlCreateMenuitem("Label 11",$file1) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $file1 MsgBox(266288,"Menu Clicked","Label1 clicked.") EndSelect ;~ $t_Sec = int( TimerDiff($Timer)/1000) ;~ ;if $t_Sec = int($t_Sec) then ;~ GuiCtrlSetData($statuslabel2,$t_Sec) ;~ ;EndIf ;~ ;~ if TimerDiff($Timer) >3000 Then ToolTip("") WEnd Exit Func MouseOverMenu($hWndGUI, $MsgID, $WParam, $LParam) if $DEBUG then ConsoleWrite( "hWndGui= "&$hWndGUI& @LF &"MsgId= "&$MsgID& @LF &"WParam= " &$WParam& @LF &"$LParam= "&$LParam& @LF) Local $id = BitAnd($WParam, 0xFFFF) if $DEBUG then ConsoleWrite("ID= "& $id & @LF) for $x= 0 to UBound($aCtrlArray)-1 if $id = ($aCtrlArray[$x]) then GuiCtrlSetData($statuslabel , $aCtrlMsgArray[$x]) if $USE_TOOLTIP then ToolTip($aCtrlMsgArray[$x]) ;~ $Timer = TimerInit() ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func _AddCtrl($ControlID,$ControlMsg) _ArrayAdd($aCtrlArray,$ControlID) _ArrayAdd($aCtrlMsgArray,$ControlMsg) EndFunc Regards strongy 1 Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code
Moderators SmOke_N Posted July 21, 2006 Moderators Posted July 21, 2006 You can try the following code. I assume your running beta. expandcollapse popup;Menu Help ;Stephen Podhajecki [eltorro] gehossafats@netmdc.com #Include <GuiConstants.au3> #include <Array.au3> Global $USE_TOOLTIP = TRUE Global $DEBUG = True Local $aCtrlArray[1], $aCtrlMsgArray[1],$ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2] Global $defaultstatus = "Ready" Global $status Global $Timer Global Const $WM_MENUSELECT = 0x011F GUIRegisterMsg($WM_MENUSELECT,"MouseOverMenu") $Form1 = GUICreate('TITLE', 400, 285) $filemenu = GUICtrlCreateMenu("&File") _AddCtrl($filemenu,"FileMenu") $file1 = GUICtrlCreateMenuitem("Label 1", $filemenu) _AddCtrl($file1,"This is Label1") $file2 = GUICtrlCreateMenuitem("Label 2", $filemenu) _AddCtrl($file2,"Label 2 at Your Service") $file3 = GUICtrlCreateMenuitem("Label3", $filemenu) _AddCtrl($file3,"Pleased to meet you from Label 3") $file4 = GUICtrlCreateMenuitem("Label 4", $filemenu) _AddCtrl($file4,"Well, you get the picture, Label 4") $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 250, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) $statuslabel2 =GUICtrlCreateLabel($defaultstatus, 300, 250, 100, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) $file11= GUICtrlCreateMenuitem("Label 11",$file1) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $file1 MsgBox(266288,"Menu Clicked","Label1 clicked.") EndSelect ;~ $t_Sec = int( TimerDiff($Timer)/1000) ;~ ;if $t_Sec = int($t_Sec) then ;~ GuiCtrlSetData($statuslabel2,$t_Sec) ;~ ;EndIf ;~ ;~ if TimerDiff($Timer) >3000 Then ToolTip("") WEnd Exit Func MouseOverMenu($hWndGUI, $MsgID, $WParam, $LParam) if $DEBUG then ConsoleWrite( "hWndGui= "&$hWndGUI& @LF &"MsgId= "&$MsgID& @LF &"WParam= " &$WParam& @LF &"$LParam= "&$LParam& @LF) Local $id = BitAnd($WParam, 0xFFFF) if $DEBUG then ConsoleWrite("ID= "& $id & @LF) for $x= 0 to UBound($aCtrlArray)-1 if $id = ($aCtrlArray[$x]) then GuiCtrlSetData($statuslabel , $aCtrlMsgArray[$x]) if $USE_TOOLTIP then ToolTip($aCtrlMsgArray[$x]) ;~ $Timer = TimerInit() ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func _AddCtrl($ControlID,$ControlMsg) _ArrayAdd($aCtrlArray,$ControlID) _ArrayAdd($aCtrlMsgArray,$ControlMsg) EndFunc RegardsThat's super nice eltorro!!... got one for buttons? 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.
GaryFrost Posted July 21, 2006 Posted July 21, 2006 (edited) That's super nice eltorro!!... got one for buttons? I already did one for buttons Edit: have a look expandcollapse popup#include <GUIConstants.au3> Opt("MustDeclareVars", 1) Global Const $DebugIt = 1 Global Const $WM_NOTIFY = 0x004E Global Const $BCN_HOTITEMCHANGE = -1249 Global $Hovered = 0 Global $Button[13][2], $status _Main() Func _Main() Local $x = 48, $y = 88, $msg, $Form2 Local $SetStatus[13] = [12, "Open Notepad, for text editing.", "Open MSPaint, for basic photo editing.", "Open Regedit, for regestry editing.", _ "Open The Gimp, for Photo manipulation, and editing.", "Open My Computer, for no particular reason.", "Nothing yet", "Nothing yet", "Nothing yet", _ "Nothing yet", "Nothing yet", "Nothing yet", "Nothing yet"] Local $Btn_Text[13] = [12, "Notepad", "MSpaint", "Regedit", "The Gimp", "My Computer", _ "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1"] $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP)) $status = GUICtrlCreateLabel("Welcome to Blash", 24, 528, 651, 17) $Button[0][0] = 12 For $i = 1 To 6 $Button[$i][0] = GUICtrlCreateButton($Btn_Text[$i], $x, $y, 89, 41) $Button[$i][1] = $SetStatus[$i] $Button[$i + 6][0] = GUICtrlCreateButton($Btn_Text[$i + 6], $x, $y + 64, 89, 41) $Button[$i + 6][1] = $SetStatus[$i + 6] $x += 104 Next ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else For $x = 1 To $Button[0][0] If $msg = $Button[$x][0] Then ; do something, could be another array ExitLoop EndIf Next EndSelect WEnd EndFunc ;==>_Main ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local Const $HICF_ENTERING = 0x10 Local Const $HICF_LEAVING = 0x20 Local $tagNMBCHOTITEM, $event, $hwndFrom, $code, $dwFlags, $i $tagNMBCHOTITEM = DllStructCreate("int;int;int;dword", $lParam) $hwndFrom = DllStructGetData($tagNMBCHOTITEM, 1) $code = DllStructGetData($tagNMBCHOTITEM, 3) $dwFlags = DllStructGetData($tagNMBCHOTITEM, 4) Select Case $code = $BCN_HOTITEMCHANGE ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("$BCN_HOTITEMCHANGE") ;---------------------------------------------------------------------------------------------- If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("Leaving" & @LF & "Button Area") ;---------------------------------------------------------------------------------------------- GUICtrlSetData($status, "Welcome to Blash") ElseIf BitAND($dwFlags, $HICF_ENTERING) = $HICF_ENTERING Then ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("Entering" & @LF & "Button Area") ;---------------------------------------------------------------------------------------------- For $i = 1 To $Button[0][0] If $hwndFrom = ControlGetHandle($hWndGUI, "", $Button[$i][0]) Then GUICtrlSetData($status, $Button[$i][1]) ExitLoop EndIf Next EndIf EndSelect $tagNMBCHOTITEM = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite( _ "!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint Edited July 21, 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.
WTS Posted July 21, 2006 Posted July 21, 2006 good going man!see also marfdamans' mousehover udf: http://www.autoitscript.com/forum/index.php?showtopic=28714
Moderators SmOke_N Posted July 21, 2006 Moderators Posted July 21, 2006 (edited) good going man!see also marfdamans' mousehover udf: http://www.autoitscript.com/forum/index.php?showtopic=28714That's what I was trying to avoid, he's using AdlibEnable , didn't want to do that. Thanks Gary!Edit:Dammit Gary, I worked on this one too with a different approach I remember, I couldn't remember where it was though!! Edited July 21, 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.
GaryFrost Posted July 22, 2006 Posted July 22, 2006 (edited) That's what I was trying to avoid, he's using AdlibEnable , didn't want to do that. Thanks Gary! Edit: Dammit Gary, I worked on this one too with a different approach I remember, I couldn't remember where it was though!! @Aciano, sorry don't mean to hi-jack your thread, was just answering a question. @SmOke_N NP, here's a little more meat for you to chew on expandcollapse popup#include <GUIConstants.au3> Opt("MustDeclareVars", 1) Global Const $DebugIt = 1 Global Const $WM_NOTIFY = 0x004E Global Const $WM_COMMAND = 0x0111 Global $Hovered = 0 Global $Button[13][2], $status _Main() Func _Main() Local $x = 48, $y = 88, $msg, $Form2 Local $SetStatus[13] = [12, "Open Notepad, for text editing.", "Open MSPaint, for basic photo editing.", "Open Regedit, for regestry editing.", _ "Open The Gimp, for Photo manipulation, and editing.", "Open My Computer, for no particular reason.", "Nothing yet", "Nothing yet", "Nothing yet", _ "Nothing yet", "Nothing yet", "Nothing yet", "Nothing yet"] Local $Btn_Text[13] = [12, "Notepad", "MSpaint", "Regedit", "The Gimp", "My Computer", _ "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1"] $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP)) $status = GUICtrlCreateLabel("Welcome to Blash", 24, 528, 651, 17) $Button[0][0] = 12 For $i = 1 To 6 $Button[$i][0] = GUICtrlCreateButton($Btn_Text[$i], $x, $y, 89, 41) $Button[$i][1] = $SetStatus[$i] $Button[$i + 6][0] = GUICtrlCreateButton($Btn_Text[$i + 6], $x, $y + 64, 89, 41) $Button[$i + 6][1] = $SetStatus[$i + 6] $x += 104 Next ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc ;==>_Main Func Button_Click(ByRef $ctrl_id) For $i = 1 To $Button[0][0] If $ctrl_id = $Button[$i][0] Then _DebugPrint("Button: " & $Button[$i][0]) ExitLoop EndIf Next EndFunc ;==>Button_Click Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local Const $BCN_HOTITEMCHANGE = -1249 Local Const $HICF_ENTERING = 0x10 Local Const $HICF_LEAVING = 0x20 Local $tagNMBCHOTITEM, $event, $hwndFrom, $code, $dwFlags, $i $tagNMBCHOTITEM = DllStructCreate("int;int;int;dword", $lParam) $hwndFrom = DllStructGetData($tagNMBCHOTITEM, 1) $code = DllStructGetData($tagNMBCHOTITEM, 3) $dwFlags = DllStructGetData($tagNMBCHOTITEM, 4) Select Case $code = $BCN_HOTITEMCHANGE ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("$BCN_HOTITEMCHANGE") ;---------------------------------------------------------------------------------------------- If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("Leaving" & @LF & "Button Area") ;---------------------------------------------------------------------------------------------- GUICtrlSetData($status, "Welcome to Blash") ElseIf BitAND($dwFlags, $HICF_ENTERING) = $HICF_ENTERING Then ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("Entering" & @LF & "Button Area") ;---------------------------------------------------------------------------------------------- For $i = 1 To $Button[0][0] If $hwndFrom = ControlGetHandle($hWndGUI, "", $Button[$i][0]) Then GUICtrlSetData($status, $Button[$i][1]) ExitLoop EndIf Next EndIf EndSelect $tagNMBCHOTITEM = 0 $event = 0 $lParam = 0 ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>WM_Notify_Events Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local Const $BN_CLICKED = 0; Local Const $BN_PAINT = 1; Local Const $BN_HILITE = 2; Local Const $BN_PUSHED = $BN_HILITE; Local Const $BN_UNHILITE = 3; Local Const $BN_UNPUSHED = $BN_UNHILITE; Local Const $BN_DISABLE = 4; Local Const $BN_DOUBLECLICKED = 5; Local Const $BN_DBLCLK = $BN_DOUBLECLICKED; Local Const $BN_SETFOCUS = 6; Local Const $BN_KILLFOCUS = 7; Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) Local $hCtrl = $lParam If $nID <> 2 Then Switch $nNotifyCode Case $BN_CLICKED _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hwnd & @LF & _ "MsgID" & @TAB & ":" & $Msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) Button_Click ($nID) Case $BN_PAINT _DebugPrint("$BN_PAINT") Case $BN_PUSHED, $BN_HILITE _DebugPrint("$BN_PUSHED, $BN_HILITE") Case $BN_UNPUSHED, $BN_UNHILITE _DebugPrint("$BN_UNPUSHED") Case $BN_DISABLE _DebugPrint("$BN_DISABLE") Case $BN_DBLCLK, $BN_DOUBLECLICKED _DebugPrint("$BN_DBLCLK, $BN_DOUBLECLICKED") Case $BN_SETFOCUS _DebugPrint("$BN_SETFOCUS") Case $BN_KILLFOCUS _DebugPrint("$BN_KILLFOCUS") EndSwitch EndIf ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite( _ "!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint Edited July 22, 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.
Aciano Posted July 24, 2006 Author Posted July 24, 2006 First of all - big thanks to Smoke! I believe that not only me will use this as a guide, when needed.
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