Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. on run {input, parameters}
  2. -- Press Return
  3. delay 0.1
  4. set timeoutSeconds to 1.0
  5. set uiScript to "keystroke \"
  6. \" "
  7. my doWithTimeout(uiScript, timeoutSeconds)
  8. return input
  9. end run
  10.  
  11. on doWithTimeout(uiScript, timeoutSeconds)
  12. set endDate to (current date) + timeoutSeconds
  13. repeat
  14. try
  15. run script "tell application \"System Events\"
  16. " & uiScript & "
  17. end tell"
  18. exit repeat
  19. on error errorMessage
  20. if ((current date) > endDate) then
  21. error "Can not " & uiScript
  22. end if
  23. end try
  24. end repeat
  25. end doWithTimeout
  26. ______________________________________________________________________
  27.  
  28. on run {input, parameters}
  29. -- ⌘W drücken
  30. delay 0.15
  31. set timeoutSeconds to 1.0
  32. set uiScript to "keystroke \"w\" using command down"
  33. my doWithTimeout(uiScript, timeoutSeconds)
  34. return input
  35. end run
  36.  
  37. on doWithTimeout(uiScript, timeoutSeconds)
  38. set endDate to (current date) + timeoutSeconds
  39. repeat
  40. try
  41. run script "tell application \"System Events\"
  42. " & uiScript & "
  43. end tell"
  44. exit repeat
  45. on error errorMessage
  46. if ((current date) > endDate) then
  47. error "Can not " & uiScript
  48. end if
  49. end try
  50. end repeat
  51. end doWithTimeout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement