cheeth Posted August 2, 2006 Share Posted August 2, 2006 I'm newbi here. Please tell me how to select a menuitem from other app (for ex: select "Save as..." from menu "File" of NotePad application). I've tried with WinMenuSelectItem, but it did not work Thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 2, 2006 Moderators Share Posted August 2, 2006 WinMenuSelectItem Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cheeth Posted August 2, 2006 Author Share Posted August 2, 2006 WinMenuSelectItemThanks SmOke. I used "WinMenuSelectItem" but i did not work. Here is my code:#include <GUIConstants.au3>$title = "Untitled - Notepad"Run("notepad.exe"); Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systemsWinWaitActive($title ); Now that the Notepad window is active type some textSend("Hello from Notepad.{ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")$blnSuccess = WinMenuSelectItem($title , "", "File", "Save As..." )If ($blnSuccess = 1) then MsgBox("Success", "", "Select menu item successful")Else MsgBox("Fail", "", "Select menu item fail")EndIfWhile 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoopWend Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 2, 2006 Moderators Share Posted August 2, 2006 If you want to save something to a text file, you could do it with FileWrite fairly easy: Example: $FILE = FileGetShortName(@HomeDrive & '\SaveTextTest.txt') FileWrite($FILE, 'Just an example') Run(@Comspec & ' /c start ' & $FILE, '', @SW_HIDE) MsgBox(64, 'Info:', 'File is saved here: ' & FileGetLongName($FILE)) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cheeth Posted August 2, 2006 Author Share Posted August 2, 2006 If you want to save something to a text file, you could do it with FileWrite fairly easy: Example: $FILE = FileGetShortName(@HomeDrive & '\SaveTextTest.txt') FileWrite($FILE, 'Just an example') Run(@Comspec & ' /c start ' & $FILE, '', @SW_HIDE) MsgBox(64, 'Info:', 'File is saved here: ' & FileGetLongName($FILE)) Thanks SmOke. I want to select a menu item on other app from AutoScript. Saving text from NotePad is just a example. Btw, Thank for your help Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 2, 2006 Moderators Share Posted August 2, 2006 Hmm, I don't know what to tell you, it's a lot of trial and error. Try this:$Window = 'Untitled - Notepad' If Not WinExists($Window) Then Run('notepad.exe') WinWaitActive($Window) Sleep(1000) If WinMenuSelectItem($Window, '', '&File', 'Save &As...') Then MsgBox(64, 'Info', 'Success, Save As is open') Else MsgBox(64, 'Info', 'Failure') EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cheeth Posted August 2, 2006 Author Share Posted August 2, 2006 Hmm, I don't know what to tell you, it's a lot of trial and error. Try this:$Window = 'Untitled - Notepad' If Not WinExists($Window) Then Run('notepad.exe') WinWaitActive($Window) Sleep(1000) If WinMenuSelectItem($Window, '', '&File', 'Save &As...') Then MsgBox(64, 'Info', 'Success, Save As is open') Else MsgBox(64, 'Info', 'Failure') EndIf Now it works. Thanks SmOke. Another question, How do you know text of menu ('&File', 'Save &As...'). I did not see any underscore below "F" and "A" char. I used AutoIt Window Info, but got nothing. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 2, 2006 Moderators Share Posted August 2, 2006 As I said above, it was trial and error for me. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
MHz Posted August 2, 2006 Share Posted August 2, 2006 Now it works. Thanks SmOke. Another question, How do you know text of menu ('&File', 'Save &As...'). I did not see any underscore below "F" and "A" char. I used AutoIt Window Info, but got nothing.Just pressing the Alt key should make the underlines appear under the accellerator keys in the menu. 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