![Waving :wave:](./images/smilies/icon_wave.gif)
Client Losing Focus Which Interupts Script Topic is solved
Client Losing Focus Which Interupts Script
Hello Family. I was wondering if someone could provide a code which will allow the client which is being focused on or potentially "at top" of screen ( as I am able to set the clients to be at the top of everything ) to steal focus back automatically if some popup or windows Frame Application or something steals focus. I'm not at a level yet where I have it constructed where the script realizes it has done something, or if it hasnt, it goes back. So as such, if something steals focus and causes a hiccup in my script, it basically ruins the entire performance. The script in general ; Performs a set list of tasks in the game, then once done, rotates clients and repeats the task on another client, then repeats again and again. I would love to be able to keep a flow and prevent anything from stealing focus and messing the script up. Ive been reading up on WinActive etc but I just cant wrap my head around how it works and would love if someone could help me solve it. Thanks Geniuses <3 ![Waving :wave:](./images/smilies/icon_wave.gif)
![Waving :wave:](./images/smilies/icon_wave.gif)
Re: Client Losing Focus Which Interupts Script
Code: Select all
; This script keeps a window active
#Requires AutoHotkey v2.0
stay := "ahk_exe notepad.exe"
Loop {
WinWait stay ; Wait for the window to exist
WinSetAlwaysOnTop ; Set the window on top
WinWaitNotActive ; Wait until the window is inactive
Try WinActivate ; Activate the window
SoundBeep 1500
}
Re: Client Losing Focus Which Interupts Script
thank you king
Re: Client Losing Focus Which Interupts Script
hey bossman. With the
stay := "ahk_exe notepad.exe"
do I replace the "ahk_exe notepad.exe" with the name of the client Im using? Like insert the name of it inside the quotation marks?
or do I just leave it and it auto detects whatever client Ive recently clicked on? Is there something Im supposed to insert to make it know which client to stay focused on? the WinSetAlwaysOnTop says its an invalid command so I assume I'm writing it wrong or missing a variable I should add? Thanks so much for Your patience and all the work You do for the people on these forums.
stay := "ahk_exe notepad.exe"
do I replace the "ahk_exe notepad.exe" with the name of the client Im using? Like insert the name of it inside the quotation marks?
or do I just leave it and it auto detects whatever client Ive recently clicked on? Is there something Im supposed to insert to make it know which client to stay focused on? the WinSetAlwaysOnTop says its an invalid command so I assume I'm writing it wrong or missing a variable I should add? Thanks so much for Your patience and all the work You do for the people on these forums.
Re: Client Losing Focus Which Interupts Script
As I am extremely new at this myself, I thought I would share what I think I've learned. I'm sure the gurus will quickly correct me if I'm wrong.
The "ahk_exe notepad.exe" you can determine what you need here with Window Spy and for myself, the documentation at https://www.autohotkey.com/docs/v2/misc/WinTitle.htm (link updated to reflect V2 documentation)
You will see the info you need in Window Spy. Examples below show Window Spy while Notepad is active, and Calculator while it is active. Notepad is an easy item to use as an example as you will quickly notice in a lot of the script examples here.
I hope this helps!!
.
The "ahk_exe notepad.exe" you can determine what you need here with Window Spy and for myself, the documentation at https://www.autohotkey.com/docs/v2/misc/WinTitle.htm (link updated to reflect V2 documentation)
You will see the info you need in Window Spy. Examples below show Window Spy while Notepad is active, and Calculator while it is active. Notepad is an easy item to use as an example as you will quickly notice in a lot of the script examples here.
I hope this helps!!
.
Re: Client Losing Focus Which Interupts Script Topic is solved
That is correct. The script is just a demonstration with Notepad. You can use any
WinTitle.
This is a v2 script. If you are using v1, you can install v2 alongside it, or use the v1 version here.
![Arrow :arrow:](./images/smilies/icon_arrow.gif)
This is a v2 script. If you are using v1, you can install v2 alongside it, or use the v1 version here.
Code: Select all
; This script keeps a window active
#Requires AutoHotkey v1.1.33
#SingleInstance Force
stay := "ahk_exe notepad.exe"
Loop {
WinWait % stay ; Wait for the window to exist
WinSet AlwaysOnTop, On ; Set the window on top
WinWaitNotActive ; Wait until the window is inactive
Try WinActivate ; Activate the window
SoundBeep 1500
}
Re: Client Losing Focus Which Interupts Script
thanks alot. you guys are chill af