walle Posted October 17, 2007 Share Posted October 17, 2007 Got problem with shifting instances. If I click a tab the SysListView32; INSTANCE:1 will change into SysListView32; INSTANCE:2 or3,4,5 depending on which tab I clicked I had to use a program for IR remote to create macros. it has a little program that gives you the handle id. Works great, but, the handle id changes every time the program launches. Any idea? //Walle Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 17, 2007 Share Posted October 17, 2007 (edited) On program launch, ControlGetHandle with an array.Opt("WinTitleMatchMode", 4) ; 4 = advanced window title handling. Opt('MustDeclareVars', 1) ; 0 = No, 1 = Require pre-declare. Dim $intCount, $hwndProgram, $a_hctlProg[31] ; 31 is just an arbitrary number ; Program launch If Not WinWait("Program", 10) Then MsgBox(0, "", "Error") Exit EndIf $hwndProgram = WinGetHandle("Program") For $intCount = 1 To UBound($a_hctlProg) - 1 $a_hctlProg[$intCount] = ControlGetHandle($hwndProgram, "", "[NAME:SysListView32; INSTANCE:" & $intCount & "]") NextAlso, look into ControlGetFocus() to find out which one has the current focus after clicking a tab.Edit: Corrected ControlGetHandle line. Edited October 17, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
walle Posted October 17, 2007 Author Share Posted October 17, 2007 So if the program already running, it would need to restart it? Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 17, 2007 Share Posted October 17, 2007 No? You can get the control handles at any time. The control handles never change once the program starts. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
walle Posted October 17, 2007 Author Share Posted October 17, 2007 (edited) No? You can get the control handles at any time. The control handles never change once the program starts.Thats pretty much my problem.In many cases the program already running when my script executes. If they have clicked on one of the tabs beforemy script executes the instances will be wrong.Thanks for the help so far Edited October 17, 2007 by walle Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 18, 2007 Share Posted October 18, 2007 When you run your script, it doesn't matter. Run that detection loop and then verify before click with ControlGetText()IE: If Not WinWait("Window", "Text", 2) Then DBP($version, "Message window failed to open", 6733, 0) ContinueCase EndIf For $counter = 1 To 50 Sleep(10) If StringInStr(ControlGetText("Window", "Text", "ControlClass" & $counter), "Control Text") > 0 Then ControlClick("Window", "Text", "ControlClass" & $counter, $primary, 1) ExitLoop EndIf Next If $counter >= 50 Then DBP($version, "Unable to locate button.", 6737, $i_debug) Exit 6737 EndIf Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache 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