Sign in to follow this  
Followers 0
RobM

Click two pop-ups, then sit idle awainting their return

9 posts in this topic

Hi folks,

I've running a COD2 game server that from time to time will throw up one of two pop-ups, sometimes only one and sometimes both.

After some googling i came across Autoit B) I've read through the samples, and the help file and i think i've got what i need. I'm looking for someone to double check my code and make sure it'll accomplish my goals.

Goals:

- Click "Set Optimal Settings" popup as "yes"

- Click "Start in Safe Mode" popup as "no"

- Loop and keep checking for the popups, or ability to run every X minutes to check for the popups.

- Popup may not be in focus, not sure if that matters.

Here's what i've come up with...

;
; AutoIt Version: 3.0
; Language:    English
; Platform:    Win9x/NT
; Author:        Robert Mount (rob@shrapnel-network.com)
;
; Script Function:
;   Kill "Start in Safe mode" and "Set Optimal Settings" pop ups in COD2 dedicated server
;

; Check if it's running already and bail if it is.
$g_szVersion = "COD2 Popup Killer"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

; Loop forever
While 1
  Sleep(1000)  ; Just idle around 
WEnd

; Check for "Optimal ... " window and say "y" if we find it.
Func Optimal()
  WinWaitActive("Set Optimal Settings?")
  Send("!y")
EndFunc

; Check for "Safemode ... " window and say "n" if we find it.
Func SafeMode()
  WinWaitActive("Start in Safe mode?")
  Send("!n")
EndFunc

Thanks for your input!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

$g_szVersion = "COD2 Popup Killer"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

; Loop forever
While 1
  Optimal(); Use func Optimal
  SafeMode(); use func Safemode
  Sleep(1000); Just idle around
WEnd

; Check for "Optimal ... " window and say "y" if we find it.
Func Optimal()
  WinWaitActive("Set Optimal Settings?")
  Send("!y")
EndFunc

; Check for "Safemode ... " window and say "n" if we find it.
Func SafeMode()
  WinWaitActive("Start in Safe mode?")
  Send("!n")
EndFunc

Edit: If you want it to send just the letter then Send("letter") should be used.

Edited by Shyke

Share this post


Link to post
Share on other sites

You should ad a hotkey to terminate??

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Yeah, you might wanna do that too.

Share this post


Link to post
Share on other sites

Wouldn't an "IF WinExists Then" scenario be better?


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

@Shyke: It's not working at all... Something must be wrong.

Here's the Window Details (note to proper window title... yes, i corrected the above script before testing)

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:  Run In Safe Mode?
Class:  #32770
Size:   X: 302  Y: 315  W: 425  H: 152

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 456  Y: 321
Cursor ID:  2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB:    Hex: 0x08246B   Dec: 533611

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size:
Control ID:
ClassNameNN:
Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<


>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Yes
&No
Cancel
It appears that Call of Duty(R) 2 did not quit properly the last time it ran.
Do you want to run the game in safe mode?

This is recommended for most people.
It will change your system settings but not your controls.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Still working on Window info for the "Set Optimal Settings" window...

@Valuater: I'm not concerned about terminating it, i can right click the tray icon and kill it. Shouldn't that be enough?

Thanks!

Share this post


Link to post
Share on other sites

maybe

$g_szVersion = "COD2 Popup Killer"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

; Loop forever
While 1
  
  If WinExists("Set Optimal Settings?") Then
        Send("!y")
    EndIf
    
    If WinExists("Start in Safe mode?") Then
        Send("!n")
    EndIf
  Sleep(100); Just idle around
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

maybe

Maybe Yes! I <3 Valuater :P

I run this for a few days trying to catch the other popup as well and let you know how it goes. Thanks a bunch!

Share this post


Link to post
Share on other sites

I <3 Valuater :lmao:

Do I see a bad case of narcissism coming on? :P

(For those who don't get the joke, Valuater's name is also 'Rob M.'.)

Share this post


Link to post
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
Sign in to follow this  
Followers 0