HenrikMorin Posted February 14, 2019 Share Posted February 14, 2019 Hi Forum, I do have a very important question to ask the Forum. In the examples that I have seen up to now and played with, the application that I will control is started as the first thing in the script. That makes sense of cause, but not necessarily in all cases. The application that I'm asked to do automation on, is a big package sitting on a server in a big network. During startup, there is a memory management software being loaded and a login dialog to deal with. All in all, it nearly takes 40 sec. before the app shows up. So this big delay doesn't really invite you to start it over and over again to get your little script running. So, I'm wondering if it's possible somehow to have the big application running and then start the script when the user want's to run his automated procedure doing this, that and whatever. I have tried it on a simple Notepad example, but it's not working. It's probably missing a handle to the application, to get it all right! Thanks for any ideas Thanks, Henrik Link to comment Share on other sites More sharing options...
caramen Posted February 14, 2019 Share Posted February 14, 2019 Show me somthing that is not working so I will try to help you. Not alone I’m sure. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - 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 - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
HenrikMorin Posted February 14, 2019 Author Share Posted February 14, 2019 1 hour ago, caramen said: Show me somthing that is not working so I will try to help you. Not alone I’m sure. Hi Caramen, Here is the script that works fine, when it starts Notepad as the first thing: ; open Notepad ;Run ( "Notepad.exe" ) ; wait for Notepad window to exist Local $hNotepad = WinWait ( "[CLASS:Notepad; TITLE:Unavngivet - Notesblok;]" ) ; write "HelloWorld" ControlSetText ( $hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "HelloWorld" ) ; open the SaveAs window (by pressing ALT+f and a) ControlSend ( $hNotepad, "", "", "{ALT}fg" ) ; wait for Save As window to exist Local $hSaveAs = WinWait ( "[CLASS:#32770; TITLE:Gem som;]" ) ; complete the File Name field with "HelloWorld.txt" ControlSetText ( $hSaveAs, "", "[CLASS:Edit; INSTANCE:1]", "C:\$HemConsult\AUTOIT\HelloWorld.txt" ) ; press the Save button ControlClick ( $hSaveAs, "", "[CLASS:Button; INSTANCE:2]" ) ; wait for Bekræft Gem som window to exist Local $hConfirmSaveAs = WinWait ( "[CLASS:#32770; TITLE:Bekræft Gem som;]", "", 5 ) If $hConfirmSaveAs Then ; press the no button ControlClick ( $hConfirmSaveAs, "", "[CLASS:Button; INSTANCE:2]" ) ; press the Cancel button ControlClick ( $hSaveAs, "", "[CLASS:Button; INSTANCE:3]" ) EndIf ; wait for Save As window to close WinWaitClose ( $hSaveAs, "" ) ; close the Notepad window WinClose ( $hNotepad, "" ) ; wait for Notepad window to close WinWaitClose ( $hNotepad, "" ) This is how far it gets…. Thanks, Henrik Link to comment Share on other sites More sharing options...
Nine Posted February 14, 2019 Share Posted February 14, 2019 1 hour ago, caramen said: Show me somthing that is not working 35 minutes ago, HenrikMorin said: Here is the script that works fine, FrancescoDiMuro 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
LarsJ Posted February 15, 2019 Share Posted February 15, 2019 If Notepad (here an English version) is already open when you run the script, make Notepad active for ALT+fa to work. There are also a few wrong instance numbers. expandcollapse popup; open Notepad ;Run( "Notepad.exe" ) ; wait for Notepad window to exist Local $hNotepad = WinWait( "[CLASS:Notepad; TITLE:Untitled - Notepad;]" ) ; write "HelloWorld" ControlSetText( $hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "HelloWorld" ) ; activate Notepad WinActivate( $hNotepad ) ; <<<<<<<<<<<<<<<<<<< ; open the SaveAs window(by pressing ALT+f and a) ControlSend( $hNotepad, "", "", "{ALT}fa" ) ; wait for Save As window to exist Local $hSaveAs = WinWait( "[CLASS:#32770; TITLE:Save As;]" ) ; complete the File Name field with "HelloWorld.txt" ControlSetText( $hSaveAs, "", "[CLASS:Edit; INSTANCE:1]", "C:\Windows\Temp\AutoIt\HelloWorld.txt" ) ; press the Save button ControlClick( $hSaveAs, "", "[CLASS:Button; INSTANCE:1]" ) ; 2 --> 1 <<<<<<<<<<<<<<<<<<< ; wait for Bekræft Gem som window to exist Local $hConfirmSaveAs = WinWait( "[CLASS:#32770; TITLE:Confirm Save As;]", "", 5 ) ;Local $hConfirmSaveAs = WinWait( "[CLASS:#32770; TITLE:Confirm Save As;]" ) ;ConsoleWrite( "$hConfirmSaveAs = " & $hConfirmSaveAs & @CRLF ) If $hConfirmSaveAs Then ; press the no button ControlClick( $hConfirmSaveAs, "", "[CLASS:Button; INSTANCE:2]" ) ; press the Cancel button ControlClick( $hSaveAs, "", "[CLASS:Button; INSTANCE:2]" ) ; 3 --> 2 <<<<<<<<<<<<<<<<<<< EndIf ; wait for Save As window to close WinWaitClose( $hSaveAs, "" ) ; close the Notepad window WinClose( $hNotepad, "" ) ; wait for Notepad window to close WinWaitClose( $hNotepad, "" ) Procedure to test the code: Open an empty Notepad. Run the code in SciTE with F5. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
HenrikMorin Posted February 15, 2019 Author Share Posted February 15, 2019 2 hours ago, LarsJ said: If Notepad (here an English version) is already open when you run the script, make Notepad active for ALT+fa to work. There are also a few wrong instance numbers. expandcollapse popup; open Notepad ;Run( "Notepad.exe" ) ; wait for Notepad window to exist Local $hNotepad = WinWait( "[CLASS:Notepad; TITLE:Untitled - Notepad;]" ) ; write "HelloWorld" ControlSetText( $hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "HelloWorld" ) ; activate Notepad WinActivate( $hNotepad ) ; <<<<<<<<<<<<<<<<<<< ; open the SaveAs window(by pressing ALT+f and a) ControlSend( $hNotepad, "", "", "{ALT}fa" ) ; wait for Save As window to exist Local $hSaveAs = WinWait( "[CLASS:#32770; TITLE:Save As;]" ) ; complete the File Name field with "HelloWorld.txt" ControlSetText( $hSaveAs, "", "[CLASS:Edit; INSTANCE:1]", "C:\Windows\Temp\AutoIt\HelloWorld.txt" ) ; press the Save button ControlClick( $hSaveAs, "", "[CLASS:Button; INSTANCE:1]" ) ; 2 --> 1 <<<<<<<<<<<<<<<<<<< ; wait for Bekræft Gem som window to exist Local $hConfirmSaveAs = WinWait( "[CLASS:#32770; TITLE:Confirm Save As;]", "", 5 ) ;Local $hConfirmSaveAs = WinWait( "[CLASS:#32770; TITLE:Confirm Save As;]" ) ;ConsoleWrite( "$hConfirmSaveAs = " & $hConfirmSaveAs & @CRLF ) If $hConfirmSaveAs Then ; press the no button ControlClick( $hConfirmSaveAs, "", "[CLASS:Button; INSTANCE:2]" ) ; press the Cancel button ControlClick( $hSaveAs, "", "[CLASS:Button; INSTANCE:2]" ) ; 3 --> 2 <<<<<<<<<<<<<<<<<<< EndIf ; wait for Save As window to close WinWaitClose( $hSaveAs, "" ) ; close the Notepad window WinClose( $hNotepad, "" ) ; wait for Notepad window to close WinWaitClose( $hNotepad, "" ) Procedure to test the code: Open an empty Notepad. Run the code in SciTE with F5. Hi LarsJ, Thanks. The WinActivate did the trick. 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