masonj Posted May 29, 2008 Share Posted May 29, 2008 Noob here...Ive been playing around a little with the notepad example from AutoIT. So far I can get it to open a file, write some text to it, and then do a Save As. The code I have for this is below, and it seems to work.The problem I am having is that I need to do something where I provide the path, like in the following:Send("myFile\shortFile.pc0")But this doesnt work unless notepad happens to open in myFile.It seems to me that I need to gain control over the Look in (combobox?) field so that "myFile\outFile1" will make sense to it, but so far no luck. Im out of ideas, so any help would be greatly appreciated. expandcollapse popup;Run Notepad Run("notepad.exe") ;Wait for the Notepad become active WinWaitActive("Untitled - Notepad") ;slow things down so I can see what's happening AutoItSetOption("SendKeyDelay", 200) ;get ready to open a file WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Open" ) ;the name of the file to open is "shortFile.pc0". ;the .pc0 is just a text file on the inside. ;ControlSend("Open", "", "Edit1", "myFile\shortFile.pc0");doesnt work?? Send("myFile\shortFile.pc0");this works as long as notepad opens to myFile ;click the Open button Send("!o") ;write some text ;Send("This is some text.") ;get ready to save the file. ;Note that the name of the window is now "shortFile.pc0" WinMenuSelectItem("shortFile.pc0", "", "&File", "Save &As..." ) ;set the name of the file to save to "outFile" ControlSend("Save As", "", "Edit1", "outFile1") ;save it as a text file ;ControlSend("Save As", "", "ComboBox3", "Text File (*.txt)") ControlSend("Save As", "", "ComboBox3", "All Files") ;click the "Save" button Send("!s") ;close notepad ;WinClose("outFile.txt - Notepad") Send("!f") Send("x") Link to comment Share on other sites More sharing options...
evilertoaster Posted May 29, 2008 Share Posted May 29, 2008 It would be possible to script the GUI as you are trying to do, but it would be much simpler to just do somthing like- Run("notepad.exe C:\folder\myFile\shortFile.pc0") Link to comment Share on other sites More sharing options...
masonj Posted May 29, 2008 Author Share Posted May 29, 2008 It would be possible to script the GUI as you are trying to do, but it would be much simpler to just do somthing like- Run("notepad.exe C:\folder\myFile\shortFile.pc0") evilertoaster: That works for me! And how simple I had no idea notepad could start like that. Thanks very much! Mason Link to comment Share on other sites More sharing options...
masonj Posted May 30, 2008 Author Share Posted May 30, 2008 Does anyone know how I can specify the folder that I open from and/or save to? Should I be trying to set the look in combobox? If so, how do you do that? This morning it dawned on me that not all applications are going to take the extra argument (as suggested by evilertoaster) the way that notepad does. Noob here... Ive been playing around a little with the notepad example from AutoIT. So far I can get it to open a file, write some text to it, and then do a Save As. The code I have for this is below, and it seems to work. The problem I am having is that I need to do something where I provide the path, like in the following: Send("myFile\shortFile.pc0") But this doesnt work unless notepad happens to open in myFile. It seems to me that I need to gain control over the Look in (combobox?) field so that "myFile\outFile1" will make sense to it, but so far no luck. Im out of ideas, so any help would be greatly appreciated. expandcollapse popup;Run Notepad Run("notepad.exe") ;Wait for the Notepad become active WinWaitActive("Untitled - Notepad") ;slow things down so I can see what's happening AutoItSetOption("SendKeyDelay", 200) ;get ready to open a file WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Open" ) ;the name of the file to open is "shortFile.pc0". ;the .pc0 is just a text file on the inside. ;ControlSend("Open", "", "Edit1", "myFile\shortFile.pc0");doesnt work?? Send("myFile\shortFile.pc0");this works as long as notepad opens to myFile ;click the Open button Send("!o") ;write some text ;Send("This is some text.") ;get ready to save the file. ;Note that the name of the window is now "shortFile.pc0" WinMenuSelectItem("shortFile.pc0", "", "&File", "Save &As..." ) ;set the name of the file to save to "outFile" ControlSend("Save As", "", "Edit1", "outFile1") ;save it as a text file ;ControlSend("Save As", "", "ComboBox3", "Text File (*.txt)") ControlSend("Save As", "", "ComboBox3", "All Files") ;click the "Save" button Send("!s") ;close notepad ;WinClose("outFile.txt - Notepad") Send("!f") Send("x") Link to comment Share on other sites More sharing options...
masonj Posted May 30, 2008 Author Share Posted May 30, 2008 It seems to me that this should work: Run("notepad.exe") ;Wait for the Notepad become active WinWaitActive("Untitled - Notepad") ;slow things down so I can see what's happening AutoItSetOption("SendKeyDelay", 100) ;get ready to open a file WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Open" ) Send("!i");Look &in: Send("C:\EasyScan\myFile") But it doesn't. Surely someone out there must know the answer. This has got to be basic AutoIT stuff isn't it?! Mason Does anyone know how I can specify the folder that I open from and/or save to? Should I be trying to set the look in combobox? If so, how do you do that? This morning it dawned on me that not all applications are going to take the extra argument (as suggested by evilertoaster) the way that notepad does. Link to comment Share on other sites More sharing options...
Bert Posted May 30, 2008 Share Posted May 30, 2008 Are you simply trying to put text into a file? You can use filewrite to do it. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
masonj Posted May 30, 2008 Author Share Posted May 30, 2008 Are you simply trying to put text into a file? You can use filewrite to do it. No, I'm trying to control the directory that I read and write from by using the "Look in" drop down box that's displayed when you try to Open or Save As. Link to comment Share on other sites More sharing options...
HarshChaturvedi Posted October 21, 2013 Share Posted October 21, 2013 Hi , excuse me if i am being naive but what if we want to create a notepad file and add text to it but all this should happen with the window being in minimized mode?? Is it possible? Link to comment Share on other sites More sharing options...
l3ill Posted October 21, 2013 Share Posted October 21, 2013 Save to desktop would look something like this: WinWaitActive("Save File") Sleep(500) Send(@DesktopDir & "\" & "yourfile.pco") Send("!s") My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
guinness Posted October 21, 2013 Share Posted October 21, 2013 This is an old thread, so please don't revive in the future. Why do you want to use notepad when AutoIt can directly interact with files? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
l3ill Posted October 21, 2013 Share Posted October 21, 2013 Sorry my bad... wasn't paying attention My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Bert Posted October 21, 2013 Share Posted October 21, 2013 Zombie thread award nominee!!! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 22, 2013 Share Posted October 22, 2013 Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
l3ill Posted October 22, 2013 Share Posted October 22, 2013 Is there anything worse than a 5 year old thread hijacker? Yes, someone who spams a hijacked a 5 year old thread..... ...present company accepted, naturally ;-) My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted October 22, 2013 Share Posted October 22, 2013 A 8 year old thread hijacker that admits it's for a game at the same time? "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation 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