Jump to content


Photo

activewindowcheck


  • Please log in to reply
10 replies to this topic

#1 Ego

Ego

    Insane Poster

  • Moderators
  • 447 posts
  • LocationAustralia

Posted 17 April 2014 - 06:05 PM

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

Ego is not a dirty word


#2 DaMOB

DaMOB

    Lord of the Forums

  • Moderators
  • 3,121 posts
  • Locationm

Posted 18 April 2014 - 09:20 AM

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.


PM me and face the consequences if you are arguing, trolling, begging, or just being an all around ass.

 

4:35pm, Central Time, Feb 7, 2013...A date which will always be a day from hell for me.  I love you honey and may you rest in peace.


#3 Ego

Ego

    Insane Poster

  • Moderators
  • 447 posts
  • LocationAustralia

Posted 18 April 2014 - 03:42 PM

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.


Ego is not a dirty word


#4 DaMOB

DaMOB

    Lord of the Forums

  • Moderators
  • 3,121 posts
  • Locationm

Posted 19 April 2014 - 05:11 AM

Yeah, for me it drove me to C++ intermingled with ACTool then completely to C++ for my macros.


PM me and face the consequences if you are arguing, trolling, begging, or just being an all around ass.

 

4:35pm, Central Time, Feb 7, 2013...A date which will always be a day from hell for me.  I love you honey and may you rest in peace.


#5 Bear

Bear

    Forum Master

  • Moderators
  • 931 posts
  • LocationAltoona, IA

Posted 07 June 2014 - 06:21 PM

Hey guys, here's what I was using for my differnet games.

 

Attached File  game.zip   1.04KB   94 downloads


Number inside (#) = Number of Accounts.
Emulator Games:
SWGEmu(1), Earth and Beyond(3): ZackeryFox## , MillyFilly## & Gooseman##

Paid/Free Subscriptions:
World of Warcraft(2), Runes of Magic(2), DDO(1)
SWG(3) up until JTL:Beta, Fiesta Online(2), Guild Wars(1),
Too bad someone never made a Asheron's Call 2(Beta:1) Emulator.
Since we'll never see a Asheron's Call(3)-Emulator until Turbine stops Supporting it.
SWTOR(1) didn't even make it a full year before becoming BORING, but goes F2P in the Fall of 2012.
Lord of the Rings Online (2:Lifetime VIP)
bear67star.png


#6 RADoss

RADoss

    Newbie

  • Members
  • Pip
  • 18 posts

Posted 15 December 2018 - 04:04 PM

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.



#7 Ego

Ego

    Insane Poster

  • Moderators
  • 447 posts
  • LocationAustralia

Posted 16 December 2018 - 12:57 AM

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.   //<<<HERE<<<
  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


Ego is not a dirty word


#8 The WABBIT

The WABBIT

    Forum Master

  • Moderators
  • 663 posts
  • LocationDenver, Colorado

Posted 16 December 2018 - 09:35 AM

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.


#9 RADoss

RADoss

    Newbie

  • Members
  • Pip
  • 18 posts

Posted 16 December 2018 - 12:24 PM

@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.



#10 The WABBIT

The WABBIT

    Forum Master

  • Moderators
  • 663 posts
  • LocationDenver, Colorado

Posted 16 December 2018 - 08:47 PM

@Ego Just for FYI. In v5.5.1 Restart was renamed to RestartScript. This was done for the same reasons as Stop was renamed to StopScript. I mentioned it in the The WABBIT's AC Tool Programming TODO List topic.



#11 RADoss

RADoss

    Newbie

  • Members
  • Pip
  • 18 posts

Posted 17 December 2018 - 06:30 PM

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

Attached File  ActiveGameCheck.zip   591bytes   1 downloads