Conditional Open App

Discussion, questions and support.
Post Reply
spotticus
Posts: 9
Joined: Oct 15th, ’19, 17:44

Post by spotticus » Oct 15th, ’19, 18:44

How do I make it so that if I hit F11 it will open Chrome, BUT if Chrome is already open it will just make it pop up and be the active window? Thanks!
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Oct 16th, ’19, 20:34

Shortcut: F11
Type: Command

Code: Select all

If Not WinExist("ahk_exe chrome.exe")
	Run, chrome.exe
Else
	WinActivate, ahk_exe chrome.exe
spotticus
Posts: 9
Joined: Oct 15th, ’19, 17:44

Post by spotticus » Oct 17th, ’19, 15:11

That works great. I tried to run the same script for Outlook (using F10):

If Not WinExist("ahk_exe outlook.exe")
Run, outlook.exe
Else
WinActivate, ahk_exe outlook.exe

BUT it still opens a new instance of Outlook everytime I hit F10. What did I do wrong?
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Oct 18th, ’19, 11:17

Code: Select all

If Not WinExist("Inbox - Outlook")
	Run, outlook.exe
Else
	WinActivate, Inbox - Outlook
You can find the window information using Tools/Window Information.
spotticus
Posts: 9
Joined: Oct 15th, ’19, 17:44

Post by spotticus » Oct 18th, ’19, 21:57

That still creates a new instance of Outlook when I run it.
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Oct 23rd, ’19, 16:18

Then adjust the code with your window name (use Tools/Window information tool).
spotticus
Posts: 9
Joined: Oct 15th, ’19, 17:44

Post by spotticus » Oct 23rd, ’19, 19:00

I am very sorry, but I don't understand what you mean.
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Oct 23rd, ’19, 20:03

No problem. Open the Windows Information tool from Tools/Window information menu. Then move the mouse to your open main Outlook window. Read the information from the tool. Replace the "Inbox - Outlook" parts in the code with a window text name.

You can also post or send us a screenshot of the Window information.
spotticus
Posts: 9
Joined: Oct 15th, ’19, 17:44

Post by spotticus » Oct 25th, ’19, 22:37

That worked!!! Thank you!!!!!!
Post Reply