3

I am new to AHK and been trying to fidget around with it for quite some time, what I need to do is open a specific profile of Google Chrome when a key is pressed and if it's open close it when the same key is pressed. I tried many things but can't quite figure out how to do it, this is what I have right now.

PgDn::
    Process, Exist, chrome.exe
If ErrorLevel <> 0
    Process, Close, chrome.exe
Else    
    Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1"
return

This opens up the chrome to a profile I want but when I close press the button again it closes any and every chrome window open. I understand that's because I close the chrome.exe process, I cannot figure out how to close that specific profile.

Ultimately what I want to do is when the Page Down key is pressed

If Chrome Profile 1 is not opened, open it.
If Chrome Profile 1 is minimized, maximize it.
and if Chrome Profile 1 is opened and maximized, close it.

I would really appreciate if someone could assist with this.

Cerbrus
  • 70,800
  • 18
  • 132
  • 147
Adam Johns
  • 61
  • 2

1 Answers1

1

AHK's Run command has a parameter named: OutputVarPID.

you can use this to store the process id of the started chrome instance in a variable, which you can then pass to your Exit command.

Cerbrus
  • 70,800
  • 18
  • 132
  • 147