Sign in to follow this  
Followers 0
walle

Shifting instances

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 & "]")
Next

Also, look into ControlGetFocus() to find out which one has the current focus after clicking a tab.

Edit: Corrected ControlGetHandle line.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

So if the program already running, it would need to restart it?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 before

my script executes the instances will be wrong.

Thanks for the help so far :)

Edited by walle

Share this post


Link to post
Share on other sites

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

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