One of my projects is going to use AutoIt script to launch client application on Windows machine. It will usually require to auto-fill in some information on popped up windows.
This post is to collect some useful scripts I found from Internet. Some of them are made by myself for certain purpose.
AutoInstallation Script
;
; NComputing AutoInstallation Script v1.1.1.06262012
; AutoIt Version: 3.0
; Language: English
; Platform: Win7
; Author: Matthew Roslevich
; /email/
;
; Script Function:
; Opens NComputing vSpace Windows 7 x64 installer and fills in the registration information.
;
; Run vSpace installer
Run("vSpace_X-6.2.5.4_setup.exe")
; Wait for the vSpace installer window to become active - it is titled "NComputing vSpace"
WinWaitActive("NComputing vSpace")
; Now that the vSpace window is active, start the installer
; Initial installer screen
Sleep(1000)
Send("{TAB 2}")
Sleep(500)
Send("{ENTER}")
; vSpace End User License Agreement
Sleep(1000)
Send("{TAB}")
Sleep(500)
Send("{RIGHT}")
Sleep(500)
Send("{ENTER}")
; vSpace Terms of Use Agreement
Sleep(1000)
Send("{TAB}")
Sleep(500)
Send("{RIGHT}")
Sleep(500)
Send("{ENTER}")
; Initial Screen Resolution (default is 1024x768 16bpp 60Hz)
Sleep(1000)
Send("{ENTER}")
; Select Installation Folder (default is C:\Program Files\NComputing\NComputing vSpace\)
Sleep(1000)
Send("{ENTER}")
; Confirm Installation
Sleep(1000)
Send("{ENTER}")
; Now a screen will pop up and ask to install device software, the window is called
; "Windows Security" and has some text "Install" and "Don't Install"
WinWaitActive("Windows Security")
Sleep(1500)
Send("{LEFT 2}")
Sleep(500)
Send("{SPACE}")
Sleep(500)
Send("{RIGHT}")
Sleep(500)
Send("{ENTER}")
; Another screen will pop up with registration details, the window is called
; "License wizard" and has a form which needs filled out.
WinWait("License wizard")
Sleep(1000)
Send("Technology Department")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("School District X")
Sleep(500)
Send("{TAB 2}")
Sleep(500)
Send("Address 1")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("City")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("PA")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("17701")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("[email protected]")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("570-555-1212")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("NComputing")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("{DOWN}")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("{ENTER}")
; Yet another screen will pop up reminding user about attaching device(s) after installation finishes.
; The window is called "NComputing vSpace" and has an "OK" button.
WinWaitActive("NComputing vSpace")
Sleep(1000)
Send("{ENTER}")
; The installer is finished! Last thing is to press the "CLOSE" button.
WinWaitActive("NComputing vSpace")
Sleep(1000)
Send("{ENTER}")
; Standard [you must restart the system to have change take effect] window.
; The window is still called "NComputing vSpace", and has a "YES" and "NO" button.
WinWaitActive("NComputing vSpace")
Sleep(1000)
Send("{ENTER}")
; Finished!
Launch Application Windows and Fill in Password
;
;Thycotic xca.exe with password launcher script
;Author: Johnny Yan
;set filepath of ssms.exe
;$Path = "c:\tools\xca\xca.exe c:\tools\certs\ivari_xca.xdb"
$Path = "C:\tools\xca\xca.exe"
;execute xca.exe to open xdb
;ShellExecute($Path)
ShellExecute($Path, "c:\tools\certs\ivari_xca.xdb")
;Wait for the 'Password' window to appear
WinWaitActive("Password", "", 0)
;WinActivate ("Password")
;set password to password passed from Secret Server launcher in cmd line parameter 3
;ControlSetText("Password", "", "[NAME:password]", $CmdLine[3],1)
;ControlSetText("Password", "", "[NAME:password]", "Password1234")
Send("Password1234")
Sleep(500)
;reactivate the connect to server window, required Enter within the window
WinActivate ("Password")
;click the connect button
;ControlClick("Password", "", "[NAME:OK]")
Send("{Enter}")
; Finished!
OpenLinkInIE.au3
;
; this script copies an address from Mozilla Firefox and opens it in IE
; click in Firefox's address bar before running the script
Opt("WinTitleMatchMode", 2) ; this tells AutoIt to match any part of window title in the following window commands
WinActivate("Mozilla Firefox") ; activates the Mozilla Firefox window
WinWaitActive("Mozilla Firefox") ; waits for Mozilla Firefox to be the active window before continuing
Send("{HOME}") ; the Send command tells AutoIt to type text; this line simulates pressing the Home key
Send("+{END}") ; this line simulates pressing Shift+End
Send("^c") ; this line simulates CTRL+c
Run("C:\Program Files\Internet Explorer\iexplore.exe") ; starts IE; you may need to edit this path
WinActivate("Internet Explorer") ; activates the IE window
WinWaitActive("Internet Explorer") ; waits for IE to be the active window before continuing
Send("^t") ; opens new tab in IE
WinWaitActive("New Tab - Windows Internet Explorer") ; you may need to edit this text depending on you IE version
Send("^v") ; pastes the contents of the clipboard
Send("{ENTER}") ; this line simulates pressing Enter
OpenLinkInIE.au3
;
; this script copies an address from Mozilla Firefox and opens it in IE
; click in Firefox's address bar before running the script
Opt("WinTitleMatchMode", 2) ; this tells AutoIt to match any part of window title in the following window commands
WinActivate("Mozilla Firefox") ; activates the Mozilla Firefox window
WinWaitActive("Mozilla Firefox") ; waits for Mozilla Firefox to be the active window before continuing
Send("{HOME}") ; the Send command tells AutoIt to type text; this line simulates pressing the Home key
Send("+{END}") ; this line simulates pressing Shift+End
Send("^c") ; this line simulates CTRL+c
Run("C:\Program Files\Internet Explorer\iexplore.exe") ; starts IE; you may need to edit this path
WinActivate("Internet Explorer") ; activates the IE window
WinWaitActive("Internet Explorer") ; waits for IE to be the active window before continuing
Send("^t") ; opens new tab in IE
WinWaitActive("New Tab - Windows Internet Explorer") ; you may need to edit this text depending on you IE version
Send("^v") ; pastes the contents of the clipboard
Send("{ENTER}") ; this line simulates pressing Enter
CopyPasteNotepadToWord_2.au3
; This script copies and pastes 5 lines between two open Word documents.
; Before running this script, open two Word files and save one as old.docx (or old.doc)
; and one as new.docx. The names must be in lower case to match the script.
; Type 5 lines of text in the file named old.
Opt("WinTitleMatchMode", 2) ; configures AutoIt to find a search term in any part of the window title
Dim $x
WinActivate("old") ; activates window with old in the title
WinWaitActive("old") ; waits for the window to be active
Send("^{HOME}") ; simulates pressing CTRL+Home to go to top of document
For $x = 1 to 5 ; this is a loop that is done 5 times
WinActivate("old") ; activates window with Old in the title
WinWaitActive("old"); waits for the window to be active
Send("{HOME}") ; simulates pressing the Home key
Sleep(500) ; pauses for 1/2 a second; I added the pauses to show you what the script is doing
Send("+{END}") ; simulates pressing Shit+End
Sleep(500) ; pauses for 1/2 a second
Send("^c") ; simulates pressing CTRL+c
Send("{RIGHT}") ; simulates pressing the right arrow key
Sleep(500) ; pauses for 1/2 a second
WinActivate("new") ; activates window with new in the title
WinWaitActive("new"); waits for the window to be active
Send("^v") ; simulates pressing CTRL+v
Sleep(500) ; pauses for 1/2 a second
Next
MouseSwitchButtons.au3
; Switches right and left mouse buttons.
; This works with the standard Mouse Properties Control Panel.
; If you installed a program that changes the Mouse Properties control panel,
; it may not work.
; For a list of all the Control Panel applets,
; see http://en.wikipedia.org/wiki/Control_Panel_%28Windows%29
; or google "CPL list."
Run("control.exe main.cpl") ; Opens the Mouse Properties Control Panel applet
WinWaitActive("Mouse Properties") ; Waits for the window to open
Sleep(1000) ; (Optional) Pauses one second so you can watch the script work
Send("!s{ENTER}") ; Types ALT+s then presses the Enter key
MouseSwitchButtons.au3
;Thycotic ssms.exe with sql credential launcher script
;set filepath of ssms.exe
$Path = "C:\Program Files (x86)\Microsoft SQL Server Management Studio
18\Common7\IDE\Ssms.exe"
;execute ssms.exe
ShellExecute($Path)
;Wait for the 'connect to server' window to appear
WinWaitActive("Connect to Server", "", 0)
;set auth mode to SQL authenticaiton
ControlSend("Connect to Server" , "" , "[NAME:comboBoxAuthentication]", "[NAME:SQL]")
;set server instance to servername passed from Secret Server launcher in cmd line parameter 1
ControlSetText("Connect to Server", "", "[NAME:serverInstance]",
$CmdLine[1],1)
;set username to username passed from Secret Server launcher in cmd line parameter 2
ControlSetText("Connect to Server", "", "[NAME:userName]", $CmdLine[2],1)
;set password to password passed from Secret Server launcher in cmd line parameter 3
ControlSetText("Connect to Server", "", "[NAME:password]", $CmdLine[3],1)
;reactivate the connect to server window, required for the click of buttons within the window
WinActivate ("Connect to Server")
;click the connect button
ControlClick("Connect to Server", "", "[NAME:connect]")
via Blogger https://ift.tt/3hUYPRR
July 21, 2021 at 02:27PM Software