OnClipboardChange IfWinActive

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
new_auhotkeyuser85
Posts: 1
Joined: 06 Jun 2023, 08:57

OnClipboardChange IfWinActive

Post by new_auhotkeyuser85 » 06 Jun 2023, 09:04

Hi, newbie here, I am trying to get this script to only work when Chrome browser is active. I tried different ways using IfWinActive but not getting any luck :( I appreciate any help on this, tyvm!

Code: Select all

#Persistent
OnClipboardChange:
Clipboard := RegExReplace(Clipboard,"htt(ps?)\://(?!customdomain\.|my\.customdomain|app.slack|sub.customdomain)(.*)","hXX$1://$2")
return
[Mod edit: Wrong subforum: Moved topic to AHK v1 help, since this is not v2 code.]

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: OnClipboardChange IfWinActive

Post by mikeyww » 06 Jun 2023, 12:00

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33
#SingleInstance
Loop {
 WinWaitActive ahk_exe chrome.exe
 OnClipboardChange("fixClip")
 SoundBeep 1500
 WinWaitNotActive
 OnClipboardChange("fixClip", 0)
 SoundBeep 1000
}

fixClip(type) {
 MsgBox 123
}

Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: OnClipboardChange IfWinActive

Post by Rohwedder » 06 Jun 2023, 12:06

Hallo,
try:

Code: Select all

#Persistent
OnClipboardChange:
IF WinActive("ahk_exe chrome.exe")
	Clipboard := RegExReplace(Clipboard,"htt(ps?)\://(?!customdomain\.|my\.customdomain|app.slack|sub.customdomain)(.*)","hXX$1://$2")
return

Post Reply

Return to “Ask for Help (v1)”