Autohotkey ahk power control script etc/

AutoHotkey is a game-changer for automating repetitive tasks, and with a well-crafted script, you can transform your workflow. Below, we dive into a powerful AutoHotkey script packed with hotkeys designed to streamline media control, window management, file access, and more. This script, an enhanced version combining the best of two iterations, includes both everyday shortcuts and specialized commands for power users. Whether you’re toggling apps, controlling music, or pulling random content, these hotkeys have you covered. Let’s break them down by category!

Media Control: Master Your Music and Videos

The script offers a suite of hotkeys for controlling media playback, primarily focused on foobar2000, a popular audio player, and video players like mpv and VLC.

  • F9: Play or pause the main foobar2000 instance. Perfect for quick music control.
  • Shift+F9: Play or pause an alternate foobar2000 instance (e.g., at D:\foobar2000b\). Great for managing multiple playlists.
  • F10/F11: Skip to the previous or next track in foobar2000.
  • Ctrl+MButton / Ctrl+XButton2: Play a random track in foobar2000, adding spontaneity to your listening.
  • Shift+Volume Up/Down: Seek forward or backward by 1 second in foobar2000, ideal for precise scrubbing.
  • Ctrl+Volume Up/Down: Seek by 10 seconds for faster navigation.
  • Ctrl+Alt+WheelUp/Down: Set foobar2000 volume to 0 dB or -12 dB, respectively, for quick volume adjustments.
  • Alt+6: Toggle Discord Rich Presence in foobar2000 to show off what you’re listening to.
  • Ctrl+Alt+V: Resize and move mpv, VLC, or Picture-in-Picture windows to a secondary monitor for distraction-free viewing.
  • Alt+9: Position Agent DVR (a surveillance tool) on the secondary monitor.
  • F5: Move multiple media windows (mpv, VLC, SunVox, etc.) to the secondary monitor with precise coordinates, optimizing your multi-monitor setup.
  • AppsKey+Z / AppsKey+J: Play the newest video in the D:\vid\ folder using mpv with dynamic audio normalization, automatically setting the audio device to RME ADI-2 Pro.

Window and Application Management: Seamless Navigation

Switching between apps and managing windows is a breeze with these hotkeys, designed to keep your workspace organized.

  • MButton & XButton1: Toggle between Firefox and Pale Moon browsers.
  • XButton1: Switch between Renoise and Ableton Live, perfect for music producers.
  • AppsKey+B: Toggle between Betterbird and Thunderbird email clients.
  • AppsKey+P: Switch between Notepad++ and VSCodium for coding or note-taking.
  • AppsKey+9: Alternate between WinSCP and FileZilla for file transfers.
  • NumpadDiv: Toggle between foobar2000 and ConEmu (a terminal emulator).
  • NumpadMult: Switch between foobar2000 and Firefox.
  • AppsKey+, / AppsKey+. / AppsKey+/: Activate main, alternate, or third foobar2000 instances, respectively.
  • AppsKey+N / F / U / R / M / K / I: Toggle or tab through QOwnNotes, Firefox, SumatraPDF, Renoise, BowPad, KeePass, or a Raspberry Pi console, respectively, with Alt+Tab fallback if already active.
  • Shift+NumpadAdd / Div / Sub: Activate Renoise, a PHP book in SumatraPDF, or SunVox, respectively.
  • Shift+NumpadMult: Set display frequency to 280Hz and activate Sven Co-op, optimizing for gaming.
  • Ctrl+Win+T: Toggle AlwaysOnTop for the active window, with a visual flash to confirm.
  • Alt+Numpad1–4: Switch to virtual desktops 1–4 (restored from the old script, using the VD library).
  • Ctrl+Win+Alt+Left/Right: Move the active window to the previous or next virtual desktop (restored).

File and Folder Access: Instant Access to Your Data

These hotkeys open or activate specific folders, streamlining file management.

  • AppsKey+V: Open or activate the D:\vid folder (Videos).
  • AppsKey+Q: Access the D:\windows\Pictures folder.
  • Win+Shift+E: Open the D:\ drive.
  • Win+Shift+U: Access the C:\Users\sb\AppData folder.
  • AppsKey+1 / L / ; / C / T / G / H / A: Open folders like D:\server, AppData\Local, AppData\Roaming, D:\bat, D:\rex\test, D:\bat\game, D:\windows\docs\html, or D:\apps (Downloads), respectively.
  • Shift+Ctrl+P: Copy the active File Explorer path to the clipboard.

System and Display Control: Fine-Tune Your Setup

Manage power settings, display frequency, and system inputs with ease.

  • Alt+NumpadSub / Alt+F1: Set display frequency to 60Hz.
  • Alt+NumpadAdd / Alt+F2: Set display frequency to 280Hz for high-refresh-rate monitors.
  • Ctrl+Alt+NumpadAdd: Switch to High Performance power mode with a tray tip reminder to check speakers.
  • Win+Shift+NumpadAdd: Set Balanced power mode and launch HomeSafe View (a surveillance app) if not running.
  • Alt+Win+M: Close HomeSafe View, switch to Power Saver mode, log the change, and turn off monitors.
  • Win+M: Turn off monitors instantly.
  • Ctrl+Alt+Win+Pause: Block keyboard and mouse input for security.
  • AppsKey+Pause: Unblock input, releasing modifier keys.
  • Win+N / , / . / ‘: Open Windows settings for Night Light, Updates, Taskbar, or Graphics, respectively.
  • Win+[: Launch the Windows Volume Mixer.
  • Alt+Win+N: Open today’s SDRSharp recordings folder, or activate it if open (restored).
  • Alt+Win+8 / 9: Open recent or yesterday’s SDRSharp recordings in Audacity (restored).

Clipboard and Text Manipulation: Boost Your Typing

These hotkeys automate text input and clipboard processing for efficiency.

  • Shift+Ctrl+Alt+D / F / H / G: Paste timestamps in various formats (e.g., full date-time, date only, time with day, or a formatted ChatSounds notice).
  • Alt+Win+T / Y / 2: Paste compact timestamp, date, or hyphenated date.
  • Alt+Win+R: Append the clipboard content to a Reddit RSS feed URL.
  • Alt+W / Shift+Ctrl+Alt+V / B: Wrap clipboard content in double or single quotes and paste.
  • Shift+Ctrl+V: Remove newlines from the clipboard and paste.
  • Ctrl+Alt+F11: Process the clipboard to remove specific words, normalize spaces, and write to ChatSoundsnewFR.txt, then run a bash script.
  • F7: Copy the active Edge tab’s title and URL to the clipboard.

Content Randomization: Add Some Fun

Pull random content from predefined lists for inspiration or entertainment.

  • Alt+Win+V / , / U / B / I: Open random Max 8 patcher, Renoise project, Max gen file, Max help patcher, or Max example patcher.
  • Alt+Win+F7 / 3: Send a random Bible verse or BIP 39 word.
  • Win+B: Open a random ebook from a list.
  • Alt+Capslock: Open a random URL in Brave and log it to his.txt.
  • Alt+Shift+Z / X / C / V / B: Open random Amazon Music album, Dave video, Vancity video, Ben video, or C++ video in Firefox or Brave.
  • Ctrl+Alt+C: Open a random chess article in Brave and log it.
  • Alt+3 / 4 / 5: Play random Terry A. Davis videos from 2017, 2017b, or 2018 archives.
  • Alt+7: Copy a random chess endgame FEN to the clipboard.

Download and Terminal Commands: Automate Web Tasks

These hotkeys streamline downloading and terminal interactions using tools like yt-dlp and wget.

  • Win+C / 0 / Z / Alt+Win+C: Run yt-dlp with different options (normal, with subtitles, open in mpv, or with -f 18) in ConEmu.
  • Win+/: Download Newgrounds audio using yt-dlp.
  • Shift+Ctrl+C: Run wget in ConEmu with the clipboard content.
  • Win+V: Paste the clipboard in quotes in ConEmu with a custom command.
  • Ctrl+F1: Ping and open Starlink statistics in a browser.
  • AppsKey+\ / =: Run or download ChatSounds scripts via Cygwin’s mintty.

Gaming and Niche Tools: For Specialized Tasks

Hotkeys for gaming (Sven Co-op) and niche applications like IrfanView and Wikipedia.

  • Alt+F9: Play a random sound in Sven Co-op.
  • Shift+Ctrl+Alt+0 / 9: Say a random Bible verse or scientist line in Sven Co-op.
  • Win+F / Alt+Win+F / G / H / J: Perform random mouse wheel actions in IrfanView with varying delays and counts, great for browsing images.
  • Ctrl+Alt+U / J: Send ‘u’ or ‘j’ to Wikipedia for navigation (restored).
  • Ctrl+F2: Display the parent window’s title and class (restored, useful for debugging).
  • Ctrl+F5: Resize and move YouTube live chat to the secondary monitor (restored).

Miscellaneous: System-Wide Utilities

A few handy utilities round out the script.

  • Win+Insert: Suspend all hotkeys for a quick pause.
  • Ctrl+Win+F12: Toggle a GUI showing all hotkeys and their comments.
  • Win+Ctrl+F9: Write the hotkey list to D:\bat\keys.txt.
  • Shift+Ctrl+Alt+F12: Empty the Recycle Bin with a tray tip.
  • AppsKey+2: Open Sound settings.
  • Ctrl+F7: Press ‘a’ every 800ms for 1500 iterations, useful for repetitive tasks.
  • Alt+Win+PrintScreen: Capture a screenshot and paste it into PaintDotNet (restored).

Why These Hotkeys Rock

This AutoHotkey script is a productivity powerhouse, blending everyday shortcuts with specialized commands for media enthusiasts, developers, and gamers. The restored hotkeys from the older version—such as virtual desktop navigation (Alt+Numpad1–4, Ctrl+Win+Alt+Left/Right), SDRSharp recording access (Alt+Win+N/8/9), and Wikipedia navigation (Ctrl+Alt+U/J)—add depth, making it ideal for users with diverse needs. Whether you’re managing multiple foobar2000 instances, downloading videos with yt-dlp, or randomizing your music and video playback, these hotkeys save time and effort.

Get Started

To use this script, download AutoHotkey, save the code as a .ahk file, and run it. Customize the paths (e.g., D:\vid, C:\Program Files\foobar2000) to match your system, and tweak the hotkeys to fit your workflow. With this script, you’ll be automating like a pro in no time!

Note: Some hotkeys rely on external tools like foobar2000, mpv, Cygwin, or the VD library. Ensure these are installed, and check file paths for compatibility.

#Insert Suspend all hotkeys
MButton & XButton2 Play random track in foobar2000
MButton & XButton2 Up Release MButton and XButton2
XButton2 & MButton Play random track in foobar2000
XButton2 Send r key in browsers to refresh with Vimium
MButton & XButton1 Toggle between Firefox and Pale Moon
^MButton Play random track
^!WheelUp Set volume to 0 dB
^!WheelDown Set volume to -12 dB
+f9 Play/pause alternate foobar2000
f9 Play/pause main foobar2000
f10 Previous track in foobar2000
f11 Next track in foobar2000
!6 Toggle Discord Rich Presence in foobar2000
^XButton2 Play random track
+Volume_Down Seek back 1 second
+Volume_Up Seek ahead 1 second
^Volume_Down Seek back 10 seconds
^Volume_Up Seek ahead 10 seconds
appskey & b Toggle between Betterbird and Thunderbird
appskey & p Toggle between Notepad++ and VSCodium
appskey & 9 Toggle between WinSCP and FileZilla
XButton1 Toggle between Renoise and Ableton
numpaddiv Toggle between foobar2000 and ConEmu
numpadmult Toggle between foobar2000 and Firefox
appskey & , Activate main foobar2000
appskey & . Activate alternate foobar2000
appskey & / Activate third foobar2000 instance
+NumpadAdd Activate Renoise
+NumpadDiv Activate PHP book
+NumpadSub Activate SunVox
+NumpadMult Set 280Hz and activate Sven Co-op
appskey & n Toggle or tab QOwnNotes
appskey & f Toggle or tab Firefox
appskey & u Toggle or tab SumatraPDF
appskey & r Toggle or tab Renoise
appskey & m Toggle or tab BowPad
appskey & k Toggle or tab KeePass
appskey & i Toggle or tab Raspberry Pi console
appskey & v Open or activate Videos folder
appskey & q Open or activate Pictures folder
!Numpad1 Switch to virtual desktop 1
!Numpad2 Switch to virtual desktop 2
!Numpad3 Switch to virtual desktop 3
!Numpad4 Switch to virtual desktop 4
!#k Get ffmpeg converted podcast from VPS
Launch_App2 Placeholder for custom application launch
Launch_Media Placeholder for custom media launch
!#PrintScreen Capture screenshot and paste in PaintDotNet with Alt + Win + PrintScreen
#PgDn Get current weather
!#PgDn Get current weather (double star)
^#PgDn Get current weather (unformatted, Burnaby)
#PgUp Get system info
!#PgUp Get system info (double star)
^F2 Get parent window info
^F5 Resize and move YouTube chat to secondary monitor
^!u Send 'u' to Wikipedia
^!j Send 'j' to Wikipedia
^#!Left Move window to previous virtual desktop
^#!Right Move window to next virtual desktop
!NumpadSub Set display frequency to 60Hz
!f1 Set display frequency to 60Hz
!NumpadAdd Set display frequency to 280Hz
!f2 Set display frequency to 280Hz
^#F12 Toggle GUI visibility
+^p Copy active Explorer path to clipboard
#^f9 Write hotkey list to D:\bat\keys.txt
^!NumpadAdd Set High Performance mode
#!NumpadAdd Set Balanced mode and run HomeSafe View
!#m Close HomeSafe View, set Power Saver mode, and turn off monitors
#m Turn off monitors
^!f11 Process clipboard and write to ChatSoundsnewFR.txt
^+!d Paste full timestamp
!#t Paste compact timestamp
!#y Paste date
!2 Paste hyphenated date
^+!f Paste date without time
^+!h Paste time and day
^+!g Paste formatted ChatSounds notice
!#r Paste Reddit RSS feed
f7 Copy Edge URL and title
!f3 Ignore JOINS PARTS QUITS NICKS for irssi channel name in Clipboard
!w Wrap clipboard in double quotes
^+!v Wrap clipboard in single quotes
^+!b Wrap clipboard in double quotes
^+!f12 Empty Recycle Bin
appskey & 2 Open Sound settings
^#t Toggle AlwaysOnTop
^+v Remove newlines from clipboard
^!#pause Block keyboard and mouse input
appskey & pause Unblock input
^f7 Press 'a' every 800ms for 1500 iterations
#f Random mouse wheel in IrfanView
!#f Continuous random wheel
!#g Random wheel with delay (1-1000ms)
!#h Random wheel with delay (1-6000ms)
!#j Random wheel (up to 3000)
appskey & ' Run or restart HomeSafe View
appskey & \ Run ChatSounds script
appskey & = Download ChatSounds
!#v Open random Max 8 patcher
!#, Open random Renoise project
!#u Open random Max gen file
!#b Open random Max 8 help patcher
!#i Open random Max 8 example patcher
!#f7 Send random Bible verse
!#3 Send random BIP 39 word
#b Open random ebook
!Capslock Open random URL in Brave and log
!+z Search random album on Amazon Music
!+x Open random Dave video
!+c Open random Vancity video
!+v Open random Ben video
!+b Open random C++ video
^!c Open random chess article and log
!3 Open random Terry 2017 video
!4 Open random Terry 2017b video
!5 Open random Terry 2018 video
!7 Copy random endgame FEN to clipboard
#c Run yt-dlp
#0 Run yt-dlp with subtitles
#z Run yt-dlp and open in mpv
!#c Run yt-dlp with -f 18 
#/ Download Newgrounds audio
^+c Run wget
#v Paste clipboard in quotes in ConEmu 
^f1 Ping and open Starlink stats
!f9 Play random sound in Sven Co-op
^+!0 Say random Bible verse in Sven Co-op
^+!9 Play random scientist line in Sven Co-op
^!v Resize and move video players to secondary monitor
!9 Resize and move Agent DVR to secondary monitor
f5 Resize and move video to Secondary Monitor
#InstallKeybdHook
#SingleInstance force
SetWorkingDir %A_ScriptDir%
#include group2.ahk
#include VA.ahk
#include VD.ahk
Menu, Tray, Icon, p.ico

; Functions
ChangeDisplayFrequency(Frequency) {
    VarSetCapacity(DEVMODE, 156, 0)
    NumPut(156, DEVMODE, 36, "UShort")
    DllCall("EnumDisplaySettingsA", "Ptr", 0, "UInt", -1, "Ptr", &DEVMODE)
    NumPut(0x400000, DEVMODE, 40)
    NumPut(Frequency, DEVMODE, 120, "UInt")
    Return DllCall("ChangeDisplaySettingsA", "Ptr", &DEVMODE, "UInt", 0)
}

RunFoobar(cmd, path := "C:\Program Files (x86)\foobar2000\foobar2000.exe") {
    Run "%path%" "%cmd%"  ; Use quotes to ensure proper argument separation
    ; Sleep 1000
}

ToggleWindow(exe1, exe2) {
    IfWinActive % "ahk_exe " exe1
        WinActivate % "ahk_exe " exe2
    else
        WinActivate % "ahk_exe " exe1
}

OpenOrActivate(path, title, maximize := 1) {
    IfWinExist %title%
        WinActivate %title%
    else {
        Run %path%
        WinWait %title%
        if (maximize)
            WinMaximize
    }
}

RunRandom(file, prefix := "Run", suffix := "", browser := "") {
    FileRead, content, %file%
    if (ErrorLevel) {
        MsgBox, Could not read %file%
        return
    }
    Sort, content, Random
    line := Trim(SubStr(content, 1, InStr(content, "`r") - 1))
    if (line = "") {
        MsgBox, No valid content found in %file%
        return
    }
    if (prefix = "Send") {
        Send %line%%suffix%
    } else {
        if (browser != "") {
            fullCmd := browser . " """ . line . """"
        } else {
            fullCmd := prefix . " " . line . suffix
        }
        Run %fullCmd%, , UseErrorLevel
        if (ErrorLevel) {
            MsgBox, Failed to run: %fullCmd%
        }
    }
}

SendCmd(console, cmd, clip := 0) {
    IfWinNotExist %console%
        return
    WinActivate %console%
    WinWaitActive %console%, , 2
    if (ErrorLevel)
        return
    Sleep 200
    Send %cmd%
    if (clip)
        Send %Clipboard%
    Send {Enter}
}

SendTime(fmt) {
    FormatTime, time, A_Now, %fmt%
    Send %time%
}

; Autoexecute GUI
Gui -Caption
Gui Add, ListView,, HOTKEY|COMMENT
for i, e in Hotkeys(Hotkeys)
    LV_Add("", e.Hotkey, e.Comment)
LV_ModifyCol()

; Hotkeys with comments
#Insert:: ; Suspend all hotkeys
    Suspend
    return

; Preserve default MButton behavior only when not combined with XButton2
MButton::
    Send {MButton down}
    return

MButton Up::
    Send {MButton up}
    return

MButton & XButton2:: ; Play random track in foobar2000
    if (GetKeyState("MButton", "P")) {  ; Ensure MButton is still pressed
        RunFoobar("/runcmd=Playback/Random")
        Sleep 1
        Send {MButton up}
        Send {XButton2 up}
    }
    return

MButton & XButton2 Up:: ; Release MButton and XButton2
    Send {MButton up}
    Send {XButton2 up}
    return

XButton2 & MButton:: ; Play random track in foobar2000
    RunFoobar("/runcmd=Playback/Random")
    return

XButton2:: ; Send r key in browsers to refresh with Vimium
if WinActive("ahk_exe firefox.exe") or WinActive("ahk_exe librewolf.exe") or WinActive("ahk_exe chrome.exe") or WinActive("ahk_exe brave.exe") or WinActive("ahk_exe msedge.exe")
    send, r
else
IfWinActive, ahk_exe ConEmu64.exe
{
    Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
    sleep, 10
    WinActivate ahk_exe mintty.exe
    return
}
else
{
    Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
    sleep, 10
    WinActivate ahk_exe ConEmu64.exe
    return
}
return

MButton & XButton1:: ; Toggle between Firefox and Pale Moon
    ToggleWindow("firefox.exe", "palemoon.exe")
    return

^MButton:: ; Play random track
    RunFoobar("/runcmd=Playback/Random")
    return

MButton & XButton1 Up::
    return

^!WheelUp:: ; Set volume to 0 dB
    RunFoobar("/runcmd=Playback/Volume/Set to -0 dB")
    return

^!WheelDown:: ; Set volume to -12 dB
    RunFoobar("/runcmd=Playback/Volume/Set to -12 dB")
    return

+f9:: ; Play/pause alternate foobar2000
    Run "D:\foobar2000b\foobar2000.exe" "/playpause"
    return

f9:: ; Play/pause main foobar2000
    RunFoobar("/playpause")
    return

f10:: ; Previous track in foobar2000
    RunFoobar("/prev")
    return

f11:: ; Next track in foobar2000
    RunFoobar("/next")
    return

!6:: ; Toggle Discord Rich Presence in foobar2000
    RunFoobar("/runcmd=View/Display Discord Rich Presence")
    return

^XButton2:: ; Play random track
    RunFoobar("/runcmd=Playback/Random")
    return

+Volume_Down:: ; Seek back 1 second
    RunFoobar("/runcmd=Playback/Seek/""Back by 1 second""")
    return

+Volume_Up:: ; Seek ahead 1 second
    RunFoobar("/runcmd=Playback/Seek/""Ahead by 1 second""")
    return

^Volume_Down:: ; Seek back 10 seconds
    RunFoobar("/runcmd=Playback/Seek/""Back by 10 seconds""")
    return

^Volume_Up:: ; Seek ahead 10 seconds
    RunFoobar("/runcmd=Playback/Seek/""Ahead by 10 seconds""")
    return

appskey & b:: ; Toggle between Betterbird and Thunderbird
    ToggleWindow("betterbird.exe", "thunderbird.exe")
    return

appskey & p:: ; Toggle between Notepad++ and VSCodium
    ToggleWindow("notepad++.exe", "VSCodium.exe")
    return

appskey & 9:: ; Toggle between WinSCP and FileZilla
    ToggleWindow("WinSCP.exe", "filezilla.exe")
    return

XButton1:: ; Toggle between Renoise and Ableton
    ToggleWindow("renoise.exe", "Ableton Live 11 Suite.exe")
    return

numpaddiv:: ; Toggle between foobar2000 and ConEmu
    ToggleWindow("foobar2000.exe", "ConEmu64.exe")
    return

numpadmult:: ; Toggle between foobar2000 and Firefox
    ToggleWindow("foobar2000.exe", "firefox.exe")
    return

appskey & ,:: ; Activate main foobar2000
    WinActivate ahk_exe C:\Program Files (x86)\foobar2000\foobar2000.exe
    return

appskey & .:: ; Activate alternate foobar2000
    WinActivate ahk_exe D:\foobar2000b\foobar2000.exe
    return

appskey & /:: ; Activate third foobar2000 instance
    WinActivate ahk_exe D:\foobar2000c\foobar2000.exe
    return

+NumpadAdd:: ; Activate Renoise
    WinActivate ahk_class Renoise
    return

+NumpadDiv:: ; Activate PHP book
    WinActivate Learning PHP
    return

+NumpadSub:: ; Activate SunVox
    WinActivate ahk_class SunDogEngine
    return

+NumpadMult:: ; Set 280Hz and activate Sven Co-op
    ChangeDisplayFrequency(280)
    Sleep 100
    WinActivate Sven Co-op
    return

appskey & n:: ; Toggle or tab QOwnNotes
    IfWinActive ahk_exe QOwnNotes.exe
        SendInput !{Tab}
    else
        WinActivate ahk_exe QOwnNotes.exe
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & f:: ; Toggle or tab Firefox
    IfWinActive ahk_exe firefox.exe
        SendInput !{Tab}
    else
        WinActivate ahk_exe firefox.exe
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & u:: ; Toggle or tab SumatraPDF
    IfWinActive ahk_exe SumatraPDF.exe
        SendInput !{Tab}
    else
        WinActivate ahk_exe SumatraPDF.exe
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & r:: ; Toggle or tab Renoise
    IfWinActive ahk_exe renoise.exe
        SendInput !{Tab}
    else
        WinActivate ahk_exe renoise.exe
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & m:: ; Toggle or tab BowPad
    IfWinActive ahk_exe BowPad.exe
        SendInput !{Tab}
    else
        WinActivate ahk_exe BowPad.exe
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & z::
appskey & j::
    if VA_GetDeviceName(VA_GetDevice()) != "Analog (1+2) (2- RME ADI-2 Pro)"
        VA_SetDefaultEndpoint("Analog (1+2) (2- RME ADI-2 Pro)", 0), Sleep 10
    Loop, d:\vid\*
    {
        FileGetTime, Time, %A_LoopFileFullPath%, C
        if (Time > Time_Orig)
            Time_Orig := Time, File := A_LoopFileName
    }
    Run, mpv.exe --speed=1.50 --af=dynaudnorm "d:\vid\%File%"
    Sleep 2000
    WinMove, ahk_exe mpv.exe,, -1083, -4, 1083, 640
    return

appskey & k:: ; Toggle or tab KeePass
    IfWinActive ahk_exe KeePass.exe
        SendInput !{Tab}
    else
        WinActivate ahk_exe KeePass.exe
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & i:: ; Toggle or tab Raspberry Pi console
    IfWinActive pi@raspberrypi: ~
        SendInput !{Tab}
    else
        WinActivate pi@raspberrypi: ~
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    Sleep 100
    return

appskey & v:: ; Open or activate Videos folder
    OpenOrActivate("D:\vid", "Videos")
    return

appskey & q:: ; Open or activate Pictures folder
    OpenOrActivate("D:\windows\Pictures", "Pictures")
    return

#IfWinNotActive ahk_group ESC

!Numpad1:: ; Switch to virtual desktop 1
    VD.goToDesktopNum(1)
    return

!Numpad2:: ; Switch to virtual desktop 2
    VD.goToDesktopNum(2)
    return

!Numpad3:: ; Switch to virtual desktop 3
    VD.goToDesktopNum(3)
    return

!Numpad4:: ; Switch to virtual desktop 4
    VD.goToDesktopNum(4)
    return

!#k:: ; Get ffmpeg converted podcast from VPS
    clip := Clipboard
    StringTrimRight, OutputVar, clip, 15
    Send gp
    Send {Space}
    SendInput %OutputVar%
    return

Launch_App2:: ; Placeholder for custom application launch
    return

Launch_Media:: ; Placeholder for custom media launch
    return

!#PrintScreen:: ; Capture screenshot and paste in PaintDotNet with Alt + Win + PrintScreen
    Send {PrintScreen}
    Run "C:\Program Files\paint.net\PaintDotNet.exe"
    WinWait ahk_exe PaintDotNet.exe
    Send ^v
    Send {Enter}
    return

#PgDn:: ; Get current weather
    Clipboard := ""
    Run C:\Users\sb\AppData\Local\Programs\Python\Python311\pythonw.exe d:/rex/test/weather2023.py
    SplashImage,, B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
    Sleep 50
    SplashImage, off
    return

!#PgDn:: ; Get current weather (double star)
    Clipboard := ""
    Run C:\Users\sb\AppData\Local\Programs\Python\Python311\pythonw.exe d:/rex/test/weather2023winterdoublestar.py
    SplashImage,, B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
    Sleep 50
    SplashImage, off
    return

^#PgDn:: ; Get current weather (unformatted, Burnaby)
    Clipboard := ""
    Run C:\Users\sb\AppData\Local\Programs\Python\Python39\pythonw.exe d:/rex/test/printweather.py
    SplashImage,, B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
    Sleep 50
    SplashImage, off
    return

#PgUp:: ; Get system info
    Clipboard := ""
    Run D:\bat\sysinfochate.ahk
    return

!#PgUp:: ; Get system info (double star)
    Clipboard := ""
    Run D:\bat\sysinfochatedoublestar.ahk
    return

^F2:: ; Get parent window info
    ID := DllCall("GetParent", UInt, WinExist("A"))
    ID := !ID ? WinExist("A") : ID
    WinGetClass, Class, ahk_id %ID%
    WinGetTitle, Title, ahk_id %ID%
    MsgBox, 0, %ID%, %Title%`n%Class%
    return

^F5:: ; Resize and move YouTube chat to secondary monitor
    WinGetTitle, ActiveWindowTitle, A
    WinMove, %ActiveWindowTitle%,, -1080, -337, 1080, 971
    return

; #!n:: 

; #!8:: 

; #!9:: 

^!u:: ; Send 'u' to Wikipedia
    SetTitleMatchMode 2
    ControlSend,, {u down}, Wikipedia
    Sleep 5
    ControlSend,, {u up}, Wikipedia
    SetTitleMatchMode 1
    return

^!j:: ; Send 'j' to Wikipedia
    SetTitleMatchMode 2
    ControlSend,, {j down}, Wikipedia
    Sleep 5
    ControlSend,, {j up}, Wikipedia
    SetTitleMatchMode 1
    return

^#!Left:: ; Move window to previous virtual desktop
    VD.MoveWindowToRelativeDesktopNum("A", -1)
    return

^#!Right:: ; Move window to next virtual desktop
    VD.MoveWindowToRelativeDesktopNum("A", 1)
    return

!NumpadSub:: ; Set display frequency to 60Hz
    ChangeDisplayFrequency(60)
    return

!f1:: ; Set display frequency to 60Hz
    ChangeDisplayFrequency(60)
    return

!NumpadAdd:: ; Set display frequency to 280Hz
    ChangeDisplayFrequency(280)
    return

!f2:: ; Set display frequency to 280Hz
    ChangeDisplayFrequency(280)
    return

^#F12:: ; Toggle GUI visibility
    Toggle := !Toggle
    if (Toggle) {
        Gui Show, x0 y0
    } else {
        Gui Destroy
    }
    return

+^p:: ; Copy active Explorer path to clipboard
    Clipboard := GetActiveExplorerPath()
    return

#^f9:: ; Write hotkey list to D:\bat\keys.txtc
    FileDelete D:\bat\keys.txt
    for i, e in Hotkeys(Hotkeys)
        FileAppend % e.Hotkey " " e.Comment "`n", D:\bat\keys.txt
    SoundBeep
    return

^!NumpadAdd:: ; Set High Performance mode
    Run C:\Windows\System32\powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
    TrayTip, Power Control, High Performance mode CHECK SPEAKERS, 20, 17
    return

#!NumpadAdd:: ; Set Balanced mode and run HomeSafe View
    Run C:\Windows\System32\powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
    FileAppend `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec% balanced`n, power.txt
    Process, Exist, HomeSafe View.exe
    if !ErrorLevel
        Run "C:\Program Files (x86)\swann\HomeSafe View\HomeSafe View.exe"
    TrayTip, Power Control, Balanced mode CHECK SPEAKERS, 20, 17
    return

!#m:: ; Close HomeSafe View, set Power Saver mode, and turn off monitors
    Process, Close, HomeSafe View.exe
    Sleep 2000
    FileAppend `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec% lower`n, power.txt
    Run C:\Windows\System32\powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a
    Sleep 1000
    SendMessage 0x112, 0xF170, 2, , Program Manager
    return

#m:: ; Turn off monitors
    Sleep 1000
    SendMessage 0x112, 0xF170, 2, , Program Manager
    return

^!f11:: ; Process clipboard and write to ChatSoundsnewFR.txt
    words := ["mean words" , "to remove"]
    for i, w in words
        Clipboard := StrReplace(Clipboard, w, "")
    Clipboard := RegExReplace(RegExReplace(Clipboard, "\t", ""), " +", " ")
    Clipboard := StrReplace(Clipboard, "!", "{!}")
    Loop {
        Clipboard := StrReplace(Clipboard, "`r`n`r`n", "`r`n", Count)
        if (Count = 0)
            Break
    }
    FileOpen("D:\bat\game\ChatSoundsnewFR.txt", "w").Write(Clipboard).Close()
    Run "C:\cygwin64\bin\mintty.exe" -i /Cygwin-Terminal.ico -e /usr/bin/bash /cygdrive/d/bat/csfix.sh
    return

^+!d:: ; Paste full timestamp
    SendTime("dddd MMM dd, yyyy hh:mm:ss tt")
    return

!#t:: ; Paste compact timestamp
    SendTime("yyyy MM/dd HH:mm:s")
    return

!#y:: ; Paste date
    SendTime("yyyy MM dd")
    return

!2:: ; Paste hyphenated date
    SendTime("yyyy-MM-dd")
    return

^+!f:: ; Paste date without time
    SendTime("dddd MMM dd, yyyy")
    return

^+!h:: ; Paste time and day
    FormatTime, t, A_Now, hh:mm tt dddd
    Send last modified %t%
    return

^+!g:: ; Paste formatted ChatSounds notice
    FormatTime, t, A_Now, dddd MMM dd, yyyy hh:mm tt
    Send last modified %t% EDT (UTC-4){Enter}The majority of these ChatSounds are user submitted and do not Reflect the Views of Bsmesh KING{Enter}Disk space is limited, consider donating if you submit a ton of ChatSounds https://kingsc.net/donate
    return

!#r:: ; Paste Reddit RSS feed
    Send https://www.reddit.com/r/%Clipboard%
    return

f7:: ; Copy Edge URL and title
    WinGetActiveTitle, t
    url := GetURL("Edge")
    Clipboard := t " https://" url
    StringTrimRight, Clipboard, Clipboard, 8
    return

!f3:: ; Ignore JOINS PARTS QUITS NICKS for irssi channel name in Clipboard
    Send /ignore -channels {#}^+{Insert} * JOINS PARTS QUITS NICKS
    return

!w:: ; Wrap clipboard in double quotes
    Send ^x
    Sleep 100
    ClipWait
    Clipboard := """" Clipboard """"
    Sleep 100
    ClipWait
    Send ^v
    return

^+!v:: ; Wrap clipboard in single quotes
    Clipboard := "'" Clipboard "'"
    Sleep 100
    ClipWait
    Send ^v
    return

^+!b:: ; Wrap clipboard in double quotes
    Clipboard := """" Clipboard """"
    Sleep 100
    ClipWait
    Send ^v
    return

^+!f12:: ; Empty Recycle Bin
    FileRecycleEmpty
    TrayTip, Recycle Bin, Bin emptied, 20, 17
    return

appskey & 2:: ; Open Sound settings
    OpenOrActivate("mmsys.cpl", "Sound", 0)
    return

^#t:: ; Toggle AlwaysOnTop
    WinSet AlwaysOnTop, Toggle, A
    SplashImage,, B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
    Sleep 50
    SplashImage, off
    return

^+v:: ; Remove newlines from clipboard
    StringReplace, Clipboard, Clipboard, `r`n, , All
    Send ^v
    return

^!#pause:: ; Block keyboard and mouse input
    BlockInput on
    return

appskey & pause:: ; Unblock input
    BlockInput off
    Send {Alt Up}{Shift Up}{Ctrl Up}{LWin Up}
    return

^f7:: ; Press 'a' every 800ms for 1500 iterations
    Loop 1500 {
        Send a
        Sleep 800
    }
    return

#f:: ; Random mouse wheel in IrfanView
    Random, r, 1, 658
    Random, t, 0, 1
    WinActivate ahk_class IrfanView
    WinWaitActive ahk_class IrfanView
    if (t = 1)
        Click WheelDown %r%
    else
        Click WheelUp %r%
    return

!#f:: ; Continuous random wheel
    Loop {
        Random, r, 1, 658
        Random, t, 0, 1
        WinActivate ahk_class IrfanView
        WinWaitActive ahk_class IrfanView
        if (t = 1)
            Click WheelDown %r%
        else
            Click WheelUp %r%
    }
    return

!#g:: ; Random wheel with delay (1-1000ms)
    Loop {
        Random, r, 1, 658
        Random, s, 1, 1000
        Random, t, 0, 1
        WinActivate ahk_class IrfanView
        WinWaitActive ahk_class IrfanView
        if (t = 1)
            Click WheelDown %r%
        else
            Click WheelUp %r%
        Sleep %s%
    }
    return

!#h:: ; Random wheel with delay (1-6000ms)
    Loop {
        Random, r, 1, 658
        Random, s, 1, 6000
        Random, t, 0, 1
        WinActivate ahk_class IrfanView
        WinWaitActive ahk_class IrfanView
        if (t = 1)
            Click WheelDown %r%
        else
            Click WheelUp %r%
        Sleep %s%
    }
    return

!#j:: ; Random wheel (up to 3000)
    Loop {
        Random, r, 1, 3000
        Random, s, 1, 6000
        Random, t, 0, 1
        WinActivate ahk_class IrfanView
        WinWaitActive ahk_class IrfanView
        if (t = 1)
            Click WheelDown %r%
        else
            Click WheelUp %r%
        Sleep %s%
    }
    return

appskey & ':: ; Run or restart HomeSafe View
    Process, Exist, HomeSafe View.exe
    if ErrorLevel {
        Process, Close, HomeSafe View.exe
        Sleep 100
        Run "C:\Program Files (x86)\swann\HomeSafe View\HomeSafe View.exe"
    } else {
        Run "C:\Program Files (x86)\swann\HomeSafe View\HomeSafe View.exe"
    }
    return

appskey & \:: ; Run ChatSounds script
    Run "C:\cygwin64\bin\mintty.exe" -i /Cygwin-Terminal.ico -h always -e /usr/bin/bash -l /cygdrive/d/bat/chatsoundsopilNuk.sh
    return

appskey & =:: ; Download ChatSounds
    Run "C:\cygwin64\bin\mintty.exe" -i /Cygwin-Terminal.ico -e /usr/bin/bash -l /cygdrive/d/bat/game/chatsoundscyg.sh,, Hide
    SoundBeep
    return

!#v:: ; Open random Max 8 patcher
    RunRandom("maxmsp.txt")
    return

!#,:: ; Open random Renoise project
    RunRandom("renoise.txt")
    return

!#u:: ; Open random Max gen file
    RunRandom("maxgen.txt")
    return

!#b:: ; Open random Max 8 help patcher
    RunRandom("maxhelp.txt")
    return

!#i:: ; Open random Max 8 example patcher
    RunRandom("maxexample.txt")
    return

!#f7:: ; Send random Bible verse
    RunRandom("bible4.txt", "Send")
    return

!#3:: ; Send random BIP 39 word
    RunRandom("english.txt", "Send")
    return

#b:: ; Open random ebook
    RunRandom("pdf.txt")
    return

!Capslock:: ; Open random URL in Brave and log
    RunRandom("rand.txt", "Run", "", """C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe""")
    SetTitleMatchMode 2
    Sleep 2000
    braveUrl := GetURL("Brave")
    if (braveUrl)
        FileAppend, `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%`n%braveUrl%`n, his.txt
    SetTitleMatchMode 1
    return

!+z:: ; Search random album on Amazon Music
    FileRead, content, albums2.txt
    Sort, content, Random
    line := Trim(SubStr(content, 1, InStr(content, "`r") - 1))
    Run "C:\Program Files\Mozilla Firefox\firefox.exe" "https://music.amazon.ca/search/%line%"
    return

!+x:: ; Open random Dave video
    RunRandom("dave.txt", "Run", "", """C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe""")
    return

!+c:: ; Open random Vancity video
    RunRandom("van.txt", "Run", "", """C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe""")
    return

!+v:: ; Open random Ben video
    RunRandom("ben.txt", "Run", "", """C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe""")
    return

!+b:: ; Open random C++ video
    RunRandom("randc++.txt", "Run", "", """C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe""")
    return

^!c:: ; Open random chess article and log
    RunRandom("chess2.txt", "Run", "", """C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe""")
    SetTitleMatchMode 2
    Sleep 2000
    braveUrl := GetURL("Brave")
    if (braveUrl)
        FileAppend, `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%`n%braveUrl%`n, his.txt
    SetTitleMatchMode 1
    return

!3:: ; Open random Terry 2017 video
    RunRandom("terry2017.txt")
    SetWorkingDir D:\Terry A. Davis - TempleOS Archive\videos\2017
    SetWorkingDir %A_ScriptDir%
    return

!4:: ; Open random Terry 2017b video
    RunRandom("terry2017b.txt")
    SetWorkingDir D:\Terry A. Davis - TempleOS Archive\videos\2017
    SetWorkingDir %A_ScriptDir%
    return

!5:: ; Open random Terry 2018 video
    RunRandom("terry2018.txt")
    SetWorkingDir D:\Terry A. Davis - TempleOS Archive\videos\2018
    SetWorkingDir %A_ScriptDir%
    return

!7:: ; Copy random endgame FEN to clipboard
    FileRead, content, endgame.txt
    Sort, content, Random
    line := Trim(SubStr(content, 1, InStr(content, "`r") - 1))
    Clipboard := line
    return

#c:: ; Run yt-dlp
    SendCmd("/cygdrive/d/vid ahk_class VirtualConsoleClass", "y")
    return

#0:: ; Run yt-dlp with subtitles
    SendCmd("/cygdrive/d/vid ahk_class VirtualConsoleClass", "ys")
    return

#z:: ; Run yt-dlp and open in mpv
    SendCmd("/cygdrive/d/vid ahk_class VirtualConsoleClass", "yz")
    return

!#c:: ; Run yt-dlp with -f 18 
    SendCmd("/cygdrive/d/vid ahk_class VirtualConsoleClass", "yt")
    return

#/:: ; Download Newgrounds audio
    SendCmd("/cygdrive/d/ng ahk_class VirtualConsoleClass", "yn")
    return

^+c:: ; Run wget
    SendCmd("/cygdrive/d/apps ahk_class VirtualConsoleClass", "wg")
    return

#v:: ; Paste clipboard in quotes in ConEmu 
    SendCmd("/cygdrive/d/vid ahk_class VirtualConsoleClass", "v", 1)
    return

^f1:: ; Ping and open Starlink stats
    SendCmd("ahk_class VirtualConsoleClass", "g")
    Run http://dishy.starlink.com/statistics
    return

!f9:: ; Play random sound in Sven Co-op
    RunRandom("spk.txt", "Send", " as_command .s_player_exec @all spk ")
    return

^+!0:: ; Say random Bible verse in Sven Co-op
    RunRandom("bible4.txt", "Send", " as_command .s_admin_say 0 1 """" """" 8 @all 255 0 255 -1 -1")
    Send {Enter}
    return

^+!9:: ; Play random scientist line in Sven Co-op
    RunRandom("sci.txt", "Send", " .s_player_exec @all ""spk """"")
    Send {Enter}
    return

^!v:: ; Resize and move video players to secondary monitor
    WinMove ahk_exe mpv.exe,, -1083, 88, 1083, 640
    WinMove ahk_exe vlc.exe,, -1083, 88, 1083, 640
    WinMove "Picture in picture",, -1083, 88, 1083, 640
    return

!9:: ; Resize and move Agent DVR to secondary monitor
    SetTitleMatchMode 2
    WinMove "Agent: Agent DVR - Chromium",, -1083, 478, 1080, 1001
    SetTitleMatchMode 1
    return

f5:: ; Resize and move video to Secondary Monitor
WinMove, ahk_exe mpv.exe,, -1083, -4, 1083, 640
WinMove, ahk_exe vlc.exe,, -1083, -4, 1083, 640
WinMove, ahk_exe webcamoid.exe,, -1083, -4, 1083, 640
WinMove, Picture in picture,, -1083, -4, 1083, 640
WinMove, Picture-in-Picture,, -1083, -4, 1083, 640
WinMove, ahk_exe sunvox.exe,, -1087, -378, 1088, 1010
WinMove, Mixer,, -1087, 626, 1088, 833
WinMove, Instrument Editor,, -1087, -202, 1088, 833
SetTitleMatchMode, 2
WinMove, Agent: Agent DVR - Chromium,, -1083, 478, 1080, 1001
WinMove, youtube.com/live_chat,, -1085, -418, 1086, 431
SetTitleMatchMode, 1
return

; Supporting Functions
GetActiveExplorerPath() {
    explorerHwnd := WinActive("ahk_class CabinetWClass")
    if (explorerHwnd) {
        for window in ComObjCreate("Shell.Application").Windows
            if (window.hwnd = explorerHwnd)
                return window.Document.Folder.Self.Path
    }
}

Hotkeys(ByRef Hotkeys) {
    FileRead, Script, %A_ScriptFullPath%
    Script := RegExReplace(Script, "ms`a)^\s*/\*.*?^\s*\*/\s*|^\s*\(.*?^\s*\)\s*")
    Hotkeys := {}
    Loop, Parse, Script, `n, `r
        if RegExMatch(A_LoopField, "^\s*(.*):`:.*`;\s*(.*)", Match)
            Hotkeys.Push({"Hotkey": Match1, "Comment": Match2})
    return Hotkeys
}

GetURL(wTitle*) {
    if !(wId := WinExist(wTitle*))
        return
    IUIAutomation := ComObjCreate("{ff48dba4-60ef-4201-aa87-54103eef594e}", "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
    DllCall(NumGet(NumGet(IUIAutomation+0)+6*A_PtrSize), "ptr", IUIAutomation, "ptr", wId, "ptr*", elementMain)
    NumPut(addressbarStrPtr := DllCall("oleaut32\SysAllocString", "wstr", "Address and search bar", "ptr"), (VarSetCapacity(addressbar, 8+2*A_PtrSize)+NumPut(8, addressbar, 0, "short"))*0+&addressbar, 8, "ptr")
    DllCall("oleaut32\SysFreeString", "ptr", addressbarStrPtr)
    DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "ptr", &addressbar, "ptr*", addressbarCondition)
    DllCall(NumGet(NumGet(elementMain+0)+5*A_PtrSize), "ptr", elementMain, "int", 0x4, "ptr", addressbarCondition, "ptr*", currentURLElement)
    DllCall(NumGet(NumGet(currentURLElement+0)+10*A_PtrSize), "ptr", currentURLElement, "uint", 30045, "ptr", (VarSetCapacity(currentURL, 8+2*A_PtrSize)+NumPut(0, currentURL, 0, "short")+NumPut(0, currentURL, 8, "ptr"))*0+&currentURL)
    ObjRelease(currentURLElement)
    ObjRelease(elementMain)
    ObjRelease(IUIAutomation)
    return StrGet(NumGet(currentURL, 8, "ptr"), "utf-16")
}

Leave a Comment

Auto