Advertisement
MarkUa

Untitled

Oct 28th, 2019
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <Constants.au3>
  2.  
  3. ;
  4. ; AutoIt Version: 3.0
  5. ; Language: English
  6. ; Platform: Win9x/NT
  7. ; Author: Jonathan Bennett (jon at autoitscript dot com)
  8. ;
  9. ; Script Function:
  10. ; Plays with the calculator.
  11. ;
  12.  
  13. ; Prompt the user to run the script - use a Yes/No prompt with the flag parameter set at 4 (see the help file for more details)
  14. Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "AutoIt Example", "This script will run the calculator and type in 2 x 4 x 8 x 16 and then quit. Do you want to run it?")
  15.  
  16. ; Check the user's answer to the prompt (see the help file for MsgBox return values)
  17. ; If "No" was clicked (7) then exit the script
  18. If $iAnswer = 7 Then
  19. MsgBox($MB_SYSTEMMODAL, "AutoIt", "OK. Bye!")
  20. Exit
  21. EndIf
  22.  
  23. ; Run the calculator
  24. Run("calc.exe")
  25.  
  26. ; Wait for the calculator to become active. The classname "CalcFrame" is monitored instead of the window title
  27. WinWaitActive("[CLASS:CalcFrame]")
  28.  
  29. ; Now that the calculator window is active type the values 2 x 4 x 8 x 16
  30. ; Use AutoItSetOption to slow down the typing speed so we can see it
  31. AutoItSetOption("SendKeyDelay", 400)
  32. Send("2*4*8*16=")
  33. Sleep(2000)
  34.  
  35. ; Now quit by sending a "close" request to the calculator window using the classname
  36. WinClose("[CLASS:CalcFrame]")
  37.  
  38. ; Now wait for the calculator to close before continuing
  39. WinWaitClose("[CLASS:CalcFrame]")
  40.  
  41. ; Finished!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement