Advertisement
WhiteWolfOne

AutoIt Keystroke Paste Paster

Apr 4th, 2019
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.22 KB | None | 0 0
  1. ;This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  2. ;http://creativecommons.org/licenses/by-sa/4.0/
  3.  
  4. ; Copy text to clipboard, e.g. out of Google/Yandex translate
  5. ; Run this, follow the instructions.
  6.  
  7. #include <AutoItConstants.au3>
  8. #include <MsgBoxConstants.au3>
  9.  
  10. Global Const $gsOurTitle = "Keystroke Paste Paster"
  11.  
  12.  
  13. HotKeySet("{ESC}", "Terminate")
  14.  
  15. Global $ganMouseCoords[2]
  16. Global Const $idxX = 0, $idxY = 1
  17.  
  18. main()
  19. Terminate()
  20. Exit
  21.  
  22.  
  23.  
  24. Func Terminate()
  25.     ConsoleWrite(@CRLF & "Autoit script ended." & @CRLF & @CRLF)
  26.     Exit
  27. EndFunc   ;==>Terminate
  28.  
  29.  
  30. Func main()
  31.     Local $ls1 = ""
  32.  
  33.     Do
  34.         $lb1 = False
  35.  
  36.         $ls1 = "Running: " & @AutoItExe & @CRLF
  37.         $ls1 &= @CRLF & @TAB & " " & @ScriptDir & "\" & @ScriptName & @CRLF
  38.         $ls1 &= @CRLF & "Working from: " & @WorkingDir & @CRLF & @CRLF
  39.         $ls1 &= @CRLF
  40.         $ls1 &= @CRLF
  41.  
  42.  
  43.         $li1 = MsgBox($MB_OKCANCEL + $MB_ICONQUESTION + $MB_TOPMOST + $MB_TASKMODAL _
  44.                  + $MB_DEFBUTTON1 _
  45.                 , $gsOurTitle, $ls1 & @CRLF & "Place mouse over clipboard keystroke insertion point." & @CRLF & @CRLF & "Press Enter. [equals 'OK'].", 0)
  46.  
  47.         $ganMouseCoords = MouseGetPos()
  48.  
  49.         Switch $li1
  50.             Case $IDTIMEOUT
  51.             Case $IDOK
  52.                 $lb1 = True
  53.             Case $IDCANCEL
  54.                 ConsoleWrite("Cancelled." & @CRLF)
  55.                 MsgBox($MB_OK + $MB_ICONINFORMATION + $MB_TOPMOST + $MB_TASKMODAL _
  56.                          + $MB_DEFBUTTON1 _
  57.                         , $gsOurTitle, "Cancelled.", 2)
  58.                 Terminate()
  59.             Case $IDABORT
  60.             Case $IDRETRY
  61.             Case $IDIGNORE
  62.             Case $IDYES
  63.             Case $IDNO
  64.             Case $IDTRYAGAIN
  65.             Case $IDCONTINUE
  66.             Case Else
  67.         EndSwitch
  68.     Until $lb1
  69.  
  70.     ConsoleWrite("Got mouse coords: " & $ganMouseCoords[$idxX] & ", " & $ganMouseCoords[$idxY] & "." & @CRLF)
  71.  
  72.     MouseMove($ganMouseCoords[$idxX], $ganMouseCoords[$idxY])
  73.  
  74.     MouseClick($MOUSE_CLICK_PRIMARY)
  75.     ConsoleWrite("Clicking at position, then sleeping half sec." & @CRLF)
  76.     Sleep(500)
  77.     MouseClick($MOUSE_CLICK_PRIMARY)
  78.     ConsoleWrite("Clicking at position (again), then sleeping half sec (again)." & @CRLF)
  79.     Sleep(500)
  80.  
  81.     ConsoleWrite("Sending '" & ClipGet() & "'." & @CRLF)
  82.  
  83.     AutoItSetOption ( "SendKeyDelay" , 80 )
  84.  
  85.     Send(ClipGet(), $SEND_RAW)
  86.  
  87.     ConsoleWrite("Done." & @CRLF)
  88.     Terminate()
  89.  
  90. EndFunc   ;==>main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement