Mayur Posted February 9, 2010 Share Posted February 9, 2010 Hi All, I am trying to automate Window based application using AutoIt. For Clicking Menu Items right now I am using MouseClick methods but i observed that its behaviour is different on different machines & different OS so for overcoming this problem can any one have solution to click Menu Items without x,y co-ordinates. Thanks, Mayur Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 9, 2010 Moderators Share Posted February 9, 2010 Mayur,Welcome to the AutoIt forum. Two ways I have automated menus:1. If your app has accelerators (the underlined characters in the menus when you press Alt). You can use Send to open the menus initially and then either more accelerator keys to directly access the correct item, or a series of UP/DOWN/LEFT/RIGHT as required to move the cursor as if it were your mouse doing the work.2. Use the _GUICtrlMenu UDF to find out about the menu. This will eventually give you the actual screen positions of the various menu items so you can then hit them with your MouseClick.Personally I would go for the first method if at all possible. I have found it a good idea to add a short Sleep between the Send commands to allow the app menu to adjust - if you go too fast it does not have time to open submenus, etc.I hope this helps. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mayur Posted February 11, 2010 Author Share Posted February 11, 2010 Mayur,Welcome to the AutoIt forum. Two ways I have automated menus:1. If your app has accelerators (the underlined characters in the menus when you press Alt). You can use Send to open the menus initially and then either more accelerator keys to directly access the correct item, or a series of UP/DOWN/LEFT/RIGHT as required to move the cursor as if it were your mouse doing the work.2. Use the _GUICtrlMenu UDF to find out about the menu. This will eventually give you the actual screen positions of the various menu items so you can then hit them with your MouseClick.Personally I would go for the first method if at all possible. I have found it a good idea to add a short Sleep between the Send commands to allow the app menu to adjust - if you go too fast it does not have time to open submenus, etc.I hope this helps. M23Will you please explain first Method I didn't understand.I tried second method but i am not able to get handle of menu because AutoIt Window Info doesnot recognises Menu Items.I used first _GUICtrlNenu_GetMenu method first to get handle of Menu& Then GUICtrlMenu_GetItemText this method returned blank.Let me know Your Suggestions.Thanks,Mayur Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2010 Moderators Share Posted February 11, 2010 Mayur,Many apps have "accelerator" keys to open menus. Open Notepad and press the "Alt" key - on my version I can see small underlines in the menu like this:File Edit Format View HelpThese are the "accelerator" keys for the menu - if you now press "f", the <File> menu opens and you can see that there are more underlined characters in the sub-menu. Once again you can action an item by pressing the "accelerator" key - like "u" for <Page Setup>. So you can Send the keys directly to the app and have the menu open.Some apps do not have "accelerators" for all the submenu items, or even at all. In this case you might have to Send cursor keys to move to the correct item and then Send "Enter" to action it. To action the <Page Setup> item in Notepad this way would work something like this:- Determine where the menu bar is situated on the GUI - convert this position to screen coordinates with _WinAPI_ClientToScreen.- MouseClick on the menu bar to open it.- Send down "Down" 5 times to get to the <Page Setup> item- Send "Enter" to action it.I hope that is clearer. M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mayur Posted February 12, 2010 Author Share Posted February 12, 2010 Thanks for your help It Worked. Link to comment Share on other sites More sharing options...
Zedna Posted February 12, 2010 Share Posted February 12, 2010 Also look at WinMenuSelectItem() Resources UDF ResourcesEx UDF AutoIt Forum Search 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