Sandhya Posted July 28, 2015 Share Posted July 28, 2015 I have tried the below code for activating a window if it appears.if WinExists ("Connect devices") ThenWinActivate ("Connect devices")Send ("{ENTER}")EndIfBut failed. Sometimes it works.The window is not getting activated.Can you pls help me on this? Link to comment Share on other sites More sharing options...
jguinch Posted July 28, 2015 Share Posted July 28, 2015 Try with ControlSend instead of Send :ControlSend ( "Connect devices", "", "", "{ENTER}") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Sandhya Posted July 28, 2015 Author Share Posted July 28, 2015 it works. Thanks.But at sometimes, the window is not getting activated.At all times the window will not appear. So at times, it appears, i have to send "ENTER" Link to comment Share on other sites More sharing options...
xxaviarxx Posted July 28, 2015 Share Posted July 28, 2015 This is what I use for my own auto launcher to test out certain aspects of games I make you may find some things in it helpful. It hasn't failed yet it will even launch my personal game when i have something full screen up. Global $windowTitle = "insert name here" ; defines the window title for the script Global $shortcutTitle = "insert name here" ; defines the shortcut title for the script Global $checkWin = WinExists($windowTitle) ; sees if the window is open or not RunWindow() ; runs the RunWindow function Func RunWindow() ; runs the window If $checkWin = 0 Then ;0 = not launched ShellExecute($shortcutTitle, "", @DesktopDir) ; launches the window from your desktop $checkWin = 1 ; enables next block of code to activate EndIf If $checkWin = 1 Then ;1 = launched WinActivate($windowTitle) ; supposed to activate the window WinWaitActive($windowTitle) ; waits for the window to be active before continuing Sleep(10000) ; waits 10 seconds to make sure window is loaded fully EndIf EndFuncHope this helps you Link to comment Share on other sites More sharing options...
Sandhya Posted July 30, 2015 Author Share Posted July 30, 2015 i have taken some points from your code like below.Local $checkagain = WinExists("ERROR")If $checkagain = 1 Then WinActivate("ERROR") Send ("{ENTER}")EndIfBut of no use. Whether my code is correct? Link to comment Share on other sites More sharing options...
232showtime Posted July 30, 2015 Share Posted July 30, 2015 (edited) Ill do it like this:If WinExists("ERROR") Then WinWaitActive("ERROR") Send ("{ENTER}") EndIforIf WinWait("ERROR") Then WinActivate("ERROR") Send("{ENTER}") EndIf Edited July 30, 2015 by 232showtime ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
xxaviarxx Posted July 30, 2015 Share Posted July 30, 2015 (edited) Ill do it like this:If WinExists("ERROR") Then WinWaitActive("ERROR") Send ("{ENTER}") EndIforIf WinWait("ERROR") Then WinActivate("ERROR") Send("{ENTER}") EndIf I'd add in this above the Send line just to double check that the window is indeed active. ControlClick("ERROR", "", "Control ID of somewhere on the ERROR message like where the error message itself is", "left", 1)Then use this instead of Send to ensure that you don't have to manually click the button.ControlSend("ERROR", "", "Control ID of the button you wish to use", "{ENTER}")Finished code would look like thisIf WinExists("ERROR") Then WinWaitActive("ERROR") ControlClick("ERROR", "", "Control ID of the error message", "left", 1) ControlSend("ERROR", "", "Control ID of the button", "{ENTER}") EndIforIf WinWait("ERROR") Then WinActivate("ERROR") ControlClick("ERROR", "", "Control ID of the error message", "left", 1) ControlSend("ERROR", "", "Control ID of the button", "{ENTER}") EndIf Edited July 30, 2015 by xxaviarxx Link to comment Share on other sites More sharing options...
Sandhya Posted July 30, 2015 Author Share Posted July 30, 2015 thanks.both works. 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