azure Posted December 17, 2008 Share Posted December 17, 2008 (edited) Here's what I'm trying to do. I posted as a reply to an OLDER post... I'm part of the way to where I want to be. RIGHT CLICK TASKBAR (the part of XP that's between the start menu and the system tray) CHOOSE TOOLBAR (Accellerator = T, typically first index in the right click menu) UNCHECK "Windows Desktop Search" (you can apply this to any of the options in there. checking or unchecking). I've spent most of the day today searching the forums and no one seems to have a solution to this that I can actually understand. I've seen many many posts on creating your own context menu, but that's not what I want. This is a pre-existing menu. Here's the code I have so far: #include <GuiToolbar.au3> Opt("WinTitleMatchMode", 4) $hWnd = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ToolbarWindow322") $aRect = _GUICtrlToolbar_GetButtonRect($hWnd, _GUICtrlToolbar_IndexToCommand($hWnd, _GUICtrlToolbar_ButtonCount($hWnd)-1)) $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", $aRect[0]) DllStructSetData($tpoint, "Y", $aRect[3]) $pPoint = DllStructGetPtr($tPoint) DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", $pPoint) MouseClick("right", DllStructGetData($tPoint, "X"), DllStructGetData($tPoint, "Y"), 1, 1) This right clicks the taskbar for me. Now I need to TRAVERSE the menu that's brought up, choose TOOLBAR, then UNCHECK WINDOWS DESKTOP SEARCH. Edited December 23, 2008 by azure Link to comment Share on other sites More sharing options...
FireFox Posted December 17, 2008 Share Posted December 17, 2008 Hi, For traverse menu simply use send function,hope this could help you Send("{UP}");go at top of first item Send("{RIGHT}");go to menu ;etc.. Link to comment Share on other sites More sharing options...
azure Posted December 18, 2008 Author Share Posted December 18, 2008 Hi, For traverse menu simply use send function,hope this could help you Send("{UP}");go at top of first item Send("{RIGHT}");go to menu ;etc.. Thank you.. but the SEND command is sort of unreliable. For instance, what if they have more options in their context menu? or more toolbars to choose from? then i'm just picking the wrong one. i need to attack this programatically rather than using brute force key sends. Link to comment Share on other sites More sharing options...
azure Posted December 18, 2008 Author Share Posted December 18, 2008 Any ideas? How do I Find text within a context menu and click it? Link to comment Share on other sites More sharing options...
FireFox Posted December 18, 2008 Share Posted December 18, 2008 Any ideas? How do I Find text within a context menu and click it?The traymenu you want to traverse is an autoit script ? Link to comment Share on other sites More sharing options...
azure Posted December 19, 2008 Author Share Posted December 19, 2008 The traymenu you want to traverse is an autoit script ?No. I typed out what I'm looking for. right click your taskbar at the bottom of your screen, go to toolbars, then go to the submenu.. that's what i want.. but to do it automatically without using sendkeys. There has to be a way to "findtext" in that menu, click the container of said text, etc. Link to comment Share on other sites More sharing options...
azure Posted December 22, 2008 Author Share Posted December 22, 2008 Bump. Anyone? Link to comment Share on other sites More sharing options...
TurionAltec Posted December 22, 2008 Share Posted December 22, 2008 (edited) Try enabling / disabling the toolbar, see what in the registry changes, using a tool like RegShotYou could then code in the proper registry changes into your script.The next step would be getting Explorer to recognize the toolbar changes without a restart. I don't know how to do this in AutoIT, surely it can be done with a DLL call or something, but using the tool NircmdYou can try the commands:nircmd sysrefresh nircmd shellrefresh Edited December 22, 2008 by TurionAltec Link to comment Share on other sites More sharing options...
azure Posted December 22, 2008 Author Share Posted December 22, 2008 Try enabling / disabling the toolbar, see what in the registry changes, using a tool like RegShot You could then code in the proper registry changes into your script. The next step would be getting Explorer to recognize the toolbar changes without a restart. I don't know how to do this in AutoIT, surely it can be done with a DLL call or something, but using the tool Nircmd You can try the commands: nircmd sysrefresh nircmd shellrefresh Thank you, but I've tried that already. The changes made are to a dword value that determines what toolbars are in effect. This dword, however, isn't documented. No one's able to determine what part of it makes what work. I've googled the heck out of it, which is why I fell back to an autoit solution. Thanks for the link to nircmd.. That'll be useful for future scripts! Any other ideas? Link to comment Share on other sites More sharing options...
azure Posted December 23, 2008 Author Share Posted December 23, 2008 For anyone else interested, here's how the final script coded. I used someone elses system tray popup script and fiddled around with it until I got it to do what I want. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiToolbar.au3> #include <GuiMenu.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #Include <Misc.au3> ;_Singleton("TrayMenuTest", 0) Opt("MustDeclareVars", 1) Global $gaPopups[1][3] = [[0, 0]] Global $hMenu, $hParent Func OpenMenu() Local $hWnd, $aRect, $tPoint, $pPoint $hWnd = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ToolbarWindow322") $aRect = _GUICtrlToolbar_GetButtonRect($hWnd, _GUICtrlToolbar_IndexToCommand($hWnd, _GUICtrlToolbar_ButtonCount($hWnd)-1)) $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", $aRect[0]) DllStructSetData($tpoint, "Y", $aRect[3]) $pPoint = DllStructGetPtr($tPoint) DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", $pPoint) MouseClick("right", DllStructGetData($tPoint, "X"), DllStructGetData($tPoint, "Y"), 1, 1) EndFunc OpenMenu() Sleep(100) _Lib_PopupScan() If $gaPopups[0][0] > 0 Then Decode() EndIf SLEEP(100) _Lib_PopupScan() If $gaPopups[0][0] > 0 Then Decode() EndIf Func _Exit() Exit EndFunc ;==>_Exit Func Decode() Local $iI, $iType Local $ahwnd[2] For $iI = 1 To $gaPopups[0][0] $ahwnd[0] = _Lib_PopupGetHwnd($iI) ; menu hwnd $iType = _Lib_PopupGetType($iI) ; menu/toolbar/tooltip $ahwnd[1] = _Lib_PopupGetParent($iI) ; parent hwnd If $hMenu <> $ahwnd[0] Or $hParent <> $ahwnd[1] Then $hMenu = $ahwnd[0] $hParent = $ahwnd[1] If _GUICtrlMenu_IsMenu($hMenu) And IsHWnd($hParent) Then Select Case $iType = 1 ModShowMenu($hMenu, $hParent) EndSelect EndIf EndIf Next Return $ahwnd EndFunc ;==>Decode Func ClickMe($hParent, $hMenu, $iI) Local $aRect, $tPoint, $pPoint $aRect = _GUICtrlMenu_GetItemRect($hParent, $hMenu, $iI) $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", $aRect[0]) DllStructSetData($tpoint, "Y", $aRect[3]) $pPoint = DllStructGetPtr($tPoint) ;DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", $pPoint) ;MouseMove(DllStructGetData($tPoint, "X")+20, DllStructGetData($tPoint, "Y")-14) MouseClick("left", DllStructGetData($tPoint, "X")+20, DllStructGetData($tPoint, "Y")-14, 1, 1) EndFunc Func ModShowMenu($hMenu, $hParent) Local $iCount $iCount = _GUICtrlMenu_GetItemCount($hMenu) ;ConsoleWrite("+Parent handle .........: " & $hParent & @CRLF) ;ConsoleWrite("+Menu handle ...........: " & $hMenu & @CRLF) ;ConsoleWrite("+Menu item count .......: " & $iCount & @CRLF) If _GUICtrlMenu_FindItem($hMenu, "Tile Windows Horizontally", True) > 0 Then ClickMe($hParent, $hMenu, _GUICtrlMenu_FindItem($hMenu, "Toolbar",True)) If _GUICtrlMenu_FindItem($hMenu, "Quick Launch", True) > 0 Then ClickMe($hParent, $hMenu, _GUICtrlMenu_FindItem($hMenu, "Windows Search", True)) EndFunc Func _Lib_PopupGetParent($iIndex = 1) _Lib_PopupWait() Return $gaPopups[$iIndex][2] EndFunc ;==>_Lib_PopupGetParent Func _Lib_PopupGetType($iIndex = 1) _Lib_PopupWait() Return $gaPopups[$iIndex][1] EndFunc ;==>_Lib_PopupGetType Func _Lib_PopupGetHwnd($iIndex = 1) _Lib_PopupWait() Return $gaPopups[$iIndex][0] EndFunc ;==>_Lib_PopupGetHwnd Func _Lib_PopupScan() Local $iI, $sClass, $hWnd, $hMenu ReDim $gaPopups[1][3] $gaPopups[0][0] = 0 ReDim $winapi_gaWinList[64][2] $winapi_gaWinList[0][0] = 0 $winapi_gaWinList[0][1] = 64 _WinAPI_EnumWindowsPopup() For $iI = 1 To $winapi_gaWinList[0][0] $hWnd = $winapi_gaWinList[$iI][0] $sClass = $winapi_gaWinList[$iI][1] Select Case $sClass = "#32768" $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0) _Lib_PopupAdd($hMenu, 1, $hWnd) Case $sClass = "ToolbarWindow32" _Lib_PopupAdd($hWnd, 2, _WinAPI_GetParent($hWnd)) Case $sClass = "ToolTips_Class32" _Lib_PopupAdd($hWnd, 3, _WinAPI_GetParent($hWnd)) EndSelect Next EndFunc ;==>_Lib_PopupScan Func _Lib_PopupWait() Local $iLoop = 0 While $iLoop < 50 If $gaPopups[0][0] > 0 Then Return Sleep(100) _Lib_PopupScan() $iLoop += 1 WEnd ConsoleWrite("Timeout waiting for popup window to appear" & @CRLF) EndFunc ;==>_Lib_PopupWait Func _Lib_PopupAdd($hWnd, $iType, $hParent) Local $iCount $gaPopups[0][0] += 1 $iCount = $gaPopups[0][0] ReDim $gaPopups[$iCount + 1][3] $gaPopups[$iCount][0] = $hWnd $gaPopups[$iCount][1] = $iType $gaPopups[$iCount][2] = $hParent EndFunc ;==>_Lib_PopupAdd Link to comment Share on other sites More sharing options...
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