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/

; #InstallKeybdHook
#SingleInstance force
SetWorkingDir %A_ScriptDir%
#include group.ahk
; Menu, Tray, Icon, power.ico 
Menu, Tray, Icon, p.ico 
; SetTitleMatchMode, 2
; #Persistent
; global hold := false
; return
;NumpadMult::

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

^!NumpadAdd::
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::
; Balanced
Run C:\Windows\System32\powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
TrayTip, Power Control, Balanced mode CHECK SPEAKERS, 20, 17
return

#!NumpadAdd::
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::
Loop, 1500
{
send, a
sleep 800
}
return

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

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

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

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

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

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

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

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

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

f7::
FormatTime, time, A_now, yyyy-MM-dd 
WinGetActiveTitle, title
var2 := RegExReplace(title, "i)[^a-z0-9 ]")
StringTrimRight, clip, var2, 7
; Clipboard := time " " var2 ".html"
Clipboard := time " " clip ".html"
return

!f3::
; 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::
clip := clipboard
StringTrimRight, OutputVar, clip, 15
send, gp
send, {space down}
send, {space up}
sendinput %OutputVar%
return


!w::
Send ^x
Sleep, 100
ClipWait
Clipboard="%Clipboard%"
Sleep, 100
ClipWait
Send ^v
return

^+!v::
Clipboard='%Clipboard%'
Sleep, 100
ClipWait
Send ^v
return

^+!b::
Clipboard="%Clipboard%"
Sleep, 100
ClipWait
Send ^v
return

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

^F2::
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

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

+NumpadAdd::
WinActivate, ahk_class Renoise
return

+NumpadDiv::
WinActivate, Learning PHP
return

+NumpadSub::
WinActivate, ahk_class SunDogEngine
return

appskey & b::
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::
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::
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::
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::
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::
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::
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::
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::
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::
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 & '::
; 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 & \::
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::
IfWinExist, vid
{
    WinActivate, vid 
}
else
{
    Run, D:\vid
	sleep, 1000
	WinWait, vid
	WinMaximize

}
return

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

}
return

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

}
return


appskey & 1::
IfWinExist, server
{
    WinActivate, server 
}
else
{
    Run, D:\server
	sleep, 1000
	WinWait, vid
	WinMaximize

}
return

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

}
return

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

}
return


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

}
return

appskey & c::

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

}
return

appskey & t::

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

}
return

appskey & g::

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

}
return

appskey & h::

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

}
return

appskey & a::

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

}
return

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

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

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


appskey & [::
WinGetActiveTitle, Title
FormatTime, time, A_now, yyyy MM dd 
clipboard := time
clipboard = %clipboard% %Title%
return

+NumpadMult::
WinActivate, ahk_class SDL_app
return

^!v::
Send, ^v
Sleep, 200
clipboard = 
return

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

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

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

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

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

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


!#m::
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::
Suspend
return

; Insert::
; Pause
; return

; random ebook
#b::
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

; youtube-dl
#c::
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, ^v
send, {enter down}
send, {enter up} 
return

#z::
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, ^v
send, {enter down}
send, {enter up} 
return

!f9::
File = spk.txt
quote := """"
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1) 
Clipboard := RandLine
; send, {`` down}
; send, {`` up}
; sleep, 10
; send, .player_exec @me{space down}
; send, {space up}
; send, %quote%
; send, spk{space down}
; send, {space up}
; sendinput %Clipboard%
; send, %RandLine%
; send, %quote%
; send, {enter down}
; send, {enter up}
; sleep, 10
send, as_command .s_player_exec @all{space down}
send, {space up}
; send, %quote%
send, spk{space down}
send, {space up}
; sendinput %Clipboard%
send, %RandLine%
; send, %quote%
; sleep, 18500
return


MButton::
send, {Mbutton down}
return

MButton Up::
send, {Mbutton up} 
return

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

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

; MButton & XButton2::
; Run "D:\foobar2000\foobar2000.exe" "/runcmd=Playback/Random"
; return


MButton & XButton1::
IfWinActive, ahk_exe firefox.exe
{
	; send, {Mbutton up} 
    WinActivate ahk_exe palemoon.exe
	; sleep, 100
    return
}
else
{
	; send, {Mbutton up} 
    WinActivate ahk_exe firefox.exe
	; sleep, 100
    return
}
; send, {Mbutton up} 
; send, {Xbutton1 up} 
return

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

; wget
^+c::
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::
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

#/::
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::
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

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

Launch_Media::
return

^#t::
WinSet, AlwaysOnTop, Toggle,A
return

#f::
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::
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::
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::
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::
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::
; 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::
; 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::
Run ms-settings:nightlight
return

#,::
Run ms-settings:windowsupdate
return

#.::
Run ms-settings:taskbar
return

#'::
Run ms-settings:graphics
return


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

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

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

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

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

^+v::
StringReplace, clipboard, clipboard,`r`n,, All
Send ^v
return

; block keyboard and mouse input
^!#pause::
blockinput,on
return

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

+Volume_Down::
; 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::
; 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::
; 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::
; 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::
send, {PrintScreen}
Run "C:\Program Files\paint.net\PaintDotNet.exe"
WinWait, ahk_exe PaintDotNet.exe
Send, ^v
send, {enter down}
send, {enter up}
return

#PgDn::
clipboard = 
run C:\Users\sb\AppData\Local\Programs\Python\Python39\pythonw.exe d:/rex/test/weather5.py
sleep, 6000
return

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

!#Pgup::
clipboard = 
run D:\bat\sysinfochat2.ahk
return

^+!0::
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::
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::
; 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::
; 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::
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::
IF Clipboard contains https,http
	{
	Fileappend,`n%clipboard%, rand.txt
	return
	} else {
	SoundBeep
	return
	}
#!-::
Random, rd, 1, 7344
Run https://j-archive.com/showgame.php?game_id=%rd%
return

!Capslock::
File = rand.txt
FileRead,FileContents,%File% 
Sort,FileContents,Random 
RandLine := SubStr(FileContents,1,InStr(FileContents,"`r")-1)
Run, %RandLine%
SetTitleMatchMode, 2
sleep, 2000
get := 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")
}
FileAppend, `n%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%`n, his.txt
Fileappend,%get%`n, his.txt
SetTitleMatchMode, 1
return

appskey & -::
vFlags := 0x0 ;off
vSize := A_PtrSize=8?16:12
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
;HCF_HIGHCONTRASTON := 0x1
NumPut(vFlags, &HIGHCONTRAST, 4, "UInt") ;dwFlags
;SPI_SETHIGHCONTRAST := 0x43
DllCall("user32\SystemParametersInfo", UInt,0x43, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
return

appskey & =::
vFlags := 0x1 ;on
vSize := A_PtrSize=8?16:12
VarSetCapacity(HIGHCONTRAST, vSize, 0)
NumPut(vSize, &HIGHCONTRAST, 0, "UInt") ;cbSize
;HCF_HIGHCONTRASTON := 0x1
NumPut(vFlags, &HIGHCONTRAST, 4, "UInt") ;dwFlags
;SPI_SETHIGHCONTRAST := 0x43
DllCall("user32\SystemParametersInfo", UInt,0x43, UInt,vSize, Ptr,&HIGHCONTRAST, UInt,0)
Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
return


XButton2::
if WinActive("ahk_exe firefox.exe") or WinActive("ahk_exe librewolf.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, {Mbutton up} 
	; send, {XButton2 up} 
	; send, {XButton2 up} 
	Send, {Alt Up}{Shift Up}{ctrl Up}{lwin up}
	sleep, 10
    WinActivate ahk_exe ConEmu64.exe
	; WinWait, ahk_exe D:\foobar2000\foobar2000.exe
	; sleep, 100
    return
}
return

XButton1::
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