Advertisement
MarkUa

Untitled

Oct 28th, 2019
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 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. ; Opens Notepad, types in some text and then quits the application.
  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 Notepad, type in some text 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 Notepad
  24. Run("notepad.exe")
  25.  
  26. ; Wait for the Notepad to become active. The classname "Notepad" is monitored instead of the window title
  27. WinWaitActive("[CLASS:Notepad]")
  28.  
  29. ; Now that the Notepad window is active type some text
  30. Send("Hello from Notepad.{ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")
  31. Sleep(500)
  32. Send("+{UP 2}")
  33. Sleep(500)
  34.  
  35. ; Now quit by pressing Alt-F and then scrolling down (simulating the down arrow being pressed six times) to the Exit menu
  36. Send("!f")
  37. Sleep(1000)
  38. Send("{DOWN 6}{ENTER}")
  39.  
  40. ; Now a screen will pop up and ask to save the changes, the classname of the window is called
  41. ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
  42. WinWaitActive("[CLASS:#32770]")
  43. Sleep(500)
  44. Send("{TAB}{ENTER}")
  45.  
  46.  
  47. ; Now wait for Notepad to close before continuing
  48. WinWaitClose("[CLASS:Notepad]")
  49.  
  50. ; Finished!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement