Autohotkey - Chrome Profiles in Alphabetical Order

Applies To:
  • MS Windows 10 Pro v10.0.18362 Build 18362 (64-bit)
  • Google Chrome Browser v79.0.3945.88 (Official Build) (64-bit)
  • AutoHotkey v1.1.30.01
This is an article to create a standalone application which lists all the Google Chrome Profiles on your Windows 10 workstation in alphabetical order.

This program will be redundant if Google ever update their Chrome browser to list the multiple profiles in alphabetical order like it used to be... but to date they have not. So I made a program that lists the profiles in alphabetical order and can be double-clicked to open the Chrome browser with that profile.

So you will need to be able to run AutoHotkey or create executables from an AHK file. Here is the code that creates a GUI with a ListView with rows that can be double-clicked to open the profile. As an overview:
  1. Setup a standard AutoHotkey GUI
  2. Loop through Google Chrome Profile folders named "Profile 1", "Profile 2", etc.
  3. Scan the preferences file for JSON key "name" and extract value.
  4. Hide the first column in the list view (contains "Profile 1", "Profile 2", ...)
  5. Sort the second column (contains "Joes Personal Profile", "Joes Work Profile", etc)
  6. Create subroutine for when listview row is double-clicked to open Chrome Browser with selected Profile.
SendMode Input  
SetWorkingDir %A_ScriptDir%  
#SingleInstance force

; --------------------------------------------------------------------------------------
; Set program Defaults
; --------------------------------------------------------------------------------------

Title   := "Joes Chrome Profile Opener"
Desc    := "This program will list all the Google Chrome profiles available from your login."
Version := "1.0"
Width   := 400
Height  := 800
BgColor := "FFFFFF"
MarginX := 2
MarginY := 2
Options := "+Caption +Border +OwnDialogs"
TempDir := "C:\Windows\Temp"

; --------------------------------------------------------------------------------------
; Create GUI

Gui, New, %Options%, %Title% v%Version%
Gui, Font, s12, Verdana
Gui, Color, %BgColor%
Gui, Margin, %MarginX%, %MarginY%
Gui, Add, ListView, w396 h775 gOpenProfile -Hdr +Grid, Profile|Client
ProfilePath := "C:\Users\" A_UserName "\AppData\Local\Google\Chrome\User Data\Profile*"
Loop, Files, %ProfilePath%, D
    FullPathArray := StrSplit(A_LoopFileLongPath, "\")
    ThisFolder := FullPathArray[9]
    PreferenceFile := A_LoopFileLongPath "\Preferences"  ; Get the preferences file from the profile
    FileRead, OutputContent, %PreferenceFile%
    NameStart := InStr(OutputContent, """name"":""")+8
    NameEnd := InStr(OutputContent, """", false, NameStart+1)
    NameLength := NameEnd - NameStart
    ClientName := SubStr(OutputContent, NameStart, NameLength)
    LV_Add("", ThisFolder, ClientName, A_LoopFileLongPath)
LV_Modifycol(1, 0)  ; hide the first column
LV_ModifyCol(2, "Sort")  ; sort the second column (profile names)
Gui, Font, s8, Verdana
Gui, Add, StatusBar,, Ready.
Gui, Show, w%Width% h%Height% x10 y10

; --------------------------------------------------------------------------------------
; Subroutine: OpenProfile

    if (A_GuiEvent = "DoubleClick")
        LV_GetText(ThisFolder, A_EventInfo, 1)
        ThisPathToOpen := """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" --profile-directory=""" ThisFolder """"
        Run, %ThisPathToOpen%

; --------------------------------------------------------------------------------------
; Closing subroutine


Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.