Re: Gaming Profile
Posted: 25 Nov 2021, 21:27
At a Windows command prompt, you can type sc query to see the names of all Windows services. You can then update line 1 with your service's name.
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=18&t=96870
Code: Select all
RunWait, % "net " (start) fxssvc.exe
Code: Select all
If !A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
}
proc = fxssvc
svcName := svcName(proc)
F3::service(svcName) ; Start service
F4::service(svcName, False) ; Stop service
service(name, start := True) {
RunWait, % "net " (start ? "start " : "stop ") name,, Hide
}
svcName(proc) {
Clipboard =
RunWait, %ComSpec% /c "wmic service where "pathname like '`%%proc%.exe`%'" get name`,pathname| clip",, Hide
ClipWait, 0
If !ErrorLevel {
RegExMatch(Clipboard, "(.+?) +?.*" proc, m)
Return m1
} Else MsgBox, 48, Error, An error occurred while waiting for the clipboard.
}
Code: Select all
RunWait,Powershell Stop-service -name wuauserv,,hide ; first way, this stops the windows update service using powershell
RunWait,SC Stop "wuauserv",,hide ; this will stop the service via command line.
RunWait,net Stop "wuauserv",,hide
Code: Select all
;RunWait,sc config "wuauserv" start= Disabled,,hide ; stoped auto start
;RunWait,net Stop "wuauserv",,hide ; Stoped the service
RunWait,sc config "wuauserv" start= Auto,,hide ; Set to auto start
RunWait,net Start "wuauserv",,hide ; started the service
Code: Select all
#SingleInstance Force ; Forces a Single instance
#Warn ; Enable warnings to assist with detecting common errors.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#NoTrayIcon ; Disable the tray icon of the script
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;SetBatchLines, -1 ; Run script at maximum speed
SetCapsLockState, AlwaysOff ; Disables the caps lock key and defaults off
games = Games.txt ; Name of my Input file
If !FileExist(games)
{
MsgBox, 48, Error, File not found.`n`n%games%
Return
}
Else
FileRead, text, %games%
For each, game in StrSplit(text, ",")
{
lastChar := SubStr(game, 0), thisGame := lastChar = "e" ? game : SubStr(game, 1, -1)
GroupAdd, fun , ahk_exe %thisGame%
GroupAdd, last%lastChar%, ahk_exe %thisGame%
}
Goto, Str
Hi:
Run, powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Return
Bal:
Runwait, powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
Return
Low:
RunWait, powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a
Return
Str:
loop
{
If WinExist("ahk_group last1")
{
Gosub, Hi
MsgBox, High Performance Power Profile.`n *GPU Overclock*`n Activated
WinWaitClose, ahk_group last1 ; Wait for all matching windows to close
GoSub, Low
MsgBox, Power Saving Profile.`n GPU Normal`n Activated
}
Else If WinExist("ahk_group fun")
{
Gosub, Bal
MsgBox, Balance Power Profile.`n *GPU Underclock* `n Activated
WinWaitClose, ahk_group fun ; Wait for all matching windows to close
GoSub, Low
MsgBox, Power Saving Profile.`n GPU Normal`n Activated
}
}
#IfWinActive ahk_group last1 ; Check if this group is running (High Performance Games)
; LWin::Return ; Disables Left windows Key
!Tab::Return ; Disables Alt Tab
#IfWinActive ahk_group fun ; will do the below always
; CapsLock::Return ; Disables capslock, Not used as I use caps state always off above while this app is running.
#IfWinActive
Code: Select all
; First, we're calling Window's GetCommandLine() function
; This function retrieves the command-line string for the current process
; We need this string to see if the script is running with the /restart switch
full_command_line := DllCall("GetCommandLine", "str")
; This if-check fires if either of the 2 evaluations are true
; Note the 'not' prefix. This if check fires when 'not' true (false)
; 1) If the script is 'not' running as admin (A_IsAdmin stores whether a script has admin rights)
; OR
; 2) If the full_command_line from above does 'not' contain /restart
; /Restart is a command line switch that tells the script "this is a restart, not a normal load"
; This affects some internal things as well as prevents #SingleInstance notifications
; This if-check makes sure that every script is forced to restart with the *RunAs verb
; This ensures the script is always given a chance to launch with elevated rights
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
; Try is used so that any runtime errors are suppressed
try
{
; The next if check makes sure that .ahk and .exe scripts are restarted correctly
; Check if the current script is compiled (.exe) or a script (.ahk)
if A_IsCompiled
; If compiled, restart using the exe method:
; CompiledScript.exe [Switches] [Script Parameters]
; This is covered in the script docs. Link below code.
Run *RunAs "%A_ScriptFullPath%" /restart
else
; If not compiled, restart using the script method:
; AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
; ExitApp to close this script because we're restarting it with a request for admin rights
ExitApp
}
; At this point, the script HAS been restarted and is running with admin rights if it can
; MsgBox A_IsAdmin: %A_IsAdmin%`nCommand line: %full_command_line%
#SingleInstance Force ; Forces a Single instance
#Warn ; Enable warnings to assist with detecting common errors.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #NoTrayIcon ; Disable the tray icon of the script
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; SetBatchLines, -1 ; Run script at maximum speed
SetCapsLockState, AlwaysOff ; Disables the caps lock key and defaults off
games = Games.txt ; Name of my Input file
If !FileExist(games)
{
MsgBox, 48, Error, File not found.`n`n%games%
Return
}
Else
FileRead, text, %games%
For each, game in StrSplit(text, ",")
{
lastChar := SubStr(game, 0), thisGame := lastChar = "e" ? game : SubStr(game, 1, -1)
GroupAdd, fun , ahk_exe %thisGame%
GroupAdd, last%lastChar%, ahk_exe %thisGame%
}
Goto, Str
Hi:
RunWait, powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
RunWait, C:\Program Files (x86)\My Tool's\NV Inspector\nvidiaInspector.exe -setBaseClockOffset:0`,0`,22 -setMemoryClockOffset:0`,0`,200 -setPowerTarget:0`,114 -setTempTarget:0`,0`,80
Return
Bal:
RunWait, powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
RunWait, C:\Program Files (x86)\My Tool's\NV Inspector\nvidiaInspector.exe -setBaseClockOffset:0`,0`,-300 -setMemoryClockOffset:0`,0`,-400 -setPowerTarget:0`,80 -setTempTarget:0`,0`,80
Return
Low:
RunWait, powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a
RunWait, C:\Program Files (x86)\My Tool's\NV Inspector\nvidiaInspector.exe -setBaseClockOffset:0`,0`,0 -setMemoryClockOffset:0`,0`,0 -setPowerTarget:0`,100 -setTempTarget:0`,0`,80
Return
SvcSt: ; Start services
; Acronis Nonstop Backup Service
Run,sc config "afcdpsrv" start= Auto,,hide ; auto start
RunWait,net Start "afcdpsrv",,hide ; Start service
; Acronis Scheduler2 Service
Run,sc config "AcrSch2Svc" start= Auto,,hide ; auto start
RunWait,net Start "AcrSch2Svc",,hide ; start service
; Connected Devices Platform Service
Run,sc config "CDPSvc" start= Delayed-Auto,,hide ; delayed auto start
RunWait,net Start "CDPSvc",,hide ; Start service
; Connected User Experiences and Telemetry
Run,sc config "DiagTrack" start= Auto,,hide ; auto start
RunWait,net Start "DiagTrack",,hide ; Start service
; Distributed Link Tracking Client
Run,sc config "TrkWks" start= Auto,,hide ; auto start
RunWait,net Start "TrkWks",,hide ; Start service
; Geolocation Service
Run,sc config "lfsvc" start= Demand,,hide ; Manual start
; RunWait,net Start "lfsvc",,hide ; Dont need to Start the service
; LGHUB Updater Service
Run,sc config "LGHUBUpdaterService" start= Delayed-Auto,,hide ; Auto start Changed to delayed
RunWait,net Start "LGHUBUpdaterService",,hide ; Start service
; Microsoft Office Click-to-Run Service
; Run,sc config "ClickToRunSvc" start= Delayed-Auto,,hide ; auto delay start
; RunWait,net Start "ClickToRunSvc",,hide ; Start service
; Network Connected Devices Auto-Setup
Run,sc config "NcdAutoSetup" start= Demand,,hide ; Manual start
RunWait,net Start "NcdAutoSetup",,hide ; Start service
; Portable Device Enumerator Service
Run,sc config "WPDBusEnum" start= Demand,,hide ; Manual auto start
;RunWait,net Start "WPDBusEnum",,hide ; Dont need to Start the service
; Print Spooler
Run,sc config "Spooler" start= Auto,,hide ; auto start
RunWait,net Start "Spooler",,hide ; Start service
; Program Compatibility Assistant Service
Run,sc config "PcaSvc" start= Delayed-Auto,,hide ; auto Delay start
RunWait,net Start "PcaSvc",,hide ; Start service
; Simple TCP/IP Services
; Run,sc config "simptcp" start= Auto,,hide ; auto start
; RunWait,net Start "simptcp",,hide ; Start service
; Server
Run,sc config "LanmanServer" start= Delayed-Auto,,hide ; auto start
RunWait,net Start "LanmanServer",,hide ; Start service
; SysMain
Run,sc config "SysMain" start= Auto,,hide ; auto start
RunWait,net Start "SysMain",,hide ; Start service
; Windows Image Acquisition (WIA)
Run,sc config "StiSvc" start= Demand,,hide ; Manual start
RunWait,net Start "StiSvc",,hide ; Start service
; Windows Media Player Network Sharing Service
Run,sc config "WMPNetworkSvc" start= Delayed-Auto,,hide ; Stopped auto start
RunWait,net Start "WMPNetworkSvc",,hide ; Stopped the service
; Windows Search
Run,sc config "WSearch" start= Delayed-Auto,,hide ; auto Delay start
RunWait,net Start "WSearch",,hide ; Start service
; Windows Update
Run,sc config "wuauserv" start= Demand,,hide ; auto start
; RunWait,net Start "wuauserv",,hide ; Dont need to Start the service
; WLAN AutoConfig
Run,sc config "WlanSvc" start= Auto,,hide ; Auto start
RunWait,net Start "WlanSvc",,hide ; Start service
Return
SvcSP: ; Stop services
; Acronis Nonstop Backup Service
Run,sc config "afcdpsrv" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "afcdpsrv",,hide ; Stopped the service
; Acronis Scheduler2 Service
Run,sc config "AcrSch2Svc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "AcrSch2Svc",,hide ; Stopped the service
; Connected Devices Platform Service
Run,sc config "CDPSvc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "CDPSvc",,hide ; Stopped the service
; Connected User Experiences and Telemetry
Run,sc config "DiagTrack" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "DiagTrack",,hide ; Stopped the service
; Distributed Link Tracking Client
Run,sc config "TrkWks" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "TrkWks",,hide ; Stopped the service
; Geolocation Service
Run,sc config "lfsvc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "lfsvc",,hide ; Stopped the service
; LGHUB Updater Service
Run,sc config "LGHUBUpdaterService" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "LGHUBUpdaterService",,hide ; Stopped the service
; Microsoft Office Click-to-Run Service
; Run,sc config "ClickToRunSvc" start= Disabled,,hide ; Stopped auto start
; RunWait,net Stop "ClickToRunSvc",,hide ; Stopped the service
; Network Connected Devices Auto-Setup
Run,sc config "NcdAutoSetup" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "NcdAutoSetup",,hide ; Stopped the service
; Portable Device Enumerator Service
Run,sc config "WPDBusEnum" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "WPDBusEnum",,hide ; Stopped the service
; Print Spooler
Run,sc config "Spooler" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "Spooler",,hide ; Stopped the service
; Program Compatibility Assistant Service
Run,sc config "PcaSvc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "PcaSvc",,hide ; Stopped the service
; Simple TCP/IP Services
; Run,sc config "simptcp" start= Disabled,,hide ; Stopped auto start
; RunWait,net Stop "simptcp",,hide ; Stopped the service
; Server
Run,sc config "LanmanServer" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "LanmanServer",,hide ; Stopped the service
; SysMain
Run,sc config "SysMain" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "SysMain",,hide ; Stopped the service
; Windows Image Acquisition (WIA)
Run,sc config "StiSvc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "StiSvc",,hide ; Stopped the service
; Windows Media Player Network Sharing Service
Run,sc config "WMPNetworkSvc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "WMPNetworkSvc",,hide ; Stopped the service
; Windows Search
Run,sc config "WSearch" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "WSearch",,hide ; Stopped the service
; Windows Update
Run,sc config "wuauserv" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "wuauserv",,hide ; Stopped the service
; WLAN AutoConfig
Run,sc config "WlanSvc" start= Disabled,,hide ; Stopped auto start
RunWait,net Stop "WlanSvc",,hide ; Stopped the service
Return
Str:
loop
{
If WinExist("ahk_group last1")
{
GoSub, Hi ; High Power Profile and OC GPU
GoSub, SvcSP ; Stop Services
MsgBox, High Performance Power Profile.`n GPU Overclock`n Activated
WinWaitClose, ahk_group last1 ; Wait for all matching windows to close
GoSub, Low ; Power saving profile , Default GPU
GoSub, SvcST ; Start Services
MsgBox, Power Saving Profile.`n Default GPU`n Activated
}
Else If WinExist("ahk_group fun")
{
GoSub, Bal ; Balance power profile, GPU Underclocked
GoSub, SvcSP ; Stop Services
MsgBox, Balance Power Profile.`n GPU Underclock`n Activated
WinWaitClose, ahk_group fun ; Wait for all matching windows to close
GoSub, Low ; Power saving profile , Default GPU
GoSub, SvcST ; Start Services
MsgBox, Power Saving Profile.`n Default GPU`n Activated
}
}
#IfWinActive ahk_group last1 ; Check if this group is running (High Performance profile)
; LWin::Return ; Disables Left windows Key
!Tab::Return ; Disables Alt Tab
#IfWinActive ahk_group fun ; will do the below always
; CapsLock::Return ; Disables capslock, Not used as I use caps state always off above while this app is running.
#IfWinActive
Code: Select all
Anno1800.exe, ES2-Win64-Shipping.exe1, Notepad.exe
Code: Select all
Anno1800.exe, ES2-Win64-Shipping.exe1, Notepad.exe1
If I run notepad.exe1 it then reads ES2-Win64-Shipping.exe1TrebleTA wrote: ↑04 Dec 2021, 11:55there seems to be something wrong with how its reading the games.txtIf I run es2-win64-shipping it runs ahk_group funCode: Select all
Anno1800.exe, ES2-Win64-Shipping.exe1, Notepad.exe
yet if I do it like this it runs ahk_group last1Code: Select all
Anno1800.exe, ES2-Win64-Shipping.exe1, Notepad.exe1