4

Question

I have set up a "Work" and a "Home" user profile in Google Chrome.

Google Chrome user profile switching page

I'd like to switch between them with one keyboard shortcut. Is that somehow possible?

What I don't want

  1. Using a long sequence of keyboard shortcuts

    It is possible to switch the user profile with a whole sequence of keyboard shortcuts as described in this answer.

    • Ctrl+Shift+M to select the User button
    • Arrow down, Enter to select Switch person
    • Arrow left or Arrow right to select the user profile
    • Enter to select the profile

    I don't want to hit that many keys because switching profiles is an operation I perform fairly often.

  2. Starting Google Chrome with different user profiles

    Another way I don't want to do is to start Google Chrome with different parameters as described here: How to start different profiles with Google Chrome when startup?

  3. Google Chrome extensions that have their own concept of "profile"

    I'm not looking for extensions that introduce their own concept of "profile", like Profile Swapper or MultiLogin. I want to keep using the user profiles Google Chrome provides out of the box.

Possible ideas

  1. A one-mouse-click-solution would be fine, too.

  2. Perhaps, there is a Google Chrome extension that does that. I haven't found one yet.

  3. Perhaps, there is a Google Chrome extension that enables one to assign keyboard shortcuts to Google Chrome functions. I haven't found one yet.

  4. Perhaps, Google Chrome has this feature out of the box and one just needs to enable it in about:flags. I haven't found anything there yet; only Enable new profile management system.

System

  • Windows 7
  • Google Chrome 41.0.2272.89

Edit 24.03.2015: My current solution using AutoHotkey

This solution using AutoHotkey was inspired by Zvi Twersky's answer.

; Switch to user profile "Home" with Ctrl+Shift+1
#IfWinActive ahk_class Chrome_WidgetWin_1
^+1::
Send, ^+M
Send, {Down}{Enter}
Sleep, 300
Send, {Right}{Enter}
return

; Switch to user profile "Work" with Ctrl+Shift+2
#IfWinActive ahk_class Chrome_WidgetWin_1
^+2::
Send, ^+M
Send, {Down}{Enter}
Sleep, 300
Send, {Left}{Enter}
return
Lernkurve
  • 2,052

2 Answers2

2

Using AHK should help. With AutoHotkey you can remap any combination of keystrokes into one keystroke so that should help.

To remap say the M key to Arrow down+Enter you would do:

M::
Send, {DOWN}{Enter}
return
0

Please, check, if it is work for you

/**
 * Description : AutoHotKey script bring specific Chrome Profile windows to the front.
 *             : While Chrome is active press Ctrl+1 ... Ctrl+5 to activate another profile.
 * Tested with : Chrome v84
 * Freelancer  : Art G. - https://www.upwork.com/freelancers/~017155e179702d4657
 * Version     : 2020-07-17
 */

#Warn #NoEnv #SingleInstance Force

SetBatchLines -1 SetTitleMatchMode 2

GroupAdd ChromeWindow, ahk_exe chrome.exe ahk_class Chrome_WidgetWin_1

#IfWinActive ahk_group ChromeWindow ^1:: ActivateProfile("Default") ^2:: ActivateProfile("Profile 2") ^3:: ActivateProfile("Profile 3") ^4:: ActivateProfile("Profile 4") ^5:: ActivateProfile("Profile 5") #IfWinActive

ActivateProfile(profile) { static profiles := {}, hwnds := {}

If (!profiles[profile]) {
    FileRead preferences, % SubStr(A_AppData, 1, -8) "\Local\Google\Chrome\User Data\" profile "\Preferences"
    profiles[profile] := {}

    RegExMatch(preferences, "O)""name"":\s*""(.+?)""", match)
    profiles[profile]["name"] := match[1]

    RegExMatch(preferences, "O)""given_name"":\s*""(.+?)""", match)
    profiles[profile]["given_name"] := match[1]
}

WinGet hwndList, List, ahk_group ChromeWindow
Loop % hwndList {
    hwnd := hwndList%A_Index%
    If (!hwnds[hwnd]) {
        title := Acc_ObjectFromWindow(hwnd).accName
        RegExMatch(title, "O)^.+Google Chrome . .*?([^(]+[^)]).?$", match)
        hwnds[hwnd] := match[1]
    }

    If (hwnds[hwnd] == profiles[profile]["name"] || hwnds[hwnd] == profiles[profile]["given_name"]) {
        WinActivate ahk_id %hwnd%

        For hwnd In hwnds {
            If (!WinExist("ahk_id" hwnd))
                hwnds.Delete(hwnd)
        }

        Return
    }
}

Run chrome.exe --profile-directory="%profile%"

}

Acc_Init() { static h := DllCall("LoadLibrary", Str,"oleacc", Ptr) }

Acc_ObjectFromWindow(hwnd, objectId := 0) { static OBJID_NATIVEOM := 0xFFFFFFF0

objectId &= 0xFFFFFFFF
If (objectId == OBJID_NATIVEOM)
    riid := -VarSetCapacity(IID, 16) + NumPut(0x46000000000000C0, NumPut(0x0000000000020400, IID, "Int64"), "Int64")
Else
    riid := -VarSetCapacity(IID, 16) + NumPut(0x719B3800AA000C81, NumPut(0x11CF3C3D618736E0, IID, "Int64"), "Int64")

If (DllCall("oleacc\AccessibleObjectFromWindow", Ptr,hwnd, UInt,objectId, Ptr,riid, PtrP,pacc:=0) == 0)
    Return ComObject(9, pacc, 1), ObjAddRef(pacc)

}

Argimko
  • 129
  • 3