Jump to content

ControlID and ClassNameNN are changing from day to day?


Recommended Posts

Hi, I am quite new to AutoIt.

First off all: Congratulations to this great program!

Second: I am working on automating a program written with M$ Visual Studio C. In general it is working fine but I got some problems with changing ControlIDs and ClassNameNNs!

Yesterday the script was working fine logging the desired data, today - without any change - the logged data contains wrong information.

Checked with AU3Info and found out that the ClassNameNNs changed from yesterday to today!

Has anybody got the same experience?

I wonder how to automate a program using "stealth" technology for its controls?

Thanks for any feedback.

Best Regards from Germany,

No

Link to comment
Share on other sites

  • Moderators

Hi, I am quite new to AutoIt.

First off all: Congratulations to this great program!

Second: I am working on automating a program written with M$ Visual Studio C. In general it is working fine but I got some problems with changing ControlIDs and ClassNameNNs!

Yesterday the script was working fine logging the desired data, today - without any change - the logged data contains wrong information.

Checked with AU3Info and found out that the ClassNameNNs changed from yesterday to today!

Has anybody got the same experience?

I wonder how to automate a program using "stealth" technology for its controls?

Thanks for any feedback.

Best Regards from Germany,

No

Can you give an example of what the ControlID's and the ClassNamesNN were today vs. yesterday? Also, I wrote a UDF I think (isn't that funny, if I hadn't I should) to get the ControlID or ClassNameNN by Client X/Y Pos that should work no?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Here this should do it, you need to get the Client X and Y coord, just anywhere within that control is fine...

Opt('WinTitleMatchMode', 4)
Global $Control_To_Interact_With_Is = _CtrlGetByPos('classname=SciTEWindow', '', 829, 504, 0)
MsgBox(0, '', $Control_To_Interact_With_Is)

; 0 = return ClassNameNN / 1 = ControlID / 2 = Both (will need to parse to seperate)
Func _CtrlGetByPos($hWin, $sText = '', $iXPos = 0, $iYPos = 0, $iReturnType = 0)
    If IsString($hWin) Then $hWin = WinGetHandle($hWin)
    Local $sClassList = WinGetClassList($hWin), $hCtrlWnd
    Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $aReturn = ''
    For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1
        Local $nCount = 0
        While 1
            $nCount += 1
            Local $aCPos = ControlGetPos($hWin, '', $sSplitClass[$iCount] & $nCount)
            If @error Then ExitLoop
            If $iXPos >= $aCPos[0] And $iXPos <= ($aCPos[0] + $aCPos[2]) _
                    And $iYPos >= $aCPos[1]  And $iYPos <= ($aCPos[1] + $aCPos[3]) Then
                If $sSplitClass[$iCount] <> '' And Not $iReturnType Then Return $sSplitClass[$iCount] & $nCount
                If $sSplitClass[$iCount] <> '' And $iReturnType = 2 Then
                    $hCtrlWnd = ControlGetHandle($hWin, '', $sSplitClass[$iCount] & $nCount)
                    ControlFocus($hWin, '', $hCtrlWnd)
                    $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd)
                    If @error = 0 And $aReturn[0] <> '' Then _
                        Return 'ControlID: ' & $aReturn[0] & @CRLF & 'ClassNameNN: ' & $sSplitClass[$iCount] & $nCount
                    Return 'ClassNameNN: ' & $sSplitClass[$iCount] & $nCount
                ElseIf $sSplitClass[$iCount] <> '' And $iReturnType = 1 Then
                    $hCtrlWnd = ControlGetHandle($hWin, '', $sSplitClass[$iCount] & $nCount)
                    ControlFocus($hWin, '', $hCtrlWnd)
                    $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd)
                    If @error = 0 And $aReturn[0] <> '' Then Return $aReturn[0]
                EndIf
                Return ''
            EndIf
        WEnd
    Next
    Return ''
EndFunc

Edit:

I thought I had made one, but it was LxP that made one that returns the Handle but the same concept.

It's funny to see the different approach we both took though.

http://www.autoitscript.com/forum/index.ph...ost&p=97861

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks for fast response!

This is an - slightly - modified extract from the script:

$A = ControlGetText($WT, "", "WindowsForms10.STATIC.app.0.378734a32" )
$B = ControlGetText($WT, "", "WindowsForms10.STATIC.app.0.378734a31" )
$C = ControlGetText($WT, "", "WindowsForms10.STATIC.app.0.378734a30" )

Already overwritten the code from yesterday, but the change was in the last two digits.

E.g. WindowsForms10.STATIC.app.0.378734a29 changed to Win...8734a32

The ClassNameNN seemed to be ok - at least till today - while the ControlID was changing after each start of the app. No rule found so far.

Obviously I need to checkout your proposals searching ClassNameNN by position.

Link to comment
Share on other sites

Already overwritten the code from yesterday, but the change was in the last two digits.

E.g. WindowsForms10.STATIC.app.0.378734a29 changed to Win...8734a32

The ClassNameNN seemed to be ok - at least till today - while the ControlID was changing after each start of the app. No rule found so far.

Obviously I need to checkout your proposals searching ClassNameNN by position.

what's the application?

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

It's an inhouse written application/GUI for an IC-evaluation-kit connected to the LPT-Port. Not available in the wild. :whistle:

O.K. and what's the development environment? Strange behaviour....

BTW: Why not ask the internal developers what's going on...

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

O.K. and what's the development environment? Strange behaviour....

BTW: Why not ask the internal developers what's going on...

Cheers

Kurt

- App is written in M$ Visual Studio C. (Mentioned in the first post.)

- The developper is having no idea at all.

Always the same problem. They never think about testing and adding macro and logging feature to their apps. :)

Therefore I am trying to automate some stupid stuff like pressing Start, wait for a certain text, writing value in a list, pressing Stop and repeat and repeat ...

The designer was very surprised to get some 100 values the next day! He thought I will be busy the next days to get the data! :)

So far I haven't told too many people about this fantastic tool. :whistle:

But that's off topic, I think!

Either I will change the few values after they change manually or I will check out the "ControlID by Position"-solution.

Link to comment
Share on other sites

OK, I have experienced such behavior with ImgBurn (google it!). ControlIDs keep changing from run to run, but classnames seem not. I'm still not 100% sure about thewclassnames, so, I'll try pos x/y method.

Link to comment
Share on other sites

  • Moderators

Did the control by position help you (I don't see why it wouldn't unless there are dummy controls that have focus in the same place).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 4 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...