EnderWiggin 0 Posted June 16, 2010 (edited) I am embarrassed to ask for help at such an early juncture in my learning. But after reading all the manuals and searching the forum for, e.g. 'notepad,' 'win7 x64,' 'alt key,' 'using ! for alt,' etc., I haven't been able to come up with any one else who's had my problem. The Stumbling Block: I was working through the very basic introductory scripts. On the notepad script, when I come to the line where I'm supposed to send alt-n to close the dialog box that pops up asking, roughly, 'Save before exiting?,' I can't get it to do anything. My Detective Work: If I press 'alt-n' manually, at that point, it works, so I thought that maybe the send("!n") command might not be working properly for me. I also thought it might be a problem with recognizing the dialog box. I tried to find another program that had a dialog box-- hopefully not requiring an alt-key combination-- but all of them seem to require alt-keys. So I'm left uncertain whether it's the alt-key signal (exclamation mark) or the dialog box, or something else I haven't considered. Has anything similar happened to anyone else? I tried many forum searches, and even ended up reading most of a book on scripting, looking for anything that might help (and learning much in the process) but couldn't find an analogous problem. Am I too stupid to learn to code? I feel very bad getting hung up on the second tutorial. Apologies if I am wasting people's time. ; Script Start - Add your code below here Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("This is some text.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "Do you want to save") Send("!n") (edited to add the autoit command: thanks m23) Edited June 16, 2010 by EnderWiggin Share this post Link to post Share on other sites
water 2,388 Posted June 16, 2010 You could useControlClick ( "Untitled - Notepad", "", 7) The controlid (7) was determined by AutoIt Window Info on a german Notepad. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
kaotkbliss 146 Posted June 16, 2010 what happens if you Send("{ALT}n") instead? 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
EnderWiggin 0 Posted June 16, 2010 what happens if you Send("{ALT}n") instead? Thank you, water and kaotkbliss, for responding so quickly. I tried both of your ideas and run into the same problem as before. The script runs. It opens notepad, types the phrase, and tries to exit, but won't send the alt-n to the dialog box, so it ends with the last window, 'save changes?' still open. I used the window info tool to get a summary of the dialog box, thinking I might have a different number for the control than water, since he stipulated that it was a german version. I copied that here at the end of this post. Not sure if it makes sense. I was looking for a control number similar to 7. I assume that's not the class #32770? I also noticed I couldn't type "{Alt}" and can't type it here either. The squiggly brackets won't appear. Though I can type it in word and copy/paste. I've had the strange experience with my keyboard that if I hit the forward bracket button it outputs -[. So I type "[" and get "-[" Could I have some kind of keyboard issue that in turn is affecting what autoit gets when it tries to send keyboard commands? Or wouldn't the keyboard itself enter into autoit's simulation of a keystroke, specifically alt-n? Sorry for the repeated and undoubtedly mundane queries. I very much appreciate the attempts to help thus far. >>>> Window <<<< Title: Notepad Class: #32770 Position: 776, 487 Size: 366, 140 Style: 0x96C80284 ExStyle: 0x00010101 Handle: 0x00000000000702CE >>>> Control <<<< Class: DirectUIHWND Instance: 1 ClassnameNN: DirectUIHWND1 Name: Advanced (Class): [CLASS:DirectUIHWND; INSTANCE:1] ID: Text: Position: 0, 0 Size: 350, 102 ControlClick Coords: 122, 2 Style: 0x56000000 ExStyle: 0x00000000 Handle: 0x00000000000A02EC >>>> Mouse <<<< Position: 906, 519 Cursor ID: 2 Color: 0xFFFFFF >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< &Save Do&n't Save Cancel >>>> Hidden Text <<<< Share this post Link to post Share on other sites
water 2,388 Posted June 16, 2010 Found the problem: The window appearing after WinClose has a different title. So your script now waits forever. Change WinWaitActive to "WinWaitActive("Editor", ...)" and everything should run fine. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
EnderWiggin 0 Posted June 16, 2010 Found the problem: The window appearing after WinClose has a different title. So your script now waits forever. Change WinWaitActive to "WinWaitActive("Editor", ...)" and everything should run fine. Hooray! You were right, it was a change in the name of the window, from "Untitled - Notepad" to "Notepad" that was causing the hangup. I changed the code to: ; Script Start - Add your code below here Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("This is some text.") WinClose("Untitled - Notepad") WinWaitActive("Notepad") Send("!n") And it worked. What a great feeling. Thank you so much. Share this post Link to post Share on other sites