Title

Message

Confirm

Want to earn a free DisplayFusion Pro license? We're looking for DisplayFusion translators!
<< DiscussionsReply

Running macro only if app has focus

Avatar from Gravatar.com
AlanBes
4 discussion posts
Simple script in ClipboardFusion to replace text.
But I need the macro to only run if Chrome is the focused application.
Had a look at GetMainFileByWindow and other functions but can't get them implemented into the code.
Here's a sample of the current code, and help to add a statement if a window (chrome) is the focused app will be appreciated.

Code



Just spotted this went into the DisplayFusion section - apologies for that!
May 6, 2019 (modified May 6, 2019)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Something like this should work:

Code



Note that the "return text;" line needs to either be outside of the if statement, or you have to include it in all of the if/else blocks. (all possible code paths have to return a string). You can also do "return null;" instead if you don't want to put anything back on the clipboard.
May 7, 2019 (modified May 7, 2019)  • #2
Avatar from Gravatar.com
AlanBes
4 discussion posts
Thank you replying. That's much neater than my solution.
May 7, 2019  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
No worries, glad I could help!
May 8, 2019  • #4
Was this helpful?  Login to Vote  Login to Vote
<< DiscussionsReply