CoDeX2k Posted May 15, 2023 Posted May 15, 2023 Hi there, I don't want to be rude. Very long time since I last posted here something... But I am trying pretty basic stuff and failing badly... After for example this very simple example does not work for me at all Notepad() Func Notepad() ;Run Notebpad Local $iPID = Run("notepad") Sleep(1500) WinWaitActive("[CLASS:Notepad]") WinMenuSelectItem("[CLASS:Notepad]", "", "&Hilfe") Sleep(3000) ProcessClose($iPID) EndFunc And yeah my Windows is in German so Hilfe is the correct one. What am I doing wrong? Cheers
ioa747 Posted May 15, 2023 Posted May 15, 2023 (edited) without the 4th parameter it didn't work for me either Notepad() Func Notepad() ;Run Notebpad Local $iPID = Run("notepad") Sleep(1500) WinWaitActive("[CLASS:Notepad]") ;~ WinMenuSelectItem("[CLASS:Notepad]", "", "&Hilfe") WinMenuSelectItem("[CLASS:Notepad]", "", "&Help", "&About Notepad") Sleep(3000) ProcessClose($iPID) EndFunc Edit: if you want only the menu (without sub-menu) you can send alt h Notepad() Func Notepad() ;Run Notebpad Local $iPID = Run("notepad") Sleep(1500) WinWaitActive("[CLASS:Notepad]") ;~ WinMenuSelectItem("[CLASS:Notepad]", "", "&Hilfe") ;~ WinMenuSelectItem("[CLASS:Notepad]", "", "&Help", "&About Notepad") Send("!h") Sleep(3000) ProcessClose($iPID) EndFunc Edited May 15, 2023 by ioa747 I know that I know nothing
ioa747 Posted May 15, 2023 Posted May 15, 2023 and here's a tool I made a while ago for the correct name of the call expandcollapse popup;------------------------------------------------------------------------------ ; Title...........: CaptureMenuInfo.au3 ; Description.....: Capture Menu Information from selected win ;------------------------------------------------------------------------------ #include <MsgBoxConstants.au3> #include <GuiMenu.au3> CaptureMenuInfo() ;----------------------------------------------------------------------------------- Func CaptureMenuInfo() ; item 1197 - Capture Menu Information Local $hWnd, $hMenu, $Txt Local $iMsgBoxAnswer, $Msg $Msg = "First Select (Activate) the window" & @CRLF _ & " you wand the information " & @CRLF _ & "and then click ok" $iMsgBoxAnswer = MsgBox($MB_OKCANCEL + $MB_TOPMOST + $MB_ICONINFORMATION, "Get Menu Information", $Msg) Select Case $iMsgBoxAnswer = 1 ;OK ; ok Case $iMsgBoxAnswer = 2 ;Cancel Return False EndSelect ; Retrieve the class of the active window. $hWnd = WinGetHandle("[ACTIVE]") Local $pClassName = DllStructCreate("char[256]") DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", DllStructGetPtr($pClassName), "int", 255) Local $cText = DllStructGetData($pClassName, 1) $hWnd = WinGetHandle("[CLASS:" & $cText & "]") $hMenu = _GUICtrlMenu_GetMenu($hWnd) Local $sTitle = WinGetTitle($hWnd) Local Const $sFilePath = @DesktopDir & "\Menu-Information.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the txt file.") Return False EndIf FileWriteLine($hFileOpen, "Window title: " & $sTitle) Local $mCount, $m, $hSubMenu ; Display system menu $mCount = _GUICtrlMenu_GetItemCount($hMenu) FileWriteLine($hFileOpen, "Menu handle: 0x" & Hex($hMenu)) FileWriteLine($hFileOpen, "SubMenu count: " & $mCount) FileWriteLine($hFileOpen, " ") For $m = 0 To $mCount - 1 FileWriteLine($hFileOpen, "-----------------------------------------------------------------------") FileWriteLine($hFileOpen, "SubMenu " & $m & ": " & _GUICtrlMenu_GetItemText($hMenu, $m)) FileWriteLine($hFileOpen, "-----------------------------------------------------------------------") $hSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $m) Local $sCount, $s ; Display system menu $sCount = _GUICtrlMenu_GetItemCount($hSubMenu) FileWriteLine($hFileOpen, @TAB & "SubMenu handle: 0x" & Hex($hSubMenu)) FileWriteLine($hFileOpen, @TAB & "Item count: " & $sCount) FileWriteLine($hFileOpen, " ") For $s = 0 To $sCount - 1 FileWriteLine($hFileOpen, @TAB & "Item " & $s & ": " & _GUICtrlMenu_GetItemText($hSubMenu, $s)) Next FileWriteLine($hFileOpen, " ") Next FileClose($hFileOpen) Sleep(50) ShellExecute($sFilePath) EndFunc ;==>CaptureMenuInfo ;-------------------------------------------------------------------------------------------- rsn 1 I know that I know nothing
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