Anyone successful in getting the main notetaking window activated using AHK? The open vault window is the one that’s getting brought up by AHK every time I invoke WinRestore.

; Launch Obsidian Ctrl + Shift + (with consideration to multiple computers)

^+`::

PathToApp = C:\Users%A_UserName%\AppData\Local\Obsidian ; add this workaround because FileExist does not evaluate %A_xxx% variables

Process, Exist, “Obsidian.exe” ; Sets ErrorLevel variable to processID

if(ErrorLevel)

{

if(WinActive("ahk_exe Obsidian.exe"))

{

    ; WinMinimize, ahk_exe "Obsidian.exe"

    WinMinimize, Title, "Obsidian.exe"

}

else

{

    ;WinActivate, ahk_exe "Obsidian.exe"

    ;WinRestore, ahk_exe "Obsidian.exe"

    WinActivate, ahk_exe "Obsidian.exe"

    WinRestore, ahk_exe "Obsidian.exe"

}

}

else

{

if(FileExist(PathToApp))

{

    Run "C:\Users\%A_UserName%\AppData\Local\Obsidian\Obsidian.exe"

}

else

{

    MsgBox Check if Obsidian is installed.

}

}

return
`

I have a script for activating a specific vault, you can check them out, I am not very good with AHK, I can’t at this point explain anything else.

; This will activate obsidian, if not already open, it will open it & run the command for quick add plugin.
; This is one hotkey which I am able to get to work every time in any location whatsoever
^q::
WinActivate, i) Obsidian
Run “obsidian://advanced-uri?vault=my_vault_name_here&commandname=QuickAdd: Run QuickAdd”
return

; It will activate it & run the command for quick capture to daily notes.
; Whenever Chrome is active, this doesn’t seem to work all the time.
^Capslock::
Send, !o
Send, ^+d
return

; It will activate it & run the command for quick capture to workbench
; Whenever Chrome is active, this doesn’t seem to work all the time.
^!x::
Send, !o
Send, ^+x
return

; This will activate the obsidian window & if not open it will open obsidian & activate it
!o::
WinActivate, i) Obsidian
Run “obsidian://advanced-uri?vault=my_vault_name_here”
return

2 Likes

This is great. Thanks so much @Nihit !

1 Like

I like that this thread exists! I’d like to see more