Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <AutoItConstants.au3>
- #include <MsgBoxConstants.au3>
- Example()
- Func Example()
- ; Change the username and password to the appropriate values for your system.
- Local $sUserName = "build"
- Local $sPassword = "Mbimp,vm"
- ; Run Notepad with the window maximized. Notepad is run under the user previously specified.
- Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "C:\Users\build\Downloads\winrar-x64-540.exe", "", @SW_SHOWMAXIMIZED)
- ; Wait 10 seconds for the Notepad window to appear.
- WinWait("[CLASS:WinRAR 5.40]", "", 5)
- ; Wait for 2 seconds.
- ControlClick("WinRAR 5.40", "", "[CLASS:Button; TEXT:Install;]") ; TODO version is hardcoded. What we can do to fix this?
- WinWait("[CLASS:WinRAR Setup]", "", 7)
- Sleep(2000)
- Local $sText = ControlGetText("[CLASS:#32770]","","[CLASS:RichEdit20W]")
- If Not @error = -1 Then
- Local $iPosition = StringInStr($sText, "These options control WinRAR integration")
- If Not $iPosition = 0 Then
- ControlClick("WinRAR Setup", "", "[CLASS:Button; TEXT:OK;]")
- EndIf
- EndIf
- Sleep(5000)
- $sText = ControlGetText("WinRAR Setup","","[CLASS:Static; INSTANCE:7]")
- If Not @error = -1 Then
- Local $iPosition = StringInStr($sText, "Thank you")
- MsgBox($MB_SYSTEMMODAL, "", "Thanks")
- If Not $iPosition = 0 Then
- MsgBox($MB_SYSTEMMODAL, "", "CLICK")
- ControlClick("WinRAR Setup", "", "[CLASS:Button; TEXT:Done; INSTANCE:1]")
- EndIf
- EndIf
- MsgBox($MB_SYSTEMMODAL, "", "DONE")
- ; Close the Notepad process using the PID returned by RunAs.
- ProcessClose($iPID)
- EndFunc ;==>Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement