Code: Select all
^Enter::
{ if WinExist("ahk_class PotPlayer")
WinActivate
Send "^c"
if WinExist("ahk_exe WINWORD.EXE")
WinActivate
Send "^v"
Send "{Down down}"
Send "{Down up}"
WinActivate("ahk_class PotPlayer")
}
Code: Select all
^Enter::
{ if WinExist("ahk_class PotPlayer")
WinActivate
Send "^c"
if WinExist("ahk_exe WINWORD.EXE")
WinActivate
Send "^v"
Send "{Down down}"
Send "{Down up}"
WinActivate("ahk_class PotPlayer")
}
Code: Select all
^Enter::
{
if WinExist("ahk_class PotPlayer") {
WinActivate
WinWaitActive
} else
throw TargetError("PotPlayer not found")
A_Clipboard := ""
Send "{ctrl down}c{ctrl up}"
ClipWait(1)
if WinExist("ahk_exe WINWORD.EXE") {
WinActivate
WinWaitActive
} else
throw TargetError("Word not found")
Send "{ctrl down}v{ctrl up}"
Send "{Down}"
WinActivate("ahk_class PotPlayer")
}
Just tried your code. It couldn't repeat copying the timecode on the first attempt. Anyway, thank you for your quick reply.Descolada wrote: ↑22 Mar 2023, 14:38I would make the following optimizations:1) The window may not be active instantaneously after WinActive, so using WinWaitActive afterwards tends to be more reliable.Code: Select all
^Enter:: { if WinExist("ahk_class PotPlayer") { WinActivate WinWaitActive } else throw TargetError("PotPlayer not found") A_Clipboard := "" Send "^c" ClipWait(1) if WinExist("ahk_exe WINWORD.EXE") { WinActivate WinWaitActive } else throw TargetError("Word not found") Send "^v" Send "{Down}" WinActivate("ahk_class PotPlayer") }
2) Use ClipWait to verify that Ctrl+C actually copied something to clipboard.