Advertisement
Guest User

Untitled

a guest
Sep 24th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <AutoItConstants.au3>
  2. #include <MsgBoxConstants.au3>
  3.  
  4. Example()
  5.  
  6. Func Example()
  7.     ; Change the username and password to the appropriate values for your system.
  8.     Local $sUserName = "build"
  9.     Local $sPassword = "Mbimp,vm"
  10.  
  11.     ; Run Notepad with the window maximized. Notepad is run under the user previously specified.
  12.     Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "C:\Users\build\Downloads\winrar-x64-540.exe", "", @SW_SHOWMAXIMIZED)
  13.  
  14.     ; Wait 10 seconds for the Notepad window to appear.
  15.    WinWait("[CLASS:WinRAR 5.40]", "", 5)
  16.  
  17.     ; Wait for 2 seconds.
  18.    ControlClick("WinRAR 5.40", "", "[CLASS:Button; TEXT:Install;]") ; TODO version is hardcoded. What we can do to fix this?
  19.  
  20.    WinWait("[CLASS:WinRAR Setup]", "", 7)
  21.  
  22.  
  23.    Sleep(2000)
  24.    Local $sText = ControlGetText("[CLASS:#32770]","","[CLASS:RichEdit20W]")
  25.    If Not @error = -1 Then
  26.      Local $iPosition = StringInStr($sText, "These options control WinRAR integration")
  27.      If Not $iPosition = 0 Then
  28.          ControlClick("WinRAR Setup", "", "[CLASS:Button; TEXT:OK;]")
  29.       EndIf
  30.    EndIf
  31.  
  32.    Sleep(5000)
  33.    $sText = ControlGetText("WinRAR Setup","","[CLASS:Static; INSTANCE:7]")
  34.    If Not @error = -1 Then
  35.      Local $iPosition = StringInStr($sText, "Thank you")
  36.       MsgBox($MB_SYSTEMMODAL, "", "Thanks")
  37.      If Not $iPosition = 0 Then
  38.          MsgBox($MB_SYSTEMMODAL, "", "CLICK")
  39.          ControlClick("WinRAR Setup", "", "[CLASS:Button; TEXT:Done; INSTANCE:1]")
  40.       EndIf
  41.    EndIf
  42.  
  43.    MsgBox($MB_SYSTEMMODAL, "", "DONE")
  44.  
  45.    ; Close the Notepad process using the PID returned by RunAs.
  46.     ProcessClose($iPID)
  47. EndFunc   ;==>Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement