Jump to content

Pausing a script moment program changes focus


Recommended Posts

In this script for a bottler for this game I am unable to put in a hotkey for pause as the game captures all hotkeys and will cause the script to not pause. Instead, I want the script to pause the moment the game client is not the active program.

I don't know how to go about doing this. I can litter every second line with

If Not WinActive("game client","") Then WinWaitActive("game client","")

but there is a possibility the script will slow down considerably since it has to check constantly if the window is in focus.

I tried wrapping the working part of the script in

While WinActive("game client","")
...
WEnd

But that waits until it hits WEnd before it checks to see if the client is the window that is in focus.

Looking for any suggestions or ideas on this.

Link to comment
Share on other sites

  • Moderators

You could always use AdlibEnable to poll a search to check every X milliseconds (AdlibEnable() would start where you would want to check the first time)

AdlibEnable('_CheckWindowStatus')

Func _CheckWindowStatus()
    If Not WinActive('window name') Then WinWaitActive('window name')
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

while 1

if WinActive("game client","") then

; do your stuff

endif

wend

8)

Tried this one, but it didn't kick out of the IF statement the moment the client wasn't in focus.

You could always use AdlibEnable to poll a search to check every X milliseconds (AdlibEnable() would start where you would want to check the first time)

AdlibEnable('_CheckWindowStatus')

Func _CheckWindowStatus()
    If Not WinActive('window name') Then WinWaitActive('window name')
EndFunc
Giving an attempt to this one tonight once the game servers are back on.

Thanks for your input, both of you. Much appreciated :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...