charlie2charlie Posted May 12, 2020 Share Posted May 12, 2020 Hi, Im working my way through the tutorial fir AUTOIT. I cant seem to get it to colse the notepad, the notepad just hangs there open. here is the code. run("Notepad.exe") WinWaitActive("Untitled - Notepad") send("This is some Text") WinClose("Untitled - Notepad") WinWaitActive("Notepad","Do you want to save") Send("!n") Ive bet messing about with this for over an hour now, and something is worng. Ive noticed , when notepad save, its saving as "*notpad" with a * on the front, this seems to be a problem, why is notepad prefixing with a *? Link to comment Share on other sites More sharing options...
charlie2charlie Posted May 12, 2020 Author Share Posted May 12, 2020 Link to comment Share on other sites More sharing options...
argumentum Posted May 13, 2020 Share Posted May 13, 2020 26 minutes ago, charlie2charlie said: Ive noticed , when notepad save, its saving as "*notpad" with a * on the front, this seems to be a problem, you've got it !. So you are not stuck 26 minutes ago, charlie2charlie said: this seems to be a problem, why is notepad prefixing with a *? No clue. Updates ? charlie2charlie 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Colduction Posted May 13, 2020 Share Posted May 13, 2020 Hi, you should see and learn about Send function in Help file, the help file has a good example for your what you want: Example() Func Example() ; Simulate the key combination Win + R to open the Run dialogue window. Send("#r") ; Wait 10 seconds for the Run dialogue window to appear. WinWait("Run", "", 10) ; Simulate entering notepad.exe and pressing the 'ENTER' key. Send("notepad.exe{Enter}") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Simulate entering the following string and pressing the 'F5' key to input the date and time into edit control of Notepad. Send("Today's time/date is {F5}") ; Close the Notepad window using the handle returned by WinWait. WinClose($hWnd) ; Now a screen will pop up and ask to save the changes, the classname of the window is called ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file" WinWaitActive("[CLASS:#32770]") Sleep(500) Send("{TAB}{ENTER}") EndFunc ;==>Example charlie2charlie 1 Link to comment Share on other sites More sharing options...
TheXman Posted May 13, 2020 Share Posted May 13, 2020 (edited) The script below is the same as yours with 1 line added at the top. By default, the title string has to be an exact match starting from the beginning of the window's title. The asterisk (*) in the notepad title denotes that the file has been modified since it was last saved or created. The OPT function that I added to the script says that the string you provide for the title can appear anywhere in the title. If you use a -2, it will means it can appear anywhere in the title and is not case-sensitive. Opt('WinTitleMatchMode', 2) ;1 = Start, 2 = SubString, 3 = Exact, 4 = Advanced, -1 to -4 = Case Insensitive. run("Notepad.exe") WinWaitActive("Untitled - Notepad") send("This is some Text") WinClose("Untitled - Notepad") WinWaitActive("Notepad","Save") Send("!n") *Updated example Looks like there were a few changes to Notepad in Windows 10. The Save dialog's visible text has changed. The script above should work on Windows 10. You can lookup each command in the Help file to see how and why it works. Edited May 13, 2020 by TheXman charlie2charlie 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
charlie2charlie Posted May 13, 2020 Author Share Posted May 13, 2020 Cheers guys for grouping around , Im getting somewhere, slowly, but steadily. I appreciate the prompts. Cheers. argumentum 1 Link to comment Share on other sites More sharing options...
Subz Posted May 13, 2020 Share Posted May 13, 2020 If you're wanting to use send or mouse clicks then recommend using Control.. functions (see ControlSend, ControlClick in the help file). If you wanted to write text to a file, then would recommend using FileOpen, FileWrite functions. Just my 2 cents. charlie2charlie 1 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