gaiaplay Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
TerarinK Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
gaiaplay Posted March 24, 2009 Author Share Posted March 24, 2009 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 More sharing options...
bo8ster Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
TerarinK Posted March 24, 2009 Share Posted March 24, 2009 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 Link to comment Share on other sites More sharing options...
Negative1 Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
bo8ster Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now