do something on clipboard change Only for a program

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mirHadi
Posts: 29
Joined: 18 Jul 2021, 07:36

do something on clipboard change Only for a program

27 Oct 2021, 12:27

Hello

I have potplayer running and I want to copy the subtitle to clipboard ( can be done!) and when the clipboard changes run a dictionary app and ...

but this method:

Code: Select all

#Persistent
OnClipboardChange("ClipChanged")
return

ClipChanged(Type) {
    ToolTip Clipboard data type: %Type%
    Sleep 1000
    ToolTip  ; Turn off the tip.
}

will be always active overally and whenever the clipboard changes, It runs.
I want this functionality only when the clipboard changes in potplayer focused and when it is minimized or closed I want clipboard changes do as usual.
hope It makes sense
thank you
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: do something on clipboard change Only for a program

27 Oct 2021, 13:16

Code: Select all

ClipChanged(Type){
	If !WinActive("ahk_exe potplayer.exe")  ; "!" means "NOT" in this case
		return  ; do nothing
	; otherwise:
	ToolTip Clipboard data type: %Type%
	Sleep 1000
	ToolTip ; Turn off the tip.
}
Use Window Spy to find the exact ahk_exe of the potplayer window.
mirHadi
Posts: 29
Joined: 18 Jul 2021, 07:36

Re: do something on clipboard change Only for a program

27 Oct 2021, 15:21

I did that and It works kinda!

if WinActive...... working just fine. tooltips shows up.!
if !WinActive..... not working!!!

infact in potPlayer windot it copies the subtitle word on clipboard but nothing happens then.!

PS:: sorry my bad, It is working after I restarted Potplayer. thank you

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, Google [Bot], Joey5 and 266 guests