The CopyRefTagWin.ahk script copies text to a pre-targeted Notepad, WordPad, or GUI Edit window. To tag a reference target window, mark either a NotePad, WordPad, or GUI Edit field as the target by activating the window, clicking in the target field, and pressing Ctrl+Win+Alt+T. Then move to any source window, highlight the targeted text, and press Ctrl+Alt+C.
I offer more specific how-to information in "Tricks for Tracking and Activating Target Process Windows" and "Channeling Text to a Tagged Window."
Note: While I originally used the technique to collect reference data from multiple sources without the tedious window hopping, CopyRefTagWin.ahk works equally as well for testing AutoHotkey code using GeekDude's AutoHotkey CodeQuickTester. (I discuss this tool in “Save Time with CodeQuickTester for Testing and Modifying Scripts.”)
CopyRefTagWin.ahk Code:
Code: Select all
^!c::
If !WinTag
{
MsgBox, Tag a target window in NotePad
,`rWordPad or a GUI edit field:`r`r 1
. Activate window`n 2
. Press Ctrl+Win+Alt+T
Return
}
OldClipboard := ClipboardAll
Clipboard := "" ;clears the Clipboard
SendInput, ^c
ClipWait 0 ; pause for Clipboard data
If ErrorLevel
{
MsgBox, No text selected!
Return
}
Control, EditPaste, %Clipboard% `n`n ,%control%, ahk_id %WinTag%
; To replace text (rather than add), use the following ControlSetText command:
; ControlSetText , %Control%, %Clipboard%, ahk_id %WinTag%
ToolTip , Text inserted into %WinTitle%`rControl: %control%!
Sleep, 3000
ToolTip
Clipboard := OldClipboard
Return
^!#t::
Click, %A_CaretX%, %A_CaretY%
MouseGetPos, , , WinTag, Control
WinGetTitle, WinTitle, ahk_id %WinTag%
MsgBox The "%WinTitle%" window is tagged!`rUnique ID: %WinTag%`rControl: %Control%`rCtrl+Win+Alt+R to activate.
Return
^!#r::
WinActivate, ahk_id %WinTag%
Return
- Tag the window to receive text (Ctrl+Win+Alt+T). Must activate the window first.
- Copy text from any other app directly into the tagged window by selecting the desired text and executing the Ctrl+Alt+C Hotkey combination.
- Return to the tagged window (Ctrl+Win+Alt+R) to process text or, as in the case of a tagged “CodeQuickTest” window, run the copied code.
Use Ctrl+Win+Alt+R to return to the tagged window.