Hi all, and a big thank you for AHK.
I think I'll ask here, as sure your sort it in minutes but I after a AHK so it will detect a game, and then will run commands, say if that game is running it will change power profile, or other commands. But then detects the game has close and then revert changes.
Thank in advance
Gaming Profile Topic is solved
Re: Gaming Profile
Code: Select all
Loop {
WinWait, ahk_exe notepad.exe
MsgBox, Command #1
WinWaitClose
MsgBox, Command #2
}
Re: Gaming Profile
So say the game exe is world of warcraft so wow.exe then will swap power profile so be powercfg -setactive etc
So notepad.exe = wow.exe
Command #1 = powercfg -setactive
Is that right?
So notepad.exe = wow.exe
Command #1 = powercfg -setactive
Is that right?
Re: Gaming Profile
Also say I wanted ahk to read a file that has a list of game exe in it with say a command so be like wow.exe1, anno.exe, etc
The 1 would point to a different command?
The 1 would point to a different command?
Re: Gaming Profile
Yes, you can make those substitutions. Use Run to run your powercfg. I am not sure how you want to configure your text file, but FileRead or FileReadLine can read it.
Re: Gaming Profile
@mikeyww thanks for the help.
I'm not at home at the moment will be in a hour or 2, my miss had got me out and about.
So will start trying to get this working then. But how would you think it is best?
To get me started
Thanks again
I'm not at home at the moment will be in a hour or 2, my miss had got me out and about.
So will start trying to get this working then. But how would you think it is best?
To get me started
Thanks again
Re: Gaming Profile
ok i have this so far
But its not detecting that notepad is now closed.
Code: Select all
Loop {
#SingleInstance ignore
WinWait, ahk_exe notepad.exe
if ErrorLevel
{
MsgBox, WinWait timed out.
return
}
else
MsgBox, test high
Run, C:\Windows\System32\powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
;Disable Alt+Tab
!Tab::Return
WinWaitClose
MsgBox, test Bal
Run, C:\Windows\System32\powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
}
Re: Gaming Profile
Get the basics working first. After it works, you can expand. See whether the following works.
Code: Select all
#SingleInstance Force
Loop {
WinWait, ahk_exe notepad.exe
Run, powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
WinWaitClose
Run, powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
}
Re: Gaming Profile
HI and thanks.
Works soon as I added my disable alt tab it fails. well the alt tab is disabled just the winwaitclose is not noticed. could put the alt tab in to a exe then call that?
Code: Select all
#SingleInstance Force
Loop {
WinWait, ahk_exe notepad.exe
MsgBox, Hi Active
if ErrorLevel {
MsgBox, WinWait timed out.
return
}
else
Run, Powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
WinWaitClose
MsgBox, Balance Active
Run, Powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
}
Code: Select all
; Disable Alt+Tab
!Tab::Return
Re: Gaming Profile
Code: Select all
Loop {
WinWait, % winTitle := "ahk_exe notepad.exe"
SoundBeep, 1500
Run, Powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
WinWaitClose
SoundBeep, 1000
Run, Powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
}
#If WinExist(winTitle)
!Tab::Return
#If
Re: Gaming Profile
Hi and thanks this is what I have so far
I Sorted the SetCapsLockState, Am out of time now but tomorrow will start at looking at loading files from a text file.
Thank you so much for the help
Code: Select all
#SingleInstance Force
Loop
{
WinWait, % winTitle := "ahk_exe notepad.exe"
MsgBox, Hi Active
if ErrorLevel
{
MsgBox, WinWait timed out.
return
}
else
Run, C:\Windows\System32\Powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
WinWaitClose
MsgBox, Balance Active
Run, C:\Windows\System32\Powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
}
#If WinExist(winTitle)
; Disable Alt+Tab
!Tab::Return
; Disable Left Windows Key
LWin::Return
; CapsLock
CapsLock::Return
SetCapsLockState, Off
#If
Thank you so much for the help
Re: Gaming Profile
Without a timeout on WinWait, the command will wait indefinitely and will then succeed with ErrorLevel = 0. That is probably the desired effect here.
#If is only for hotkeys and hotstrings. SetCapsLockState, Off will never execute, because it follows Return.
#If is only for hotkeys and hotstrings. SetCapsLockState, Off will never execute, because it follows Return.
Re: Gaming Profile
Apon starting ahk its setting caps lock off then it's not read, just capslock return.
Also the winwait error check was if it failed would warn
Also the winwait error check was if it failed would warn
Re: Gaming Profile
WinWait cannot fail without a timeout. See the documentation.
Re: Gaming Profile
Morning.
So the error check is pointless, As I dont want it to time out. Can be gaming for 12hrs if I get lucky.
For the capslock as you say the state is not checked how would I go sorting that, put the state at the start?
So the error check is pointless, As I dont want it to time out. Can be gaming for 12hrs if I get lucky.
For the capslock as you say the state is not checked how would I go sorting that, put the state at the start?
Re: Gaming Profile
Yes, the error check serves no role, because an error will not occur.
You can move "running code" such as your CapsLock check to the top of the script, in the auto-execute section.Timeout: How many seconds to wait before timing out and setting ErrorLevel to 1. Leave blank to allow the command to wait indefinitely. ErrorLevel is set to 1 if the command timed out or 0 otherwise.
Re: Gaming Profile
Hi thanks this is what i have now
My problem now is reading the file to then enter to the winwait, In the game.txt at moment i just have notepad.exe
Code: Select all
#SingleInstance Force
FileRead, OutputVar, game.txt
if ErrorLevel ;If a Error
{
MsgBox, File not found.
}
else
Loop
{
WinWait, % winTitle := "ahk_exe OutputVar=*.*"
MsgBox, Hi Active
Run, C:\Windows\System32\Powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
SetCapsLockState, Off
WinWaitClose
MsgBox, Balance Active
Run, C:\Windows\System32\Powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
}
#If WinExist(winTitle)
; Disable Alt+Tab
!Tab::Return
; Disable Left Windows Key
LWin::Return
; CapsLock
CapsLock::Return
#If
Re: Gaming Profile
Your ahk_exe specification looks quite strange. I do not imagine that any process name matches what you have shown. See WinTitle and SetTitleMatchMode.
Re: Gaming Profile
Not quite sure how you mean, For testing am using notepad.txt but it will be a list of games in the games.txt.
So am looking to load the game.txt in to memory check to see if x game is running then do the Power profile changing, then will be changing GPU settings, and disabling keys. then once the game is close autohotkey will close.
Thanks for the help
So am looking to load the game.txt in to memory check to see if x game is running then do the Power profile changing, then will be changing GPU settings, and disabling keys. then once the game is close autohotkey will close.
Thanks for the help
Re: Gaming Profile
On line 11, you have written WinWait, % winTitle := "ahk_exe OutputVar=*.*", but that does not look like a process name, so I imagine that you will have an infinite wait at that point. You can test your script and see whether that is the case. As far as I know, all valid process names end in .exe.
Explained: WinTitle • Example
Explained: WinTitle • Example
Who is online
Users browsing this forum: No registered users and 55 guests