Sign in to follow this  
Followers 0
chandler8

ControlID's and ClassNames

5 posts in this topic

I currently have an external program that has many Controls on the GUI. I have my script running and it works great on each one of these controls. The problem that I have is when I close the external pogram and re-open that program the ControlID have changed. So everytime this happens, I have to enter my code and enter the new ControlID's for the program to work again.

Func buttonstart3()
            $count = 1              ; Set the counter
            Do                      ; Execute the loop "until" the counter is greater than 20
                For $x = 1 To UBound($sArray) - 1  ;go through the array and execute with focus on the control ID
                    ControlSend("Form1","", 984376, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", 984376, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1","", 984376, "{BackSpace 20}")
                Next
                    $count = $count + 1  ; Increase the count by one
            Until $count > 5
                    MsgBox(0, "Click start to Continue ", "Search finished!"); Finished
EndFunc;===buttonstart2

I have the classnames for each ControlID and think that I should be able to use the classnames instead of the ControlID to have my script be focused on the correct Control. My first ClassName is: WindowsForms1O.EDIT.app 128. I tried something like this first, but no go. Any ideas

$a = ControlGetHandle (WindowsForms1O.EDIT.app 128)
                
            
                For $x = 1 To UBound($sArray) - 1  ;go through the array 
                    ControlSend("Form1", "", $a, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", $a, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1", "", $a, "{BackSpace 20}")
                
                Next

Share this post


Link to post
Share on other sites



why ControlGetHandle

try:

$a = "WindowsForms1O.EDIT.app 128"


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

why ControlGetHandle

try:

$a = "WindowsForms1O.EDIT.app 128"

I tried your suggestion, the program starts, but the script isn't acting on the Control. I just tried this:

$handle = "WindowsForms1O.EDIT.app 128"
            $count = 1              ; Set the counter
            Do                          ; Execute the loop "until" the counter is greater than 20
                

            ;$a = ControlGetHandle (WindowsForms1O.EDIT.app 128)
                
                
                For $x = 1 To UBound($sArray) - 1  ;go through the array
                    ControlSend("Form1", "", $handle, $sArray[$x])
                ;Sleep(1000)
                    ControlSend("Form1", "", $handle, "{Enter}")
                    Sleep(1000)
                    ControlSend("Form1", "", $handle, "{BackSpace 20}")
                ;MsgBox(0, "Click start to Continue ", $handle)
                Next

Share this post


Link to post
Share on other sites

Make a simple test script with two lines of code:

$ret = ControlSend("Form1", "", "WindowsForms1O.EDIT.app 128", "{Enter}")
MsgBox(0,"",$ret)
Get that working then put it into your other script.

from the help file for ControlSend:

Return Value

Success: Returns 1.

Failure: Returns 0 if window/control is not found.

so, if the msgbox shows a 0, then...

if you want to go back to using handles:

Using the ControlGetHandle function you can determine the Handle or HWND of a control. A handle is the unique indentifier that Windows gives controls. The handle changes each time the control is created. This method of accessing controls is generally only designed for users who are familar with working with handles.

...and that ain't me :-)

The syntax for ControlGetHandle is:

ControlGetHandle ( "title", "text", controlID )

which is not what you had in your code

have fun...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Make a simple test script with two lines of code:

$ret = ControlSend("Form1", "", "WindowsForms1O.EDIT.app 128", "{Enter}")
MsgBox(0,"",$ret)
Get that working then put it into your other script.

from the help file for ControlSend:so, if the msgbox shows a 0, then...

if you want to go back to using handles:

...and that ain't me :-)

The syntax for ControlGetHandle is:

ControlGetHandle ( "title", "text", controlID )

which is not what you had in your code

have fun...

That's great advice. I'll do that test script with only 2 lines and see what happens. Thanks again

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