Bob23 Posted October 5, 2016 Share Posted October 5, 2016 Thanks kindly to genius257 for answering my earlier question. I played with the Finder Tool to get familiar with it, and opened a cmd window. Then tried creating a script that uses Wordpad. I found the path for Wordpad.exe and put that path into a batch named WP.bat with %1. My script opened my file using Wordpad, then generated some text. The last two steps I wanted were to move cursor to top of file, which requires <Ctrl + PgUp> keys then to open the 'Search' pop-up which requires <Ctrl + s>. I opened my script with the Scite-Lite editor, but did not find how to generate [Ctrl] keystroke combos. Any suggestion? Below is my new script in progress: (I generally prefer (and need) to work from command line mode.) ............................................................. #include <Constants.au3> ; Run cmd.exe Run("cmd.exe") WinWaitActive("[CLASS:ConsoleWindowClass]") Sleep(1000) ; Run Wordpad Run("wp.bat file.txt") WinWaitActive("[CLASS:WordPadClass]") Sleep(1000) ; Now that the Wordpad window is active type some text Send("Line1...{ENTER}Line2...{ENTER}Line3...{ENTER}Line4{ENTER}") Sleep(2000) ; Now go to Save by pressing Alt-F then scrolling down(x2) to 'Save' Send("!f") Sleep(1000) Send("{DOWN 2}{ENTER}") Sleep(2000) ; Now send a <Ctrl + PageUp> keystroke to move to top of file : a prerequisite to search from top of file. Link to comment Share on other sites More sharing options...
l3ill Posted October 5, 2016 Share Posted October 5, 2016 (edited) Send("^{PGUP}") BTW you can do all these with keyboard shortcuts ; Now go to Save by pressing Alt-F then scrolling down(x2) to 'Save' Send("!f") Sleep(1000) Send("{DOWN 2}{ENTER}") Sleep(2000) Try this instead: Send("!FS") Edited October 5, 2016 by l3ill 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...
Moderators JLogan3o13 Posted October 5, 2016 Moderators Share Posted October 5, 2016 Moved to the appropriate forum "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Malkey Posted October 6, 2016 Share Posted October 6, 2016 This example by-passes the cmd prompt to run WordPad. Local $sFileName = "TestFileA.txt" If FileExists($sFileName) Then FileDelete($sFileName) FileWrite($sFileName, "") ; Create file ShellExecute("write.exe", $sFileName, @ScriptDir, "open") ; Open $sFileName in WordPad. Local $hWnd = WinWaitActive("[Class:WordPadClass]") ControlSend($hWnd, "", "RICHEDIT50W1", "Line1...{ENTER}Line2...{ENTER}Line3...{ENTER}Line4{ENTER}") ; The "controlID" parameter can use the actual ClassnameNN value. Found from SciTE > Tools menu > Au3Info (Ctrl+F6) ControlSend($hWnd, "", "RICHEDIT50W1", "^{PGUP}") ; Send Ctrl+PageUp (See Send function in Autoit Help - Press F1 in SciTE v.3.6.6.0) WinWaitActive($hWnd) ; Now go to File menu by pressing Alt-F then Save by pressing Alt-S ControlSend($hWnd, "", "RICHEDIT50W1", "!F") Send("!S") 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