Jump to content

traversing through Menu items without hotkey and co-ordinate


 Share

Recommended Posts

Hi Friends,

I was trying to traverse through Menu items of an application without using hotkey or co-ordinate information.This feature is present in AutoHotkey.But unfortunately this doesn't work for applications like Adobe Illustrator as it doesn't use standard Windows APIs.

(I had posted in its forum to get this reply -- http://www.autohotkey.com/forum/post-287905.html#287905).

Please let me know if there is any solution in AutoIT.

Thanks in advance

Ajay

Link to comment
Share on other sites

Hi Friends,

I was trying to traverse through Menu items of an application without using hotkey or co-ordinate information.This feature is present in AutoHotkey.But unfortunately this doesn't work for applications like Adobe Illustrator as it doesn't use standard Windows APIs.

(I had posted in its forum to get this reply -- http://www.autohotkey.com/forum/post-287905.html#287905).

Please let me know if there is any solution in AutoIT.

Thanks in advance

Ajay

Welcome to the forum.

AutoIt also has a function named WinMenuSelectItem, you can give it a try and see how it works for you.

I do not have Adobe Illustrator to test things out on, so I'll have to ask you - if WinMenuSelectItem does not work, why can't you use coordinates for mouse clicks? Can the menus be docked in a variety of places - or customized - or ???

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

  • 9 years later...

I'm seeing issues trying to use AutoIt with an old Gupta application (clearly for my sins).  I have to get to a fourth level menu item.

; Now you should be in the main window
WinWaitActive("[Title:Operations CAPCOM Reports]")
if WinMenuSelectItem("[Title:Operations CAPCOM Reports]","","&File","Re&ports","&Daily","Check Reconciliation &Maintenance") = 1 Then
   MsgBox($MB_OK,"Msgs","It found it")
Else
   MsgBox($MB_OK,"Msgs","Not so much")
Endif

That does not find it... I have also tried various flavors of 

Send("{AltDown}F")
Sleep(500)
Send("p")
Sleep(1000)
Send("D")
Sleep(500)
Send("M")
Sleep(500)
Send("{Altup}")
 

That will get as far as Send D but never seems to actually send it...

Its driving me nuts.  Any other suggestions?

 

Link to comment
Share on other sites

Hmmm... I even pulled down the recorder and tried to capture it that way... Maybe this is a hint but all the record caught was _

WinWaitActivate("Operations CAPCOM Reports","")
Send("{ALTDOWN}f{ALTUP}")
_WinWaitActivate("Check Reconciliation Maintenance","&Cancel")

What I actually typed was Alt Down FpDM Alt Key released...

 

Link to comment
Share on other sites

Here is an example of getting all the menu items to a 4th level (although there are only 3 available) on a notepad.exe window.  If this returns anything in your window, return the output, and we can move it into a function for you:

 

$h = WinGetHandle("[CLASS:Notepad]")
Sleep(1000)
; get first level menu
$m1 = _GUICtrlMenu_GetMenu($h)
ConsoleWrite(IsHWnd($m1) & @CRLF)
; get all the items
$i1count = _GUICtrlMenu_GetItemCount($m1)
For $i1 = 0 To $i1count-1
    ConsoleWrite('[' & _GUICtrlMenu_GetItemText($m1,$i1) & ']' & @CRLF)
    $m2 = _GUICtrlMenu_GetItemSubMenu($m1,$i1)
    $i2count = _GUICtrlMenu_GetItemCount($m2)
    For $i2 = 0 To $i2count-1
        ConsoleWrite(@TAB & '[' & _GUICtrlMenu_GetItemText($m2,$i2) & ']' & @CRLF)
        $m3 = _GUICtrlMenu_GetItemSubMenu($m2,$i2)
        $i3count = _GUICtrlMenu_GetItemCount($m3)
        For $i3 = 0 To $i3count-1
            ConsoleWrite(@TAB & @TAB & '[' & _GUICtrlMenu_GetItemText($m3,$i3) & ']' & @CRLF)
            $m4 = _GUICtrlMenu_GetItemSubMenu($m3,$i3)
            $i4count = _GUICtrlMenu_GetItemCount($m4)
            For $i4 = 0 To $i4count-1
                ConsoleWrite(@TAB & @TAB & @TAB & '[' & _GUICtrlMenu_GetItemText($m4,$i4) & ']' & @CRLF)
            Next
        Next
    Next
Next

output:

[&File]
    [&New    Ctrl+N]
    [&Open...    Ctrl+O]
    [&Save    Ctrl+S]
    [Save &As...]
    []
    [Page Set&up...]
    [&Print...    Ctrl+P]
    []
    [E&xit]
[&Edit]
    [&Undo    Ctrl+Z]
    []
    [Cu&t    Ctrl+X]
    [&Copy    Ctrl+C]
    [&Paste    Ctrl+V]
    [De&lete    Del]
    []
    [&Search with Bing...    Ctrl+E]
    [&Find...    Ctrl+F]
    [Find &Next    F3]
    [&Replace...    Ctrl+H]
    [&Go To...    Ctrl+G]
    []
    [Select &All    Ctrl+A]
    [Time/&Date    F5]
[F&ormat]
    [&Word Wrap]
    [&Font...]
[&View]
    [&Zoom]
        [&Zoom In    Ctrl+Plus]
        [&Zoom Out    Ctrl+Minus]
        [&Restore Default Zoom    Ctrl+0]
    [&Status Bar]
[&Help]
    [View &Help]
    []
    [&About Notepad]

 

Example of using one of the third level items:

WinMenuSelectItem("[CLASS:Notepad]","","&View","&Zoom","&Zoom In    Ctrl+Plus")

 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Dang it...  That was very clever and worked a treat on notepad once I added the include.  Unfortunately for this application, its not finding the menu items at all.  

image.thumb.png.152234980fac5b20c0681d35aeeb028b.png

Any other suggestions?  I noticed with notepad, they actually state they support control rather than alt as a shortcut key and I tried that as well.  No luck...

:(

 

get-fourth-item.au3

Link to comment
Share on other sites

Sometimes new applications use toolbars as 'menus'.  what does the auto it spy tool return for it's class?  you can also use my signature to output all control info on the window

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\CIGScripts\GetAllWindowsControls.au3"    
Func=[GetAllWindowsControls]: ControlCounter=[  1] ControlID=[    0] Handle=[0x002713C6] ClassNN=[            Button1] XPos=[   5] YPos=[  35] Width=[   0] Height=[   0] IsVisible=[0] Text=[DummyButton].
Func=[GetAllWindowsControls]: ControlCounter=[  2] ControlID=[18434] Handle=[0x00231194] ClassNN=[            Button2] XPos=[   7] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  3] ControlID=[18435] Handle=[0x002D08D8] ClassNN=[            Button3] XPos=[  35] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  4] ControlID=[18436] Handle=[0x000905BE] ClassNN=[            Button4] XPos=[  63] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  5] ControlID=[18437] Handle=[0x000C0390] ClassNN=[            Button5] XPos=[  98] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  6] ControlID=[18438] Handle=[0x00191396] ClassNN=[            Button6] XPos=[ 126] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  7] ControlID=[18439] Handle=[0x03EB0E16] ClassNN=[            Button7] XPos=[ 154] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  8] ControlID=[18440] Handle=[0x00F8137E] ClassNN=[            Button8] XPos=[ 190] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[  9] ControlID=[18441] Handle=[0x00470620] ClassNN=[            Button9] XPos=[ 218] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 10] ControlID=[18442] Handle=[0x00791548] ClassNN=[           Button10] XPos=[ 246] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 11] ControlID=[18443] Handle=[0x00231298] ClassNN=[           Button11] XPos=[ 274] YPos=[  36] Width=[  28] Height=[  26] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 12] ControlID=[59440] Handle=[0x001710DA] ClassNN=[ Gupta:FormToolBar1] XPos=[   0] YPos=[  30] Width=[ 770] Height=[  36] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 13] ControlID=[59648] Handle=[0x00211350] ClassNN=[   Gupta:MDIClient1] XPos=[   0] YPos=[  66] Width=[ 770] Height=[ 431] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 14] ControlID=[32753] Handle=[0x002C133A] ClassNN=[   Gupta:StatusBar1] XPos=[   0] YPos=[ 497] Width=[ 770] Height=[  22] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 15] ControlID=[18433] Handle=[0x00120644] ClassNN=[GuptaCC::320000:8:CBCtrlMeter1] XPos=[   0] YPos=[ 497] Width=[   0] Height=[   0] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 16] ControlID=[59397] Handle=[0x00131494] ClassNN=[ProfUIS-ControlBar1] XPos=[   0] YPos=[   0] Width=[ 770] Height=[  30] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 17] ControlID=[59419] Handle=[0x00211390] ClassNN=[   ProfUIS-DockBar1] XPos=[   0] YPos=[   0] Width=[ 770] Height=[  66] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 18] ControlID=[59422] Handle=[0x001205C6] ClassNN=[   ProfUIS-DockBar2] XPos=[   0] YPos=[ 497] Width=[ 770] Height=[   0] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 19] ControlID=[59420] Handle=[0x003C1266] ClassNN=[   ProfUIS-DockBar3] XPos=[   0] YPos=[  66] Width=[   0] Height=[ 431] IsVisible=[1] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[ 20] ControlID=[59421] Handle=[0x004F1424] ClassNN=[   ProfUIS-DockBar4] XPos=[ 770] YPos=[  66] Width=[   0] Height=[ 431] IsVisible=[1] Text=[].
>Exit code: 0    Time: 5.503
 

Does this help at all?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...