Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
- ;http://creativecommons.org/licenses/by-sa/4.0/
- ; Copy text to clipboard, e.g. out of Google/Yandex translate
- ; Run this, follow the instructions.
- #include <AutoItConstants.au3>
- #include <MsgBoxConstants.au3>
- Global Const $gsOurTitle = "Keystroke Paste Paster"
- HotKeySet("{ESC}", "Terminate")
- Global $ganMouseCoords[2]
- Global Const $idxX = 0, $idxY = 1
- main()
- Terminate()
- Exit
- Func Terminate()
- ConsoleWrite(@CRLF & "Autoit script ended." & @CRLF & @CRLF)
- Exit
- EndFunc ;==>Terminate
- Func main()
- Local $ls1 = ""
- Do
- $lb1 = False
- $ls1 = "Running: " & @AutoItExe & @CRLF
- $ls1 &= @CRLF & @TAB & " " & @ScriptDir & "\" & @ScriptName & @CRLF
- $ls1 &= @CRLF & "Working from: " & @WorkingDir & @CRLF & @CRLF
- $ls1 &= @CRLF
- $ls1 &= @CRLF
- $li1 = MsgBox($MB_OKCANCEL + $MB_ICONQUESTION + $MB_TOPMOST + $MB_TASKMODAL _
- + $MB_DEFBUTTON1 _
- , $gsOurTitle, $ls1 & @CRLF & "Place mouse over clipboard keystroke insertion point." & @CRLF & @CRLF & "Press Enter. [equals 'OK'].", 0)
- $ganMouseCoords = MouseGetPos()
- Switch $li1
- Case $IDTIMEOUT
- Case $IDOK
- $lb1 = True
- Case $IDCANCEL
- ConsoleWrite("Cancelled." & @CRLF)
- MsgBox($MB_OK + $MB_ICONINFORMATION + $MB_TOPMOST + $MB_TASKMODAL _
- + $MB_DEFBUTTON1 _
- , $gsOurTitle, "Cancelled.", 2)
- Terminate()
- Case $IDABORT
- Case $IDRETRY
- Case $IDIGNORE
- Case $IDYES
- Case $IDNO
- Case $IDTRYAGAIN
- Case $IDCONTINUE
- Case Else
- EndSwitch
- Until $lb1
- ConsoleWrite("Got mouse coords: " & $ganMouseCoords[$idxX] & ", " & $ganMouseCoords[$idxY] & "." & @CRLF)
- MouseMove($ganMouseCoords[$idxX], $ganMouseCoords[$idxY])
- MouseClick($MOUSE_CLICK_PRIMARY)
- ConsoleWrite("Clicking at position, then sleeping half sec." & @CRLF)
- Sleep(500)
- MouseClick($MOUSE_CLICK_PRIMARY)
- ConsoleWrite("Clicking at position (again), then sleeping half sec (again)." & @CRLF)
- Sleep(500)
- ConsoleWrite("Sending '" & ClipGet() & "'." & @CRLF)
- AutoItSetOption ( "SendKeyDelay" , 80 )
- Send(ClipGet(), $SEND_RAW)
- ConsoleWrite("Done." & @CRLF)
- Terminate()
- EndFunc ;==>main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement