Pasting with SendMessage in AutoHotkey

The other day I demonstrated how to send “paste” to a window instead of sending keystrokes.

As with all things, there are multiple ways to achieve your goal.  In this version I demonstrate Pasting with SendMessage in AutoHotkey to paste on “some” windows.


;~by jeeswg https://www.autohotkey.com/boards/viewtopic.php?p=271514  (tweaked by Joe Glines)
ClipSave := ClipboardAll ; Save Clipboard
Clipboard := “this is from my script” ; Update Clipboard with Text to send
ControlGetFocus, vCtlClassNN, A
ControlGet, hCtl, Hwnd,, % vCtlClassNN, A
SendMessage, 0x302,,,, % “ahk_id ” hCtl ;WM_PASTE := 0x302
Sleep, 100
Clipboard := ClipSave ; Restore Clipboard
return

Joe Glines

Joe Glines spent 20 years as a corporate data scientist before going all in on automation. He now uses AI to build automation in AutoHotkey, Python and Rust, has made 1,500+ tutorials, and runs the-Automator with a small team that has shipped 450+ time-saving tools.

Comments are closed.