Jump to content
Sign in to follow this  
Exit

[Solved] How to click a menu item?

Recommended Posts

Exit

It is easy to find a submenu item.

But how to select/click it?

Here a reproducer:

#include

_Main()

Func _Main()
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")
$hMain = _GUICtrlMenu_GetMenu($hWnd)
$t1 = _GUICtrlMenu_GetItemText($hMain, 0)
$hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)
$t2 = _GUICtrlMenu_GetItemText($hFile, 3)
Writeln( @LF &"Question: " & @LF& @LF & "How to select submenu entry(""" & $t2 & """) of menu(""" & $t1 & """) ? "& @LF& @LF)

; here should be the code to select the submenu.

EndFunc ;==>_Main

; Write a line of text to Notepad
Func Writeln($sText)
ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CR)
EndFunc ;==>Writeln

I'm sure it is simple, but ..... I give up.

Please give me a hint..

Thanks in advance.

Edited by Exit
  • Like 1

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
bogQ

Run("notepad.exe")

WinWaitActive("[CLASS:Notepad]")

WinMenuSelectItem("[CLASS:Notepad]", "", "&File", "Save &As...")


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
Exit

@bogQ Thanks for the hint. :thumbsup:

Your solution works only in english language. :oops:

My final solution works for any language. :bye:

#include

_Main()

Func _Main()
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")
$hMain = _GUICtrlMenu_GetMenu($hWnd)
$t1 = _GUICtrlMenu_GetItemText($hMain, 0)
$hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)
$t2 = _GUICtrlMenu_GetItemText($hFile, 3)
Writeln(@LF & "Question: " & @LF & @LF & "How to select submenu entry(""" & $t2 & """) of menu(""" & $t1 & """) ? " & @LF & @LF)

; here is the solution. It is language independent.

WinMenuSelectItem($hWnd, "", $t1, $t2)


EndFunc ;==>_Main

; Write a line of text to Notepad
Func Writeln($sText)
ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CR)
EndFunc ;==>Writeln

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×