Jump to content

Detect if a program is active and run a hot key set afterwards


Recommended Posts

Hi there. I would like to create a script/program that run in background and will automatically detect if MS word is running. Is so, then perform a key combination “ALT + G + PC + Enter” once (yes, merely performing key combination once). If detect activewindow=non-MS word, then will not perform such script/program.

In short, the result I want is: Run a detective script in background to determine if activewindows=ms word, then hotkeyset above and the program will not end after the script is run and will resume detecting for active windows in background.

Any ideas on where to start with? Many thx!😁

Link to comment
Share on other sites

16 hours ago, Earthshine said:

Start by reading the manual. Then actually write code. Then post it here if you need help. We’re not going to write it for you

Yea I have done the basic to make it run the key combo when I am in word... I mean in a passive way.

However I am not able to make it to run at background and let it detect "automatically" the active windows.

Any hints or method suggested?

Link to comment
Share on other sites

As a start, simply run a loop and wait for your window to get activated...

While 1
  $titel = WinGetTitle("")
  If ($titel <> "Word") Then ContineLoop
  ; run your commands

of course if your action do not close word, you'd have to prevent hammering your keys again and again into the same word instance...

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...