Sign in to follow this  
Followers 0
gaiaplay

Simple WinActivate question

7 posts in this topic

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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Then try this on the very top of your script

$hApp = WinGetHandle("My Game")
If @error Then MsgBox(0, "Error", "Finding a windows that isn't here")

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
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.

Share this post


Link to post
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]

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