AutoHotKey script for HYPER key toggling OneCommander

72 views
Skip to first unread message

Haakon Storm Heen

unread,
Sep 26, 2023, 1:01:35 PM9/26/23
to OneCommander

This script remaps Capslock + Space to toggle OneCommander.
Caps lock is disabled when this AHK script is running.
AHK scripts can be compiled to .exe and started upon login.

- If OC isn't running, hyper+space launches it via a shortcut .lnk file.
- If it is already running and visible, it minimizes OC.
- If it is minimized, OC is activated, restored to its old position.

So it works in effect by toggling OneCommander on and off, with one hand,
using caps lock + space bar.

Replace the path to the .lnk with your own .lnk or path to OneCommander.exe:

#Requires AutoHotkey v2.0
; recommended for performance and compatibility with future autohotkey releases.
#UseHook
#SingleInstance force

InstallKeybdHook()

SendMode "Input"

;; deactivate capslock completely
SetCapslockState("AlwaysOff")

global CapslockIsDown := false

SetTimer(HandleCapslock, 50)

HandleCapslock() {
    global CapslockIsDown

    if (!CapslockIsDown && GetKeyState("Capslock", "P")) {
        CapslockIsDown := true
        Send("{Ctrl DownTemp}{Shift DownTemp}{Alt DownTemp}{LWin DownTemp}")
    } else if (CapslockIsDown && !GetKeyState("Capslock", "P")) {
        CapslockIsDown := false
        Send("{Ctrl Up}{Shift Up}{Alt Up}{LWin Up}")
        if (A_PriorKey == "Capslock") {
            Send("{Esc}")
        }
    }
}

Hotkey "~Capslock & Space", ToggleOneCommander

ToggleOneCommander(ThisHotkey)
{
    app := A_WinDir "\System32\" proc := "OneCommander.exe"
   
    If WinExist("ahk_exe" proc)
        If !WinActive() {
            WinActivate
        } Else
        {
            WinMinimize
        }
    Else
        {
            Run 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\OneCommander.lnk'
        }
    Return
}

Kyle Condon

unread,
Sep 29, 2023, 3:47:26 PM9/29/23
to OneCommander
Awesome, thanks for this. I assume I can replace the path to the actually path I have OneCommander at with just a double quoted path after the "app :=" part right? Haven't delved too deep into AHK yet so not sure of the exact syntax.
Reply all
Reply to author
Forward
0 new messages