The script is to copy selected text and pasted it to the window I have chosen with a hotkey stated in the script
V1 script
Code: Select all
+!c:: ; alt+shift+c to copy to the selected window
If !WinTag
{
MsgBox, , Capsy CopyToApp, You pressed the combination of CopyToApp. First, tag a target window in NotePad
, WordPad or a GUI edit field.`r`r 1
. Activate window`n 2
. Press Ctrl+Win+Shift+Z
return
}
OldClipboard:= ClipboardAll
; Clipboard:= ""
sleep 500
Send, ^c ;copies selected text
ClipWait,1
If ErrorLevel
{
MsgBox, , Capsy CopyToApp, No text selected!
return
}
IfWinExist, %winTitlePart%
{
;Save the currently active window title
WinGetTitle, actWin, A
; If OneNote is not active, activate it now
IfWinNotActive, %winTitlePart%
WinActivate, %winTitlePart%
; Check again, if ON active then paste else error
IfWinActive, %winTitlePart%
{
Send, ^v`r`r ; Use sendplay to avoid unexpected interactions with Win key
; Switch window back to previously active
WinActivate, %actWin%
}
sleep 500
}
Else
{
MsgBox, Window < "%winTitlePart%" > does not Exist!
}
Clipboard := OldClipboard
return
^#+z:: ;Ctrl+win+shift+z tag a window as a copy destination
; Click, %A_CaretX%, %A_CaretY%
MouseGetPos, , , WinTag, Control
WinGetTitle, winTitlePart, ahk_id %WinTag%
MsgBox, , Capsy CopyToApp, " %winTitlePart% " is tagged as the destination window!`r - Press < Alt+Shift+C > to copy selection to this app.`r - Press < Ctrl+Win+Shift+R > to reset.
return
^#+r:: ;Ctrl+win+shift+r tag a window as a reset destination
WinActivate, ahk_id %WinTag%
MsgBox, , Capsy CopyToApp, CopyToApp windows is reset!, 3
WinTag:=""
return
Code: Select all
+!c:: ; alt+shift+c to copy to the selected window
{ ; V1toV2: Added bracket
If !WinTag
{
MsgBox("You pressed the combination of CopyToApp. First, tag a target window in NotePad , WordPad or a GUI edit field.`r`r 1 . Activate window`n 2 . Press Ctrl+Win+Shift+Z", "Capsy CopyToApp", "")
return
}
OldClipboard:= ClipboardAll()
; Clipboard:= ""
Sleep(500)
Send("^c") ;copies selected text
Errorlevel := !ClipWait(1)
If ErrorLevel
{
MsgBox("No text selected!", "Capsy CopyToApp", "")
return
}
if WinExist(winTitlePart)
{
;Save the currently active window title
actWin := WinGetTitle("A")
; If OneNote is not active, activate it now
if !WinActive(winTitlePart)
WinActivate(winTitlePart)
; Check again, if ON active then paste else error
if WinActive(winTitlePart)
{
Send("^v`r`r") ; Use sendplay to avoid unexpected interactions with Win key
; Switch window back to previously active
WinActivate(actWin)
}
Sleep(500)
}
Else
{
MsgBox("Window < `"" winTitlePart "`" > does not Exist!")
}
A_Clipboard := OldClipboard
return
} ; V1toV2: Added Bracket before hotkey or Hotstring
^#+z:: ;Ctrl+win+shift+z tag a window as a copy destination
; Click, %A_CaretX%, %A_CaretY%
{ ; V1toV2: Added bracket
MouseGetPos(, , &WinTag, &Control)
winTitlePart := WinGetTitle("ahk_id " WinTag)
MsgBox("`" " winTitlePart " `" is tagged as the destination window!`r - Press < Alt+Shift+C > to copy selection to this app.`r - Press < Ctrl+Win+Shift+R > to reset.", "Capsy CopyToApp", "")
return
} ; V1toV2: Added Bracket before hotkey or Hotstring
^#+r:: ;Ctrl+win+shift+r tag a window as a reset destination
{ ; V1toV2: Added bracket
WinActivate("ahk_id " WinTag)
MsgBox("CopyToApp windows is reset!", "Capsy CopyToApp", "T3")
WinTag:=""
return
} ; V1toV2: Added bracket in the end