weighted random ambient playlist hotkey for foobar2000

this one is nasty:

global arr := ["ambient", "ambient2", "ambient3", "ambient4", "ambient5", "ambient6", "ambient7", "ambient8", "randambient2", "randambient2"]
Random, oVar, 1, arr.MaxIndex()	
rand := arr[oVar]
Run "D:\foobar2000\foobar2000.exe" /runcmd=File/Scheduler/%rand%

foo_scheduler actions:

ambient#
Set playback order to “Repeat (Playlist)”
Set active playlist “ambient”
Start playback from track #123456


randambient2
Set playback order to “Random”
Set active playlist “ambient”
Start playback
1 seconds delay
Next track
1 seconds delay
Set playback order to “Repeat (Playlist)”

Peak hours power saving ahk script

Here is a script that changes the power plan to Balanced or Power Saver depending on idle time. Just schedule it with Task Scheduler.

if A_TimeIdlePhysical > 1200000 
{
# Power Saver
	Run C:\Windows\System32\powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a
	return
}
else
{
# Balanced
	Run C:\Windows\System32\powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
	return
}

Autohotkey ahk power control script etc/

Win+Insert Suspend Keys
MButton & XButton1 Activate Firefox or Palemoon
Shift+f9 Play/Pause foobar2000b
f9 Play/Pause foobar2000
f10 Prev track foobar2000
f11 Next track foobar2000
Ctrl+Win+F12 Gui hotkeys
Shift+Ctrl+p Get Active Explorer Window Path
Win+Ctrl+f9 Print Hotkeys to D:\bat\keys.txt
; Alt+NumpadSub Power Saver Mode
Alt+NumpadSub Change monitor frequency to 60hz
Ctrl+Alt+NumpadAdd High Performance Mode
Alt+NumpadAdd Change monitor frequency to 280hz
; Alt+NumpadAdd Balanced Mode
Win+Alt+NumpadAdd Run/Rerun Swann
Ctrl+f7 Press the ‘a’ key every 1.5 seconds
Ctrl+Shift+Alt+d paste current time dddd MMM dd, yyyy hh:mm:ss tt
Alt+Win+t paste current time yyyy MM/dd HH:mm:s
Alt+Win+y paste current time yyyy MM dd
Alt+2 paste current time yyyy-MM-dd
Ctrl+Shift+Alt+f paste current time dddd MMM dd, yyyy
Ctrl+Shift+Alt+g paste current time dddd MMM dd, yyyy hh:mm tt last modified %time% EST
Ctrl+Shift+Alt+h paste current time hh:mm tt dddd last modified %time%
Alt+Win+r Paste Reddit RSS feed
f7 Copy Brave Active Tab URL and Title to Clipboard
Alt+f3 Ignore JOINS PARTS QUITS NICKS for irssi channel name in Clipboard
Alt+Win+k Get ffmpeg converted podcast from VPS
Alt+w Wrap Clipboard contents in double quotes
Ctrl+Shift+Alt+v Wrap Clipboard contents in single quotes
Ctrl+Shift+Alt+b Wrap Clipboard contents in double quotes
Ctrl+Shift+Alt+f12 Empty Recycle Bin
Shift+NumpadAdd Activate Renoise
Shift+NumpadSub Activate SunVox
appskey & b Activate Thunderbird
appskey & n Activate QOwnNotes
appskey & p Activate Notepad++
appskey & f Activate Firefox
appskey & m Activate Palemoon
appskey & r Activate Renoise or Ableton
appskey & k Activate KeePass
; appskey & s Activate SunVox
appskey & i Activate raspberrypi console
appskey & q Activate qp
appskey & ‘ Run HomeSafe View
appskey & \ Run SDRSharp
appskey & v Activate/Run vid folder
Win+Shift+e Activate/Run D: Folder
Win+Shift+u Activate/Run AppData Folder
appskey & 1 Activate/Run server folder
appskey & 2 Activate/Run mmsys.cpl
appskey & l Activate/Run Local folder
appskey & `; Activate/Run Roaming folder
appskey & c Activate/Run bat folder
appskey & t Activate/Run test folder
appskey & g Activate/Run game folder
appskey & h Activate/Run html folder
appskey & a Activate/Run apps folder
appskey & , Activate foobar2000
appskey & . Activate D:\foobar2000b\foobar2000.exe
appskey & / Activate D:\foobar2000c\foobar2000.exe
appskey & [ Copy current time and window title to Clipboard
appskey & z Run newest vid folder video in mpv
Shift+NumpadMult Activate Sven Co-op
Shift+Ctrl+Alt+p Paste then empty clipboard
Alt+Win+v Random Max 8 patcher
Alt+Win+b Random Max 8 Help patcher
Alt+Win+i Random Max 8 Example patcher
Alt+Win+f7 Random Bible Verse
Alt+Win+3 Random BIP 39 word
Win+m Turn off Monitors
Alt+Win+m Close HomeSafe View and switch to Power Saver mode
Win+b Random Ebook
; Win+c yt-dlp
Win+c yt-dlp
Win+0 yt-dlp subtitles
Win+z yt-dlp and open in mpv
Alt+f9 Random spk in Sven Co-op
Ctrl+Shift+c wget
Alt+Win+c yt-dlp -f 18
Win+/ yt-dlp Newgrounds Audio and load in foobar2000
Win+v Paste Clipboard wrapped in quotes in ConEmu
Ctrl+f1 Wait for a ping success and go to http://dishy.starlink.com/statistics
Ctrl+Win+t Set window to AlwaysOnTop
Win+f Random Mouse Wheel movements
Alt+Win+f Random Mouse Wheel movements
Alt+Win+g Random Mouse Wheel movements
Alt+Win+h Random Mouse Wheel movements
Alt+Win+j Random Mouse Wheel movements
Alt+6 Toggle Display Discord Rich Presence for foobar2000
Ctrl+XButton2 Random Track in foobar2000
Win+n Windows Night Light
Win+, Windows Updates
Win+. Windows Taskbar
Win+’ Windows Graphics
Win+[ Windows Volume Mixer
Ctrl+Shift+v Remove Newlines in Clipboard
Ctrl+Alt+Win+pause Block Keyboard and Mouse Input
appskey & pause Holding Appskey and pressing Pause to abort
Shift+Volume_Down Seek Back by 1 second foobar2000
Shift+Volume_Up Seek Ahead by 1 second foobar2000
Ctrl+Volume_Down Seek Back by 10 seconds foobar2000
Ctrl+Volume_Up Seek Ahead by 10 seconds foobar2000
Win+PrintScreen Press PrintScreen and paste in PaintDotNet
Ctrl+Shift+Alt+k KING stuff
Win+PgDn Get Current Weather
Alt+Win+PgDn Get Current Weather unformatted
Ctrl+Win+PgDn Get Current Weather unformatted Burnaby
Win+Pgup Get SysInfo
Alt+Win+Pgup Get SysInfo unformatted
Ctrl+Shift+Alt+0 Random Bible verse Sven Co-op
Ctrl+Shift+Alt+9 Random Scientist Line Sven Co-op
numpaddiv Activate foobar2000 or ConEmu
numpadmult Activate foobar2000 or Firefox
numpadsub Activate foobar2000 or Pale Moon
Win+Alt+p Append URL in Clipboard to random urls file
Win+Alt+- Random Jeopardy! game
XButton2 & MButton Random foobar2000 track
XButton2 Send r key in browsers to refresh with Vimium
XButton1 Activate Ableton or Renoise
Alt+Capslock Random Wikipedia Article etcF
Alt+Shift+z Random 1001 Album + rym top albums in Amazon music
Alt+Shift+x Random Dave vid
Alt+Shift+c Random Vancity vid
Ctrl+Alt+c Random Chess article
Alt+3 Random Terry 2017
Alt+4 Random Terry 2017b
Alt+5 Random Terry 2018
Ctrl+F2 Get parent window
Ctrl+Alt+v Resize and move video to Secondary Monitor
; Alt+f5 Resize and move video to Secondary Monitor
Alt+9 Resize and move AgentDVR to Secondary Monitor
Shift+Ctrl+f Get the Path to the Selected File in Explorer.
f5 Resize and move video to Secondary Monitor
Ctrl+f5 Resize and move yt chat to Secondary Monitor
Win+Alt+n open todays SDRSharp recordings
Win+Alt+8 open recent SDRSharp recording in Audacity
Win+Alt+9 open yesterday SDRSharp recording in Audacity
appskey & 9 Activate/Run/Sync camera folder
Alt+7 Random endgame FEN

; #InstallKeybdHook
#SingleInstance force
SetWorkingDir %A_ScriptDir%
#include group2.ahk
#include VA.ahk
; Menu, Tray, Icon, power.ico 
Menu, Tray, Icon, p.ico 

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)
}

#Insert:: ; Suspend Keys
Suspend
return

; autoexecute section:
Gui, -Caption
Gui, Add, ListView,, HOTKEY|COMMENT
for Index, Element in Hotkeys(Hotkeys)
    LV_Add("",Element.Hotkey, Element.Comment)
LV_ModifyCol()

MButton & XButton2 Up:: 
send, {Mbutton up}
send, {Xbutton2 up}
return

MButton & XButton2::
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" "/runcmd=Playback/Random"
sleep, 1000
send, {Mbutton up}
send, {Xbutton2 up}
return


MButton & XButton1:: ; Activate Firefox or Palemoon
IfWinActive, ahk_exe firefox.exe
{
    WinActivate ahk_exe palemoon.exe
    return
}
else
{
    WinActivate ahk_exe firefox.exe
    return
}
return

MButton & XButton1 Up::
; send, {Mbutton up}
; send, {Xbutton1 up}
return

MButton::
send, {Mbutton down}
return

MButton Up::
send, {Mbutton up} 
return

+f9:: ; Play/Pause foobar2000b
Run D:\foobar2000b\foobar2000.exe /playpause
; Run C:\Program Files (x86)\foobar2000\foobar2000.exe /playpause
return

f9:: ; Play/Pause foobar2000
; Run D:\foobar2000\foobar2000.exe /playpause
Run C:\Program Files (x86)\foobar2000\foobar2000.exe /playpause
return

f10:: ; Prev track foobar2000
; Run D:\foobar2000\foobar2000.exe /prev
Run C:\Program Files (x86)\foobar2000\foobar2000.exe /prev
return

f11:: ; Next track foobar2000
; Run D:\foobar2000\foobar2000.exe /next
Run C:\Program Files (x86)\foobar2000\foobar2000.exe /next
return

; #IfWinNotActive ahk_class SDL_app
#IfWinNotActive ahk_group ESC


; Hotkey to show|hide the GUI:
^#F12:: ; Gui hotkeys
    If (Toggle := !Toggle)
     Gui, Show, x0 y0
    else
     Gui, Destroy
return

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
			}
		}
	}
}

+^p:: ; Get Active Explorer Window Path
Clipboard := GetActiveExplorerPath()
return



; Read Hotkeys from Script File
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)
        {
            if !RegExMatch(Match1,"(Shift|Alt|Ctrl|Win)")
            {
                StringReplace, Match1, Match1, +, Shift+
                StringReplace, Match1, Match1, <^>!, AltGr+
                StringReplace, Match1, Match1, <, Left, All
                StringReplace, Match1, Match1, >, Right, All 
                StringReplace, Match1, Match1, !, Alt+
                StringReplace, Match1, Match1, ^, Ctrl+
                StringReplace, Match1, Match1, #, Win+
            }
            Hotkeys.Push({"Hotkey":Match1, "Comment":Match2})
        }
    return Hotkeys
}

#^f9:: ; Print Hotkeys to D:\bat\keys.txt
FileDelete, D:\bat\keys.txt
for Index, Element in Hotkeys(Hotkeys)
{
	
	key := Element.Hotkey
	key2 := Element.Comment
	FileAppend, %key% %key2%`n, D:\bat\keys.txt
}

return


; SetTitleMatchMode, 2
; #Persistent
; global hold := false
; return
;NumpadMult::

; GetURL(wTitle*) {
	; ErrorLevel := 0
	; if !(wId := WinExist(wTitle*)) {
		; ErrorLevel := 1
		; return
	; }
	; IUIAutomation := ComObjCreate(CLSID_CUIAutomation := "{ff48dba4-60ef-4201-aa87-54103eef594e}", IID_IUIAutomation := "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
	; DllCall(NumGet(NumGet(IUIAutomation+0)+6*A_PtrSize), "ptr", IUIAutomation, "ptr", wId, "ptr*", elementMain)   ; IUIAutomation::ElementFromHandle
	; 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)
	; if (A_PtrSize = 4) {
		; DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "int64", NumGet(addressbar, 0, "int64"), "int64", NumGet(addressbar, 8, "int64"), "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	; } else {
		; DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "ptr", &addressbar, "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	; }
	; DllCall(NumGet(NumGet(elementMain+0)+5*A_PtrSize), "ptr", elementMain, "int", TreeScope_Descendants := 0x4, "ptr", addressbarCondition, "ptr*", currentURLElement) ; IUIAutomationElement::FindFirst
	; 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) ;IUIAutomationElement::GetCurrentPropertyValue
	; ObjRelease(currentURLElement)
	; ObjRelease(elementMain)
	; ObjRelease(IUIAutomation)
	; return StrGet(NumGet(currentURL,8,"ptr"),"utf-16")
; }

;Suspend

;return

; powercfg /L
; LAPTOP
; Power Scheme GUID: 2d39236a-9816-4fe3-847a-0ef8dfc473a7  (Ultimate Performance)
; Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced) *
; Power Scheme GUID: 9897998c-92de-4669-853f-b7cd3ecb2790  (AMD Ryzen™ Balanced)
; Power Scheme GUID: c8415a57-3866-4ba9-b6b1-ab19b3a45124  (High performance)
; Power Scheme GUID: de3f27f6-41ab-4826-860f-17bbd79aac3a  (Power saver)
; DESKTOP
; Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced) *
; Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance)
; Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a  (Power saver)
; Power Scheme GUID: e9a42b02-d5df-448d-aa00-03f14749eb61  (Ultimate Performance)


; !NumpadSub:: ; Power Saver Mode
; Run C:\Windows\System32\powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a
; TrayTip, Power Control, Power Saver mode CHECK SPEAKERS, 20, 17
; return

!NumpadSub:: ; Change monitor frequency to 60hz
ChangeDisplayFrequency(60)
return

^!NumpadAdd:: ; 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::
; Run C:\Windows\System32\powercfg.exe /setactive e9a42b02-d5df-448d-aa00-03f14749eb61
; TrayTip, Power Control, Ultimate Performance mode CHECK SPEAKERS, 20, 17
; return

!NumpadAdd:: ; Change monitor frequency to 280hz
ChangeDisplayFrequency(280)
return

; !NumpadAdd:: ; Balanced Mode
; Run C:\Windows\System32\powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
; TrayTip, Power Control, Balanced mode CHECK SPEAKERS, 20, 17
; return

#!NumpadAdd:: ; Run/Rerun Swann
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, 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

; ^!NumpadMult::
; Run C:\Windows\System32\powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a
; FormatTime, locktime, A_now, MMM-dd hh:mm:ss tt
; IfWinNotExist, important.abw - AbiWord
; Run "C:\Program Files (x86)\AbiWord\bin\AbiWord.exe" "C:\bat\important.abw"
; else
; {
	; WinActivate, important.abw - AbiWord
; }
; sleep, 5000
; IfWinExist, iSpy 64 v7.1.8.0
; {
; Run "C:\bat\ispystart.bat"
; Run "C:\Users\sb\AppData\Local\MEGAsync\MEGAsync.exe"
; }
; DllCall("LockWorkStation")
; return

; ^+[::
; Run "C:\bat\ispystart2.bat"
; FileAppend, %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec% start`n, ispy.txt
; return

; ^+]::
; Run "C:\bat\ispystop2.bat"
; FileAppend, %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec% stop`n, ispy.txt
; return

^f7:: ; Press the 'a' key every 1.5 seconds
Loop, 1500
{
send, a
sleep 800
}
return

;^XButton1::
; XButton1::
; SendInput, {F11}
; return

^+!d:: ; paste current time dddd MMM dd, yyyy hh:mm:ss tt
FormatTime, time, A_now, dddd MMM dd, yyyy hh:mm:ss tt
send %time%
return

!#t:: ; paste current time yyyy MM/dd HH:mm:s
FormatTime, time, A_now, yyyy MM/dd HH:mm:s
send %time%
return

!#y:: ; paste current time yyyy MM dd 
FormatTime, time, A_now, yyyy MM dd 
send %time%
return

!2:: ; paste current time yyyy-MM-dd 
FormatTime, time, A_now, yyyy-MM-dd 
send %time%
return

^+!f:: ; paste current time dddd MMM dd, yyyy
FormatTime, time, A_now, dddd MMM dd, yyyy
send %time%
return

^+!g:: ; paste current time dddd MMM dd, yyyy hh:mm tt last modified %time% EST
FormatTime, time, A_now, dddd MMM dd, yyyy hh:mm tt 
send last modified %time% EST
return

^+!h:: ; paste current time hh:mm tt dddd last modified %time%
FormatTime, time, A_now, hh:mm tt dddd 
send last modified %time%
return

!#r:: ; Paste Reddit RSS feed
send, {LWin up}
sleep, 100
red := clipboard
send, https://reddit.com/r/
sendinput %red%
send, /.rss
return

f7:: ; Copy Brave Active Tab URL and Title to Clipboard
SetTitleMatchMode, 2
get2 := GetURL("Brave")
GetURL(wTitle*) {
	ErrorLevel := 0
	if !(wId := WinExist(wTitle*)) {
		ErrorLevel := 1
		return
	}
	IUIAutomation := ComObjCreate(CLSID_CUIAutomation := "{ff48dba4-60ef-4201-aa87-54103eef594e}", IID_IUIAutomation := "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
	DllCall(NumGet(NumGet(IUIAutomation+0)+6*A_PtrSize), "ptr", IUIAutomation, "ptr", wId, "ptr*", elementMain)   ; IUIAutomation::ElementFromHandle
	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)
	if (A_PtrSize = 4) {
		DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "int64", NumGet(addressbar, 0, "int64"), "int64", NumGet(addressbar, 8, "int64"), "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	} else {
		DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "ptr", &addressbar, "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	}
	DllCall(NumGet(NumGet(elementMain+0)+5*A_PtrSize), "ptr", elementMain, "int", TreeScope_Descendants := 0x4, "ptr", addressbarCondition, "ptr*", currentURLElement) ; IUIAutomationElement::FindFirst
	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) ;IUIAutomationElement::GetCurrentPropertyValue
	ObjRelease(currentURLElement)
	ObjRelease(elementMain)
	ObjRelease(IUIAutomation)
	return StrGet(NumGet(currentURL,8,"ptr"),"utf-16")
}
; FormatTime, time, A_now, yyyy-MM-dd 
WinGetActiveTitle, title
; MsgBox, %get2%
; var2 := RegExReplace(title, "i)[^a-z0-9 ]")
; StringTrimRight, clip, title, 18
StringTrimRight, clip, title, 8
; Clipboard := time " " var2 ".html"
; Clipboard := get2 " " clip
Clipboard := clip " https://"get2
SetTitleMatchMode, 1
return

!f3:: ; Ignore JOINS PARTS QUITS NICKS for irssi channel name in Clipboard
; send, {LWin up}
sleep, 100
; red := clipboard
send, /ignore -channels
send, {space down}
send, {space up}
Send, {Raw}#
send, ^+{Insert}
send, {space down}
send, {space up}
send, * JOINS PARTS QUITS NICKS
return


!#k:: ; Get ffmpeg converted podcast from VPS
clip := clipboard
StringTrimRight, OutputVar, clip, 15
send, gp
send, {space down}
send, {space up}
sendinput %OutputVar%
return

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

^+!v:: ; Wrap Clipboard contents in single quotes
Clipboard='%Clipboard%'
Sleep, 100
ClipWait
Send ^v
return

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

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

; !#l::
; Run "C:\bat\ispystart.bat"
; WinActivate, important.txt - Notepad
; sleep, 3000
; DllCall("LockWorkStation")
; return

+NumpadAdd:: ; Activate Renoise
WinActivate, ahk_class Renoise
return

+NumpadSub:: ; Activate SunVox
WinActivate, ahk_class SunDogEngine
return

appskey & b:: ; Activate Thunderbird
IfWinActive, ahk_exe thunderbird.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe thunderbird.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

; appskey & g::

; Loop 255
	; keyState .= (keyName := GetKeyName("sc" A_Index))? keyName . " : " . GetKeyState(keyName) . "`n" : ""
; MsgBox % keyState
; return

appskey & n:: ; Activate QOwnNotes
IfWinActive, ahk_exe QOwnNotes.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe QOwnNotes.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

appskey & p:: ; Activate Notepad++
IfWinActive, ahk_exe notepad++.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe notepad++.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

appskey & f:: ; Activate Firefox
IfWinActive, ahk_exe firefox.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe firefox.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

appskey & m:: ; Activate Palemoon
IfWinActive, ahk_exe palemoon.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe palemoon.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

appskey & r:: ; Activate Renoise or Ableton
IfWinActive, ahk_exe renoise.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe renoise.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

; appskey & t::
; IfWinActive, ahk_exe Ableton Live 11 Suite.exe
; {
    ; SendInput !{Tab}
	; Send, {Tab}
	; Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	; sleep, 100
    ; return
; }
; else
{
    WinActivate ahk_exe Ableton Live 11 Suite.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return


appskey & k:: ; Activate KeePass
IfWinActive, ahk_exe KeePass.exe
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate ahk_exe KeePass.exe
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

; appskey & s:: ; Activate SunVox
; IfWinActive, ahk_exe sunvox.exe
; {
    ; SendInput !{Tab}
	; Send, {Tab}
	; Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	; sleep, 100
    ; return
; }
; else
; {
    ; WinActivate ahk_exe sunvox.exe
	; Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	; sleep, 100
    ; return
; }
; return

appskey & i:: ; Activate raspberrypi console
IfWinActive, pi@raspberrypi: ~
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate, pi@raspberrypi: ~
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

appskey & q:: ; Activate qp
IfWinActive, qp
{
    SendInput !{Tab}
	Send, {Tab}
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
else
{
    WinActivate, qp
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 100
    return
}
return

appskey & ':: ; Run HomeSafe View
; Process, Exist, openvpn.exe
Process, Exist, HomeSafe View.exe
if !errorlevel
{
	Run "C:\Program Files (x86)\swann\HomeSafe View\HomeSafe View.exe"
	return
}
else
{
	Process, Close, HomeSafe View.exe
	sleep, 100
	Run "C:\Program Files (x86)\swann\HomeSafe View\HomeSafe View.exe"
	return
}
return

appskey & \:: ; Run SDRSharp
SetWorkingDir, D:\SDRSharp\
Process, Exist, SDRSharp.exe
if !errorlevel
{
	; Run "D:\apps\sdrsharp-x86\SDRSharp\bin\SDRSharp.exe"
	Run "D:\SDRSharp\SDRSharp.exe"
	SetWorkingDir, %A_ScriptDir%
	return
}
else
{
	Process, Close, SDRSharp.exe
	sleep, 100
	; Run "D:\apps\sdrsharp-x86\SDRSharp\bin\SDRSharp.exe"
	Run "D:\SDRSharp\SDRSharp.exe"
	SetWorkingDir, %A_ScriptDir%
	return
}
return

appskey & v:: ; Activate/Run vid folder
IfWinExist, Videos
{
    WinActivate, Videos 
}
else
{
    Run, D:\vid
	sleep, 1000
	WinWait, vid
	WinMaximize

}
return

#+e:: ; Activate/Run D: Folder
IfWinExist, HDD (D:)
{
    WinActivate, HDD (D:)
}
else
{
    Run, D:\
	sleep, 1000
	WinWait, HDD (D:)
	WinMaximize

}
return

#+u:: ; Activate/Run AppData Folder
IfWinExist, AppData
{
    WinActivate, AppData
}
else
{
    Run, C:\Users\sb\AppData
	sleep, 1000
	WinWait, AppData
	WinMaximize

}
return

appskey & s::
IfWinExist, vlc
{
    WinActivate, vlc
}
else
{
    Run, D:\bat\vlc
	sleep, 1000
	WinWait, AppData
	WinMaximize

}
return
appskey & 1:: ; Activate/Run server folder
IfWinExist, server
{
    WinActivate, server 
}
else
{
    Run, D:\server
	sleep, 1000
	WinWait, vid
	WinMaximize

}
return

appskey & 2:: ; Activate/Run mmsys.cpl
IfWinExist, Sound
{
    WinActivate, Sound 
}
else
{
    Run, mmsys.cpl

}
return

appskey & l::  ; Activate/Run Local folder
IfWinExist, Local
{
    WinActivate, Local 
}
else
{
    Run, C:\Users\sb\AppData\Local
	sleep, 1000
	WinWait, Local
	WinMaximize

}
return


appskey & `;:: ; Activate/Run Roaming folder
IfWinExist, Roaming
{
    WinActivate, Roaming 
}
else
{
    Run, C:\Users\sb\AppData\Roaming
	sleep, 1000
	WinWait, Roaming
	WinMaximize

}
return

appskey & c:: ; Activate/Run bat folder

IfWinExist, bat
{
    WinActivate, bat
}
else
{
    Run, D:\bat
	sleep, 1000
	WinWait, bat
	WinMaximize

}
return

appskey & t:: ; Activate/Run test folder

IfWinExist, test
{
    WinActivate, test
}
else
{
    Run, D:\rex\test
	sleep, 1000
	WinWait, bat
	WinMaximize

}
return

appskey & g:: ; Activate/Run game folder

IfWinExist, game
{
    WinActivate, game
}
else
{
    Run, D:\bat\game
	sleep, 1000
	WinWait, game
	WinMaximize

}
return

appskey & h:: ; Activate/Run html folder

IfWinExist, html
{
    WinActivate, html
}
else
{
    Run, D:\windows\docs\html
	sleep, 1000
	WinWait, html
	WinMaximize

}
return

appskey & a:: ; Activate/Run apps folder

; IfWinExist, apps
IfWinExist, Downloads
{
    ; WinActivate, apps
    WinActivate, Downloads
}
else
{
    Run, D:\apps
    ; Run, Downloads
	sleep, 1000
	; WinWait, apps
	WinWait, Downloads
	WinMaximize

}
return

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

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

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


appskey & [:: ; Copy current time and window title to Clipboard
WinGetActiveTitle, Title
FormatTime, time, A_now, yyyy MM dd 
clipboard := time
clipboard = %clipboard% %Title%
return

appskey & z:: ; Run newest vid folder video in mpv

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
}
Folder = d:\vid
Folder2 = d:\vid\
Loop, %Folder%\*
{
	FileGetTime, Time, %A_LoopFileFullPath%, C
	If (Time > Time_Orig)
	{
		Time_Orig := Time
		File := A_LoopFileName
	}
}
; Run, %Folder2%%File%
Run, mpv.exe --af=dynaudnorm "%Folder2%%File%"
; Run, mpv.exe 
; SoundBeep
sleep, 4500
; WinWait, ahk_exe mpv.exe
; WinMove, ahk_exe mpv.exe,, -1083, 283, 1082, 639
; WinMove, ahk_exe mpv.exe,, -1083, 88, 1082, 639
WinMove, ahk_exe mpv.exe,, -1083, -4, 1083, 640
return

+NumpadMult:: ; Activate Sven Co-op
ChangeDisplayFrequency(280)
sleep, 100
WinActivate, Sven Co-op
return

+^!p:: ; Paste then empty clipboard
Send, ^v
Sleep, 200
clipboard = 
return


!#v:: ; Random Max 8 patcher
File = maxmsp.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Run, %RandLine%
return


!#u:: 
File = maxgen.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Run, %RandLine%
return


!#b:: ; Random Max 8 Help patcher
File = maxhelp.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Run, %RandLine%
return

!#i:: ; Random Max 8 Example patcher
File = maxexample.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Run, %RandLine%
return


!#f7:: ; Random Bible Verse
File = bible4.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
send, %RandLine%
return
		
		
!#3:: ; Random BIP 39 word
File = english.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
send, %RandLine%
return


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

; #m up::
; SendMessage, 0x112, 0xF170, 2,, Program Manager
; return


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



; Insert::
; Pause
; return


#b:: ; Random Ebook
File = pdf.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Run, %RandLine%
return

; f3::
; File = channels3.txt
; FileRead,FileContents,%File% 
; Sort,FileContents,Random 
; RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
; send /join
; send, {space down}
; send, {space up}
; send, %RandLine%
; return

; #c:: ; yt-dlp
; Send, ^c
; WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
; sleep, 200
; send, y
; send, {space down}
; send, {space up}
; Send, %Clipboard%
; send, {enter down}
; send, {enter up} 
; return

#c:: ; yt-dlp
Send, ^c
ifWinExist, /cygdrive/d/vid ahk_class VirtualConsoleClass
{
	WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
	WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
	sleep, 200
	send, y
	send, {space down}
	send, {space up}
	Send, %Clipboard%
	send, {enter down}
	send, {enter up} 
	return
}
else
{
	Run, "C:\Program Files\ConEmu\ConEmu64.exe"
	sleep, 100
	WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
	WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
	sleep, 200
	send, y
	send, {space down}
	send, {space up}
	Send, %Clipboard%
	send, {enter down}
	send, {enter up} 
	return
}


#0:: ; yt-dlp subtitles
Send, ^c
WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
sleep, 200
send, ys
send, {space down}
send, {space up}
; Send, ^v
Send, %Clipboard%
send, {enter down}
send, {enter up} 
return

#z:: ; yt-dlp and open in mpv
Send, ^c
WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
sleep, 200
send, yz
send, {space down}
send, {space up}
Send, %Clipboard%
; Send, ^v
send, {enter down}
send, {enter up} 
return

!f9:: ; Random spk in Sven Co-op
File = spk.txt
quote := """"
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Clipboard := RandLine
send, as_command .s_player_exec @all{space down}
send, {space up}
send, spk{space down}
send, {space up}
send, %RandLine%
return

^+c:: ; wget
Send, ^c
WinActivate, /cygdrive/d/apps ahk_class VirtualConsoleClass
WinWait, /cygdrive/d/apps ahk_class VirtualConsoleClass
sleep, 200
send, wg
send, {space down}
send, {space up}
Send, ^v
send, {enter down}
send, {enter up} 
return

!#c:: ; yt-dlp -f 18
Send, ^c
WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
sleep, 200
send, yt
send, {space down}
send, {space up}
Send, ^v
send, {enter down}
send, {enter up} 
return

; f7::
; return

#/:: ; yt-dlp Newgrounds Audio and load in foobar2000
Send, ^c
WinActivate, /cygdrive/d/ng ahk_class VirtualConsoleClass
WinWait, /cygdrive/d/ng ahk_class VirtualConsoleClass
sleep, 200
send, yn
send, {space down}
send, {space up}
Send, ^v
send, {enter down}
send, {enter up} 
return

; #5:: 
; Send, ^c
; WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
; sleep, 200
; send, y5
; send, {space down}
; send, {space up}
; Send, ^v
; send, {enter down}
; send, {enter up} 
; return

; #9:: 
; Send, ^c
; WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
; sleep, 200
; send, y9
; send, {space down}
; send, {space up}
; Send, ^v
; send, {enter down}
; send, {enter up} 
; return

; #0:: 
; Send, ^c
; WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
; sleep, 200
; send, y0
; send, {space down}
; send, {space up}
; Send, ^v
; send, {enter down}
; send, {enter up} 
; return

; !#5:: 
; Send, ^c
; WinActivate, /cygdrive/d/apps ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/apps ahk_class VirtualConsoleClass
; sleep, 200
; send, wg5
; send, {space down}
; send, {space up}
; Send, ^v
; send, {enter down}
; send, {enter up} 
; return

; !#9::
; Send, ^c
; WinActivate, /cygdrive/d/apps ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/apps ahk_class VirtualConsoleClass
; sleep, 200
; send, wg9
; send, {space down}
; send, {space up}
; Send, ^v
; send, {enter down}
; send, {enter up} 
; return

; !#0::
; Send, ^c
; WinActivate, /cygdrive/d/apps ahk_class VirtualConsoleClass
; WinWait, /cygdrive/d/apps ahk_class VirtualConsoleClass
; sleep, 200
; send, wg0
; send, {space down}
; send, {space up}
; Send, ^v
; send, {enter down}
; send, {enter up} 
; return

#v:: ; Paste Clipboard wrapped in quotes in ConEmu
quote := """"
WinActivate, /cygdrive/d/vid ahk_class VirtualConsoleClass
WinWait, /cygdrive/d/vid ahk_class VirtualConsoleClass
send, v
send, {space down}
send, {space up}
send %quote%
Send, ^v
send %quote%
send, {enter down}
send, {enter up} 
return

^f1:: ; Wait for a ping success and go to http://dishy.starlink.com/statistics
WinActivate, ahk_class VirtualConsoleClass
WinWait, ahk_class VirtualConsoleClass
send, g
send, {enter down}
send, {enter up} 
Run, http://dishy.starlink.com/statistics
return

Launch_App2::
; hwnd:=winexist("pi@raspberrypi: ~")
; DllCall( "SetParent", UInt,hwnd, UInt,DllCall( "GetShellWindow" ) )
return

Launch_Media::
return

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

#f:: ; Random Mouse Wheel movements
Random, rand, 1, 658
; Random, SleepAmount2, 1, 2
Random, test, 0, 1
if (test = 0) {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
    Click, WheelUp 
}
else {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
	Click, WheelDown 
}
return


!#f:: ; Random Mouse Wheel movements
Loop,
{
Random, rand, 1, 658
Random, test, 0, 1
if (test = 0) {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
    Click, WheelUp 
}
else {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
	Click, WheelDown 
}
}

!#g:: ; Random Mouse Wheel movements
Loop,
{
Random, rand, 1, 658
Random, rand2, 1, 1000
Random, test, 0, 1
if (test = 0) {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
    Click, WheelUp 
}
else {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
	Click, WheelDown 
}
sleep, %rand2%
}

!#h:: ; Random Mouse Wheel movements
Loop,
{
Random, rand, 1, 658
Random, rand2, 1, 6000
Random, test, 0, 1
if (test = 0) {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
    Click, WheelUp 
}
else {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
	Click, WheelDown 
}
sleep, %rand2%
}

!#j:: ; Random Mouse Wheel movements
Loop,
{
Random, rand, 1, 3000
Random, rand2, 1, 6000
Random, test, 0, 1
if (test = 0) {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
    Click, WheelUp 
}
else {
	WinActivate, ahk_class IrfanView
	WinWaitActive, ahk_class IrfanView
	Loop, %rand% 
	Click, WheelDown 
}
sleep, %rand2%
}

!6:: ; Toggle Display Discord Rich Presence for foobar2000
; Run "D:\foobar2000\foobar2000.exe" "/runcmd=View/Display Discord Rich Presence"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" "/runcmd=View/Display Discord Rich Presence"
return

^XButton2:: ; Random Track in foobar2000
; Run "D:\foobar2000\foobar2000.exe" "/runcmd=Playback/Random"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" "/runcmd=Playback/Random"
return

; ^+!e::
; Run "D:\foobar2000\foobar2000.exe" "/runcmd=Playback/Random"
; return

#n:: ; Windows Night Light
Run ms-settings:nightlight
return

#,:: ; Windows Updates
Run ms-settings:windowsupdate
return

#.:: ; Windows Taskbar
Run ms-settings:taskbar
return

#':: ; Windows Graphics
Run ms-settings:graphics
return


#[:: ; Windows Volume Mixer
Run C:\Windows\System32\SndVol.exe
return


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


^!#pause:: ; Block Keyboard and Mouse Input
blockinput,on
return


appskey & pause:: ; Holding Appskey and pressing Pause to abort 
    blockinput,off
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
return

+Volume_Down:: ; Seek Back by 1 second foobar2000
; Run "D:\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Back by 1 second"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Back by 1 second"
return
 
+Volume_Up:: ; Seek Ahead by 1 second foobar2000
; Run "D:\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Ahead by 1 second"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Ahead by 1 second"
return

^Volume_Down:: ; Seek Back by 10 seconds foobar2000
; Run "D:\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Back by 10 seconds"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Back by 10 seconds"
return

^Volume_Up:: ; Seek Ahead by 10 seconds foobar2000
; Run "D:\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Ahead by 10 seconds"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" /runcmd=Playback/Seek/"Ahead by 10 seconds"
return

#PrintScreen:: ; Press PrintScreen and paste in PaintDotNet
send, {PrintScreen}
Run "C:\Program Files\paint.net\PaintDotNet.exe"
WinWait, ahk_exe PaintDotNet.exe
Send, ^v
send, {enter down}
send, {enter up}
return

^+!k:: ; KING stuff
Clipboard:=
arr := ["IS KING", "IS king", "is king", "is KING", "is king?", "IS KING!"]
Random, oVar, arr.MinIndex(), arr.MaxIndex()
rand := arr[oVar]
File = dic.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Clipboard := RandLine
sleep, 10

send, %RandLine%
send, {space down}{space up}%rand%{space down}{space up}
return

#PgDn:: ; Get Current Weather
clipboard = 
; run C:\Users\sb\AppData\Local\Programs\Python\Python39\pythonw.exe d:/rex/test/weather6.py
run C:\Users\sb\AppData\Local\Programs\Python\Python39\pythonw.exe d:/rex/test/weather6stbay.py
SplashImage,,B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
Sleep,50
SplashImage,off
; sleep, 6000
return

!#PgDn:: ; Get Current Weather unformatted
clipboard = 
; run C:\Users\sb\AppData\Local\Programs\Python\Python39\pythonw.exe d:/rex/test/weather6nostar.py
run C:\Users\sb\AppData\Local\Programs\Python\Python39\pythonw.exe d:/rex/test/weather6stbaynostar.py
SplashImage,,B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
Sleep,50
SplashImage,off
; sleep, 6000
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
; sleep, 6000
return

#Pgup:: ; Get SysInfo 
clipboard = 
run D:\bat\sysinfochat.ahk
return

!#Pgup:: ; Get SysInfo  unformatted
clipboard = 
run D:\bat\sysinfochat2.ahk
return

^+!0:: ; Random Bible verse Sven Co-op
File = bible4.txt
quote := """"
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Clipboard := RandLine
sleep, 10
send, as_command .s_admin_say 0 1{space down}
send, {space up}
send, %quote%
send, %RandLine%
send, %quote%{space down}
send, {space up}
send, 8 @all 255 0 255 -1 -1
send, {enter down}
send, {enter up}
; sleep, 18500
return

^+!9:: ; Random Scientist Line Sven Co-op
File = sci.txt
quote := """"
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Clipboard := RandLine
send, .s_player_exec @all{space down}
send, {space up}
send, %quote%
send, spk{space down}
send, {space up}
send, %RandLine%
send, %quote%
send, {enter down}
send, {enter up}
return


numpaddiv:: ; Activate foobar2000 or ConEmu
; IfWinActive, ahk_exe D:\foobar2000\foobar2000.exe
IfWinActive, ahk_exe C:\Program Files (x86)\foobar2000\foobar2000.exe
{
	; send, {Mbutton up} 
    WinActivate ahk_exe ConEmu64.exe
	; sleep, 100
    return
}
else
{
	; send, {Mbutton up} 
    ; WinActivate ahk_exe D:\foobar2000\foobar2000.exe
    WinActivate ahk_exe C:\Program Files (x86)\foobar2000\foobar2000.exe
	; sleep, 100
    return
}
; WinActivate, ahk_exe D:\foobar2000\foobar2000.exe
return

numpadmult:: ; Activate foobar2000 or Firefox
; IfWinActive, ahk_exe D:\foobar2000b\foobar2000.exe
IfWinActive, ahk_exe C:\Program Files (x86)\foobar2000\foobar2000.exe
{
	; send, {Mbutton up} 
    WinActivate ahk_exe firefox.exe
	; sleep, 100
    return
}
else
{
	; send, {Mbutton up} 
    WinActivate ahk_exe D:\foobar2000b\foobar2000.exe
	; sleep, 100
    return
}
; WinActivate, ahk_exe D:\foobar2000\foobar2000.exe
return

numpadsub:: ; Activate foobar2000 or Pale Moon
IfWinActive, ahk_exe D:\foobar2000c\foobar2000.exe
{
	; send, {Mbutton up} 
    WinActivate ahk_exe palemoon.exe
	; sleep, 100
    return
}
else
{
	; send, {Mbutton up} 
    WinActivate ahk_exe D:\foobar2000c\foobar2000.exe
	; sleep, 100
    return
}
; WinActivate, ahk_exe D:\foobar2000\foobar2000.exe
return




#!p:: ; Append URL in Clipboard to random urls file
IF Clipboard contains https,http
	{
	Fileappend,`n%clipboard%, rand.txt
	WinSet, AlwaysOnTop, Toggle,A
	SplashImage,,B w%A_ScreenWidth% h%A_ScreenHeight% cwBlack NA
	Sleep,50
	SplashImage,off
	return
	} else {
	SoundBeep
	return
	}

#!-:: ; Random Jeopardy! game
Random, rd, 1, 7344
Run https://j-archive.com/showgame.php?game_id=%rd%
return



XButton2 & MButton:: ; Random foobar2000 track
; Run "D:\foobar2000\foobar2000.exe" "/runcmd=Playback/Random"
Run "C:\Program Files (x86)\foobar2000\foobar2000.exe" "/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")
; send, ^r
send, r
else
IfWinActive, ahk_exe ConEmu64.exe
{
	; send, {Mbutton up} 
	; send, {XButton2 up} 
	; send, {XButton2 up} 
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 10
    WinActivate ahk_exe mintty.exe
	; WinWait, ahk_exe D:\foobar2000b\foobar2000.exe
	; sleep, 100
    return
}
else
{
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 10
    WinActivate ahk_exe ConEmu64.exe
    return
}
return

XButton1:: ; Activate Ableton or Renoise
IfWinActive, ahk_exe renoise.exe
{
	send, {Mbutton up} 
    WinActivate ahk_exe Ableton Live 11 Suite.exe
	sleep, 100
    return
}
else
{
	send, {Mbutton up} 
    WinActivate ahk_exe renoise.exe
	sleep, 100
    return
}
return

!Capslock:: ; Random Wikipedia Article etcF
File = rand.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
Run, %RandLine%
SetTitleMatchMode, 2
sleep, 2000
get := GetURL2("Brave")
GetURL2(wTitle*) {
	ErrorLevel := 0
	if !(wId := WinExist(wTitle*)) {
		ErrorLevel := 1
		return
	}
	IUIAutomation := ComObjCreate(CLSID_CUIAutomation := "{ff48dba4-60ef-4201-aa87-54103eef594e}", IID_IUIAutomation := "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
	DllCall(NumGet(NumGet(IUIAutomation+0)+6*A_PtrSize), "ptr", IUIAutomation, "ptr", wId, "ptr*", elementMain)   ; IUIAutomation::ElementFromHandle
	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)
	if (A_PtrSize = 4) {
		DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "int64", NumGet(addressbar, 0, "int64"), "int64", NumGet(addressbar, 8, "int64"), "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	} else {
		DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "ptr", &addressbar, "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	}
	DllCall(NumGet(NumGet(elementMain+0)+5*A_PtrSize), "ptr", elementMain, "int", TreeScope_Descendants := 0x4, "ptr", addressbarCondition, "ptr*", currentURLElement) ; IUIAutomationElement::FindFirst
	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) ;IUIAutomationElement::GetCurrentPropertyValue
	ObjRelease(currentURLElement)
	ObjRelease(elementMain)
	ObjRelease(IUIAutomation)
	return StrGet(NumGet(currentURL,8,"ptr"),"utf-16")
}
FileAppend, `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%`n, his.txt
Fileappend,%get%`n, his.txt
SetTitleMatchMode, 1
sleep, 100
return

!+z:: ; Random 1001 Album + rym top albums in Amazon music
File = albums.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
; Run, "C:\Program Files\Mozilla Firefox\firefox.exe" https://music.amazon.ca/search/%RandLine%
Run, "D:\windows\LibreWolf\librewolf.exe" https://music.amazon.ca/search/%RandLine%
return


!+x:: ; Random Dave vid
File = dave.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
Run, %RandLine%
return

!+c:: ; Random Vancity vid
File = van.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
Run, %RandLine%

return

^!c:: ; Random Chess article
File = chess2.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
Run, %RandLine%
SetTitleMatchMode, 2
sleep, 2000
get := GetURL22("Brave")
GetURL22(wTitle*) {
	ErrorLevel := 0
	if !(wId := WinExist(wTitle*)) {
		ErrorLevel := 1
		return
	}
	IUIAutomation := ComObjCreate(CLSID_CUIAutomation := "{ff48dba4-60ef-4201-aa87-54103eef594e}", IID_IUIAutomation := "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
	DllCall(NumGet(NumGet(IUIAutomation+0)+6*A_PtrSize), "ptr", IUIAutomation, "ptr", wId, "ptr*", elementMain)   ; IUIAutomation::ElementFromHandle
	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)
	if (A_PtrSize = 4) {
		DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "int64", NumGet(addressbar, 0, "int64"), "int64", NumGet(addressbar, 8, "int64"), "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	} else {
		DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "ptr", IUIAutomation, "int", 30005, "ptr", &addressbar, "ptr*", addressbarCondition)   ; IUIAutomation::CreatePropertyCondition
	}
	DllCall(NumGet(NumGet(elementMain+0)+5*A_PtrSize), "ptr", elementMain, "int", TreeScope_Descendants := 0x4, "ptr", addressbarCondition, "ptr*", currentURLElement) ; IUIAutomationElement::FindFirst
	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) ;IUIAutomationElement::GetCurrentPropertyValue
	ObjRelease(currentURLElement)
	ObjRelease(elementMain)
	ObjRelease(IUIAutomation)
	return StrGet(NumGet(currentURL,8,"ptr"),"utf-16")
}
FileAppend, `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%`n, his.txt
Fileappend,%get%`n, his.txt
SetTitleMatchMode, 1
sleep, 100
return

!3:: ; Random Terry 2017
File = terry2017.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
SetWorkingDir D:\Terry A. Davis - TempleOS Archive\videos\2017
Run, %RandLine%
SetWorkingDir %A_ScriptDir%
return

!4:: ; Random Terry 2017b
File = terry2017b.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
SetWorkingDir D:\Terry A. Davis - TempleOS Archive\videos\2017
Run, %RandLine%
SetWorkingDir %A_ScriptDir%
return

!5:: ; Random Terry 2018
File = terry2018.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
SetWorkingDir D:\Terry A. Davis - TempleOS Archive\videos\2018
Run, %RandLine%
SetWorkingDir %A_ScriptDir%
return

^F2:: ; Get parent window
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

^!v:: ; Resize and move video to Secondary Monitor
; WinGetTitle, WindowTitle, A
; WinMove, ahk_exe mpv.exe,, -1083, 283, 1082, 639
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

; !f5:: ; Resize and move video to Secondary Monitor
; WinMove, ahk_exe mpv.exe,, -1083, 88, 1083, 640
; WinMove, ahk_exe vlc.exe,, -1083, 88, 1083, 640
; WinMove, ahk_exe sunvox.exe,, -1087, -378, 1088, 1010
; WinMove, Picture in picture,, -1083, 88, 1083, 640
; SetTitleMatchMode, 2
; WinMove, HomeSafe View,, -1282, 556, 1080, 1024
; WinMove, Agent: Agent DVR - Chromium,, -1083, 478, 1080, 1001
; SetTitleMatchMode, 1
; return

!9:: ; Resize and move AgentDVR to Secondary Monitor
; WinGetTitle, WindowTitle, A
; WinMove, ahk_exe mpv.exe,, -1083, 283, 1082, 639
; -1083	y: 478	w: 1087	h: 1001
; WinMove, Agent: Agent DVR - Brave,, -1083, 478, 1080, 1001
SetTitleMatchMode, 2
WinMove, Agent: Agent DVR - Chromium,, -1083, 478, 1080, 1001
SetTitleMatchMode, 1
return

+^f:: ; Get the Path to the Selected File in Explorer. 
      hwnd := WinExist("A")
      for Window in ComObjCreate("Shell.Application").Windows  
          if (window.hwnd==hwnd) {
              Selection := Window.Document.SelectedItems
              for Items in Selection
                  Path_to_Selection := Items.path
          }

      Clipboard := Path_to_Selection
	  SoundBeep

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
SetTitleMatchMode, 2
WinMove, Agent: Agent DVR - Chromium,, -1083, 478, 1080, 1001
WinMove, https://www.youtube.com/live_chat,, -1085, -418, 1086, 431
SetTitleMatchMode, 1
return

^f5:: ; Resize and move yt chat to Secondary Monitor
; WinGetTitle, WindowTitle, A
; WinMove, ahk_exe mpv.exe,, -1083, 283, 1082, 639
WinMove, https://www.youtube.com/live_chat,, -1085, -418, 1086, 431
return

#!n:: ; open todays SDRSharp recordings
FormatTime, sdr, A_now, yyyy_MM_dd
Run, D:\%sdr%\Misc\410.450 MHz 410.450 MHz NFM
; Run, D:\apps\sdrsharp\Audio
return

IfWinExist, 410.450 MHz 410.450 MHz NFM
{
    WinActivate, 410.450 MHz 410.450 MHz NFM
}
else
{
	FormatTime, sdr, A_now, yyyy_MM_dd
	Run, D:\%sdr%\Misc\410.450 MHz 410.450 MHz NFM
	return
}


#!8:: ; open recent SDRSharp recording in Audacity
FormatTime, sdr, A_now, yyyy_MM_dd
Fol = D:\%sdr%\Misc\410.450 MHz 410.450 MHz NFM
; Fol = D:\apps\sdrsharp\Audio
; Fol2 = D:\apps\sdrsharp\Audio\
Fol2 = D:\%sdr%\Misc\410.450 MHz 410.450 MHz NFM\
Loop, %Fol%\*
{
	FileGetTime, Time, %A_LoopFileFullPath%, C
	If (Time > Time_Orig)
	{
		Time_Orig := Time
		File2 := A_LoopFileName
	}
}
; Run, %Folder2%%File%
Run, "C:\Program Files\Audacity\Audacity.exe" "%Fol2%%File2%"
return

; Misc\410.450 MHz 410.450 MHz NFM

#!9:: ; open yesterday SDRSharp recording in Audacity
yday += -1, days
formattime,yday, %yday%, yyyy_MM_dd
Fol = D:\%yday%\Misc\410.450 MHz 410.450 MHz NFM
Fol2 = D:\%yday%\Misc\410.450 MHz 410.450 MHz NFM\
Loop, %Fol%\*
{
	FileGetTime, Time, %A_LoopFileFullPath%, C
	If (Time > Time_Orig)
	{
		Time_Orig := Time
		File3 := A_LoopFileName
	}
}
; Run, %Folder2%%File%
Run, "C:\Program Files\Audacity\Audacity.exe" "%Fol2%%File3%"
return

appskey & 9:: ; Activate/Run/Sync camera folder

IfWinExist, cam
{
	; Run, C:\cygwin64\bin\mintty.exe -e /bin/rsync -auvP  -e /bin/ssh  [email protected]:/media/pi/easystore/cam/ /cygdrive/d/cam/
	Run, C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -h always -e /usr/bin/bash /cygdrive/d/bat/podsync.sh
    WinActivate, video
}
else
{
	; Run, C:\cygwin64\bin\mintty.exe -e /bin/rsync -auvP  -e /bin/ssh  [email protected]:/media/pi/easystore/cam/ /cygdrive/d/cam/
	Run, C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -h always -e /usr/bin/bash /cygdrive/d/bat/podsync.sh
    Run, D:\cam\video\
	sleep, 1000
	WinWait, video
	WinMaximize

}
return

!7:: ; Random endgame FEN
File = endgame.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Clipboard := RandLine
return

Auto