Jump to content

Simple WinActivate question


Recommended Posts

I'm having problem with my script when porting it to a new computer. The 2 lines below is the problem. It works well with my XP machine and my other Vista Machine but on my 3rd Machine which is Vista too, it does nothing at all.

WinActivate ("MyGame")

Sleep (3000)

Please let me know what is wrong with it. It is so simple but can't really make it work for my 3rd computer.

Thanks.

Link to comment
Share on other sites

First off you should make sure the window is there, this can be done with WinWait here is a sample of the code:

If WinExists("My Game") Then
    If WinWait("My Game") Then WinActivate("My Game")
EndIfoÝ÷ Ø   趫¥u·­¢­¶¡jwezíì"Ú0Â+aZ)ÆzÑÚÙ^jëh×6$hApp = WinGetHandle("My Game")

If WinExists($hApp) Then
    If WinWait($hApp) Then WinActivate($hApp)
EndIf

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

First off you should make sure the window is there, this can be done with WinWait here is a sample of the code:

If WinExists("My Game") Then
    If WinWait("My Game") Then WinActivate("My Game")
EndIfoÝ÷ Ø   趫¥u·­¢­¶¡jwezíì"Ú0Â+aZ)ÆzÑÚÙ^jëh×6$hApp = WinGetHandle("My Game")

If WinExists($hApp) Then
    If WinWait($hApp) Then WinActivate($hApp)
EndIf

I know the window exist and is physically there. It just would not activate it.

Link to comment
Share on other sites

WinActivate will make it active it is exist.

You do have make sure the arguments for it are correct though.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

WinActivate ("MyGame")

Sleep (3000)

also its always a good idea to follow up winactivate("MyGame") with winwaitactive("MyGame") you can remove you sleep(3000) if you use winwaitactive("")

-1

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

Also check out WinTitleMatchMode

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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