Opening two Google People Profiles

Just bought Keyboard Maestro, read the initial tutorials and I’m trying to set up my first macro and I’m running into logic issues.

Using Google Chrome I work with two People Profiles. One profile for work and one profile for my personal life.

What I want to do I create a Keyboard Macro that activates Google Chrome and opens up one chrome window for my work profile and one chrome window for my personal profile.

I was trying to experiment with Conditional flows but I have been unable to figure out how to tell Keyboard Maestro which Chrome Profile opened first?

Is this even possible?

Hopefully, my question made sense. Any feedback is greatly appreciated. Thanks!

Hey @wizardelite,

It would be a good idea if you'd post your macro.

How to Post Your Macro to the Forum

Is this possible? Yes.

Give us more of an idea of what you're trying to accomplish, and we'll be able to provide more help.

My big question to you right now is how you're opening windows with different accounts.

Here's how you can use AppleScript to test what account is open in a window.

set jsCmdStr to "
document.getElementsByClassName('gb_b gb_ib gb_R')[0].outerHTML
"

tell application "Google Chrome"
   tell front window's active tab
      set jsResult to execute javascript jsCmdStr
   end tell
   
   if jsResult contains "Christopher Stone" then
      set personalAccountWindowID to id of front window
   end if
   
end tell

The ID of a window stays with it while it's open, so you can reliably refer to widows by their ID.

-Chris

Do you know how to do this manually using URLs for each of your profiles?

If so, then the solution is easy:

image

I’m completely new at this. I have a basic idea of how the application works. I just didn’t know how to work out the logic of what I want to do. If I can figure out the logic of what needs to be done, I can then learn on my own how to carry it out.

Here is what I want to do.

Open my Work and Personal Profiles for Google Chrome at the start of my workday.

If Work profile opens first then open up the Personal Profile…

Here is where I get stuck with the conditional flow.

Or, if Personal Profile opens first then open up work profile.

Then as I was trying to figure out the logic I realized I had no clue on how to tell Keyboard Maestro which profile actually open first.

Hopefully, that gives you a better idea of the issue and I greatly appreciate what feedback you have provided.

Thanks!

I don’t but that I something I will look into. I didn’t even know that each profile has a specific URL. Thanks for the suggestion.

I believe there is, but I can't test because I have only one Google Profile. You might try searching for something like "chrome url open profile (or person)"

I found some old articles that showed how to get the URL, but it did not appear on my system, probably because I have only one profile.

Turns out to be even easier than I thought -- I overlooked the obvious.
You should have a People menu in the Chrome Browser, like this:

image

The first one will be your default Person/Profile.

So, all you need to do is this:

Activate a Specific Application action.
Select or Show a Menu Item action.

image

where the Menu Item will be the second Person in the menu.
When Chrome opens, it will auto-open to the default Person.

Let us know if this works for you.

Hey Chris,

This task should be very simple, but it's not. Discovering how is no simple task either.

This macro will do what you want – launch Chrome with two different profiles in two different windows.

[EDIT: Removed last open -a 'Google Chrome' command from shell script due to a syntax error and subsequent misbehavior of the app when the error was fixed.]

[This macro only works properly if Chrome is not already running – the macro in post #14 fixes this.]

Google Chrome -- Open with Two Profiles v1.00.kmmacros (6.2 KB)

To discover the actual names Chrome uses for your profiles do this:

Open a specific profile in Chrome. Then input this line into the URL field and hit <return>.

chrome://version

Then look for “Profile Path” in the result.

Profile Path	/Users/myUserName/Library/Application Support/Google/Chrome/Default

My profile is named “Christopher”, but Chrome says it's “Default”.

My other profile is specifically named “Linda”, but Chrome says it's “Profile 1”.

So you'll have to do a little detective work.

You can remove the URLs from the commands in the Execute a Shell Script action IF you want to open windows WITHOUT a destination URL.

Rename the profile-directory arguments as needed.

The final open -a command brings Chrome to the front.

-Chris

Yes, Chrome does have that and that is what I started off with. See attached image for reference.

"Chris" is my Work Profile while "Christopher" is my Personal Profile.

Here is the problem that I ran into. The profile that opens up when you open Chrome is never consistent.

Sometimes, my Work profile is the one that opens first and sometimes my Personal Profile is the one that opens first.

Thanks your guys help I've learned that each profile has it's own path.

Now, I just need to figure out how to say

If Work Profile is open, open the Personal Profile and If Personal Profile is open, open the Work Profile.

However, looking at another post here it appears that I can just run a shell script to open both profiles at the same time.

Either way I greatly appreciate all of your help on this request.

That is strange. any idea why?

So, I'll use my two profiles, and you can translate to yours:

MACRO:   Open Chrome Window for Person [Example]


#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/e/4/e461f578c7ef62ebe0b7c09841e24418450d7677.kmmacros">Open Chrome Window for Person [Example].kmmacros</a> (3.7 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---



![image|458x852](upload://p5wq9nIW8fuXLag2e0e6SXgapB9.jpg)

---

This worked well for me.
Will it work for you?

Thank you so much for helping me out on this. Looks like I need to brush up on my shell scripting.

Working out your macro that you created for me and I had a couple questions. It was much easier for me to record a video.

It’s in regards to two notifications that I received.

Thanks again.

My theory is the last profile that you close out is the first profile that will open.

It’s time for me to head home for the day. So I will test out your macro when I get home.

Greatly appreciated.

I am really loving Keyboard Maestro. I definitely have a lot to learn about this utility.

The problem you were having is that the "try" button at the bottom is just to try ONE action. To try, or actually run, the entire Macro, use the button at the top:

image

Hey Chris (@wizardelite),

Okay. It seems I missed a single quote at the end of the last shell command, and that was throwing an error.

I didn't notice, because I had the Execute a Shell Script action set to NOT display errors.

image

(The pop-up menu comes from the little gear icon in the upper-right-corner of the action.)


I'll fix the error in the original macro in a bit

This presents a bit of a problem, because I can't get the shell script to bring Chrome to the fore without opening yet another window.

I have the same problem when AppleScripting it.

So I've resorted to using Keyboard Maestro's Activate a Specific Application action after the shell script opens the two profile windows in the background.

I've also moved the URLs for each profile into variables for easier manipulation. (Leave them blank if you don't want the profile windows to have a page loaded.)

I've also used an IF-THEN action to bring Chrome to the front IF it's running already.

If it is NOT running then it will launch and open your two profile pages.

Google Chrome -- Open with Two Profiles v1.01.kmmacros (7.9 KB)

Some of this behavior may not be to your liking, but I've built it this way to give you an idea of what can be done – and you can make changes as desired.

You wanted to know about logs – see the “Open Logs Folder” menu item in the Help Menu.

See also this macro:

Open the Keyboard Maestro Engine Log in the Console or BBEdit

Take note of the Keyboard Maestro Wiki.

Many menu items link to their corresponding help page in the wiki when you hold down the key.

Right-Clicking on actions (or using the gear menu) will give you access to a “Help” sub-menu-item that also takes you to the wiki.

Okay, you’ve got a lot to chew on for a while.

Don't hesitate to ask questions if you get stuck on anything for more than 15-30 minutes.

-Chris

I believe the actual behavior of the [TRY] button is as follows:

  • ALL selected actions are run.

  • If none are selected then ALL actions are run.

-Chris

THANK YOU! This worked perfectly.

One thing that is obvious is that I need to brush up on my shell scripting or start with Applescript.

Which one do you recommend I start with first?

It depends upon what your needs are. For application automation the answer is AppleScript and perhaps JavaScript for Automation if you know any JavaScript.

-Chris

Keyboard Maestro is easier to learn than either. The solution to your problem required only 4 of the basic KM Actions.

I use KM, AppleScript, JXA, and a little shell scripting. I choose the one that gets the job done and is easiest to write/maintain, but I often use a combination. Scripting may offer some performance advantage, but with todays very fast HW, I rarely see a material difference.