Jump to content
  • Sign Up
Sign in to follow this  
Ego

activewindowcheck

Recommended Posts

Because EnB seems to be a bit unstable for whatever reason now, My avatars are being logged out of the game to the character select screen

on a regular basis


Reading up on the command activewindowcheck would it be useful in checking this command and if the active window is not the EnB window can

it be used to relog the game. It says in the description that it turns on or off an error message, could this be used as a constant or a

variable?


If not I'll look for another way to check if the game is still running like iswindow

Share this post


Link to post
Share on other sites

We never used that command back in the day but what we did was to grab a screen cap and check for something on the screen that was static (always there) on the logged off screen (waiting for you to relog on). If it dumps you to the desktop it gets a little more involved but can be done.

Share this post


Link to post
Share on other sites

Some times the game dumps to desktop, log in screen or character screen, it's pot luck which window the game crashes too, that's why I was looking at activewindowcheck or iswindow.

 

I'll have a play with some of the commands and build a macro to experiment with, I think I discovered some code similar to what I am looking for in an old macro.

 

Will go hunting thru my computer, fun fun, this is what drives me, finding new ways to do things.

Share this post


Link to post
Share on other sites

Hate to bump a 4 yr old thread but you guys have been killing the CPUs with this simple check...Also the original ActiveWindowCheck IS the way to go, once you understand how it runs in a loop.  Here is the code I use to regularly check for a Window Title without taxing CPU..granted it isn't instant but it works flawlessly for the multiple games I use ACTool for.  Once you press resume it brings the window back to top (if it can) and resumes running otherwise it tells you the game window isn't focused again and pauses the script.

Constants
  WindowTitle = MyGame
End

Procedure CheckWindow On WindowChange  //Checks to see if Game window is active
  ShowMessage wrn = Warning, OK, Window Changed/Game Closed...Pausing.  Resume to Continue.
  Pause
  SetActiveWindow $WindowTitle
  Delay 500
End

SetActiveWindow $WindowTitle
While 1 = 1
  Delay 500
  ProcessMessages
  Delay 500
End

Since ProcessMessages runs the procedures from bottom to top, put all other procedures above the CheckWindow procedure.  First time the script activates it sets the active window with the title you give it, then it starts checking for the last SetActiveWindow title every step to see if it changed.

 

Any questions just ask..happy to help :)

 

PS: Oops I almost forgot one critical point...to have the game restart if it actually crashed you would do an IsWindow check (since this actually checks to see if the program with that window title is running instead of whether or not it is active/on top) between Pause and SetActiveWindow in the CheckWindow procedure and Then the code to restart your game.

Share this post


Link to post
Share on other sites

So, replace pause with a restart. But, there is a box that come up waiting for a enter command

 

 

Constants
  avatar1name = null
  wrn = 0
  WindowTitle = Earth & Beyond - $Avatar1name
End

Procedure CheckWindow On WindowChange  //Checks if Game window is active
  ShowMessage wrn = Warning, ok, Window Changed/Game restarting.   //  SetActiveWindow Earth & Beyond - $Avatar1name
  iswindow Earth & Beyond - $Avatar1name
    timestamp Start Game - $Avatar1name
  else
    call restart
  End
End

SetActiveWindow $WindowTitle
While 1 = 1
  Delay 500
  ProcessMessages
  Delay 500
End

Share this post


Link to post
Share on other sites

Hate to bump a 4 yr old thread but you guys have been killing the CPUs with this simple check...Also the original ActiveWindowCheck IS the way to go, once you understand how it runs in a loop.  Here is the code I use to regularly check for a Window Title without taxing CPU..granted it isn't instant but it works flawlessly for the multiple games I use ACTool for.  Once you press resume it brings the window back to top (if it can) and resumes running otherwise it tells you the game window isn't focused again and pauses the script.

Constants
  WindowTitle = MyGame
End

Procedure CheckWindow On WindowChange  //Checks to see if Game window is active
  ShowMessage wrn = Warning, OK, Window Changed/Game Closed...Pausing.  Resume to Continue.
  Pause
  SetActiveWindow $WindowTitle
  Delay 500
End

SetActiveWindow $WindowTitle
While 1 = 1
  Delay 500
  ProcessMessages
  Delay 500
End

Since ProcessMessages runs the procedures from bottom to top, put all other procedures above the CheckWindow procedure.  First time the script activates it sets the active window with the title you give it, then it starts checking for the last SetActiveWindow title every step to see if it changed.

 

Any questions just ask..happy to help :)

 

PS: Oops I almost forgot one critical point...to have the game restart if it actually crashed you would do an IsWindow check (since this actually checks to see if the program with that window title is running instead of whether or not it is active/on top) between Pause and SetActiveWindow in the CheckWindow procedure and Then the code to restart your game.

 

This is good example for trying something different. There is few things that need to be mentioned.

 

  1. The ProcessMessages has no effect on when the On WindowChange happens.
  2. The current active window is check every time a command is run. And from the source code, the current active window is checked after the command is executed.
  3. The On WindowChange procedure if not being used to stop the script. Needs to do more than just notify you that the window has changed. And/or bring it back to being active. It also must determine where in the script the the window changed. And attempt to recover from that point on.

Share this post


Link to post
Share on other sites

@Ego Just remove the line with ShowMessage command and you should be fine..I really put that part in there as an example to prove it's functioning properly.  Also you can remove that ProcessMessages line.

 

@The WABBIT First of all, I'm honored you think this is a good example.  Thank you for making those points as you are one of very few that could have given me this information.  I'll work on a better example and post it.

Share this post


Link to post
Share on other sites

Okay I went ahead and updated the example to the best of my abilities.

I hope it can help some to get out of certain corners they are painted into.

 

This uses ActiveWindowCheck to always know if the window is on top, also if the game is running.

 

I also added an error reporting loop although it's not really making logs, just immediate info.

Constants
  error = 0
  WT = (MEmu)
End

Procedure CheckWindow On WindowChange  //Checks for a change in the Active Window
  IsWindow $WT  //Active Window Change Found! Check if the game is running.
    SetActiveWindow $WT  //Game is running, make it active again and move on.
    Delay 500
  Else  //Game is NOT running, let's reboot it
    ExecProgram C:\Program Files\Microvirt\MEmu\MEmu.exe  //Edit this to your game.exe
    Delay 30 sec
    SetActiveWindow $WT  //Now it's running again we can make the window Active
    Delay 500
    RestartScript  //Finally we start over like new
  End
End

Procedure err On Error
  ShowMessage error = Error, OK, Error in line $ErrorLine; Error Message: $ErrorMessage
  SetConst ErrorHandled = True
  StopScript
End

SetActiveWindow $WT
Delay 500
While 1 = 1
  Delay 1 sec
End

ActiveGameCheck.zip

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...