Jump to content
JNutt

WindowInfo - control ID

Recommended Posts

JNutt

I'm trying ot use controlClick to click on button. So I'm using the Window Info Finder tool. But I noticed that the control ID in windowInfo changes each time I restart the app.  

Am I doing this wrong.

Share this post


Link to post
Share on other sites
mikell

Maybe not. It depends on the app
The info tool provides more informations about controls so you can use them in Control* funcs (see here )

  • Like 1

Share this post


Link to post
Share on other sites
Earthshine

i like to use their class or classname and the text they have associated with them.

  • Like 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Bilgus

Its Probably the app you are trying to automate is there something else unique about the button like a specific class name to it?

Local $hWnd = WinWait("[Title:Calculator; CLASS:CalcFrame; INSTANCE:1]")
ConsoleWrite("Calc hWnd =" & $hWnd & @CRLF)


Local $iRes = ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:" & GetCtrlInstanceFromText($hWnd, "CE") & "]", "left", 1) ; CE Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:" & GetCtrlInstanceFromText($hWnd, "7") & "]", "left", 7) ;7 Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:" & GetCtrlInstanceFromText($hWnd, "+") & "]", "left", 1) ; + Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:" & GetCtrlInstanceFromText($hWnd, "3") & "]", "left", 1) ; 3 Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:" & GetCtrlInstanceFromText($hWnd, "=") & "]", "left", 1) ; = Button
ConsoleWrite("Success = " & $iRes & @CRLF) ;Didn't Work :(

Local $iRes = ControlClick($hWnd, "", "[CLASS:Button; ID:" & "82" & "]", "left", 1) ; CE Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; ID:" & "135" & "]", "left", 7) ;5 Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; ID:" & "93" & "]", "left", 1) ; + Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; ID:" & "131" & "]", "left", 1) ; 1 Button
If $iRes Then $iRes = ControlClick($hWnd, "", "[CLASS:Button; ID:" & "121" & "]", "left", 1) ; = Button
ConsoleWrite("Success = " & $iRes & @CRLF)

Func GetCtrlInstanceFromText($hWnd, $sCtrlText)
    Local $iInstance = -1
    Local $iErr = 0
    Local $sText
    For $i = 0 To 100
        $sText = ControlGetText($hWnd, "", "[CLASS:Button; INSTANCE:" & $i & "]")
        If @error Then
            ConsoleWrite("Skipped: " & $i & @CRLF)
            ContinueLoop
        ElseIf StringInStr($sText, $sCtrlText) Then
            ConsoleWrite("Found: " & $sText & @CRLF)
            $iInstance = $i
            ExitLoop
        Else
            ConsoleWrite($sText & " Instance: " & $i & @CRLF)
        EndIf
    Next

    Return $iInstance
EndFunc

Now note that the first try should be called like this for each

ControlClick($hWnd, "", "[CLASS:Button; TEXT:CE]")
Not
ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:" & GetCtrlInstanceFromText($hWnd, "CE") & "]"

I just expanded a different example and wanted you to see the inner workings

https://www.autoitscript.com/autoit3/docs/intro/controls.htm

Barring the other options You could try going through all instances till you get one at a particular coordinate

And Finally you could resort through looking for the button with a pixel search

 

  • Like 1

Share this post


Link to post
Share on other sites
JNutt

Thanks guys. Bilgus, I'll check that out.

I tried using this

ControlClick('Innovaya Studio', '', "[CLASS:WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1; TEXT:Open; INSTANCE:10]").

But no luck.  The class name seems weird.  Maybe it won't work becuase its not a standard ms control??  Heres the image from winInfo:

image.png.33ca5b9777ae16fe7358f77c1e7263fd.png

Share this post


Link to post
Share on other sites
Bilgus

Show us the next windowinfo where the same button has changed..

 

Share this post


Link to post
Share on other sites
Bowmore

On that control the developers have helpfully provided a name for the button, I would recommend that you use that. It should work reliably

ControlClick('Innovaya Studio', '', "[NAME:butOpenInv]")

 

  • Like 1

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
JNutt
1 hour ago, Bilgus said:

Show us the next windowinfo where the same button has changed..

 

image.png.8f6eea32d373e0175bfc1a5570b00d1f.png

Share this post


Link to post
Share on other sites
Earthshine

Oh boy. Win 10. You may have to use our UI automation


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
JNutt

image.png.f3889dbdfdc0a2bb06bcf85cc7f6d610.png

52 minutes ago, Bowmore said:

On that control the developers have helpfully provided a name for the button, I would recommend that you use that. It should work reliably

ControlClick('Innovaya Studio', '', "[NAME:butOpenInv]")

 

[Name:butOpenInv] works great.  I have a separate problem now.  If i use this script I can start the program, but autoIt cannot complete the block of code to click 'Open' button.  But if I comment out the first 'Run' line command and manually start the app then run the script it works fine.  I'm confused why??

 

Share this post


Link to post
Share on other sites
JNutt
14 minutes ago, Earthshine said:

Oh boy. Win 10. You may have to use our UI automation

I thought thats what I was doing?? :)

Share this post


Link to post
Share on other sites
mikell

You might try WinActivate just before the ControlClick ...

Share this post


Link to post
Share on other sites
Earthshine
Posted (edited)

IUI Automation by junkew. FAQ 31

Edited by Earthshine
  • Like 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Bilgus
Posted (edited)

I think that @Sw_ShowMaximized should be

@SW_MAXIMIZE

 

also WinWait, WinActive, WinActivate..... Returns a hWnd

Run("......", "", @SW_MAXIMIZED)
Local $iTRy = 0
Local $hWnd = 0 

$hWnd = WinWait("Innovaya Studio","", 12)
If Not $hWnd Then
    Msgbox(0,"Error", "Window is not Found")
    Exit
Else
    WinActivate($hWnd)
Endif

ControlClick($hWnd, '', "[NAME:butOpenInv]")

 

Edited by Bilgus

Share this post


Link to post
Share on other sites
JNutt
23 minutes ago, Earthshine said:

IUI Automation by junkew. FAQ 31

thanks!  checking his write up.

Share this post


Link to post
Share on other sites
JNutt
19 hours ago, Bilgus said:

I think that @Sw_ShowMaximized should be

@SW_MAXIMIZE

 

also WinWait, WinActive, WinActivate..... Returns a hWnd

Run("......", "", @SW_MAXIMIZED)
Local $iTRy = 0
Local $hWnd = 0 

$hWnd = WinWait("Innovaya Studio","", 12)
If Not $hWnd Then
    Msgbox(0,"Error", "Window is not Found")
    Exit
Else
    WinActivate($hWnd)
Endif

ControlClick($hWnd, '', "[NAME:butOpenInv]")

 

After using this code AutoIt still cannot get past the inital run command.  If I run the scipt it starts the app, then stops.  If I then comment out the run command the script works perfectly.  I wonder why autoIt gets stuck??

Share this post


Link to post
Share on other sites
Earthshine
Posted (edited)

snip

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Earthshine
Posted (edited)

also, try just a WinWaitActive for waiting for your application. please, also post your CODE, not images of your code. that is super annoying and I am not going to type all that in to test or edit.

Edited by Earthshine
  • Like 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
JNutt
27 minutes ago, Earthshine said:

snip

Having the following values for all properties: 
Title is: <Open>    Class   := <WindowsForms10.Window.b.app.0.1e84ccb_r16_ad1>    controltype:= <UIA_ButtonControlTypeId>    ,<50000>    , (0000C350)    9;65;131;63
*** Parent Information top down ***
2: Title is: <Innovaya Studio>    Class   := <WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    -8;-8;1616;876
"Title:=Innovaya Studio;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1""    
1: Title is: <panelMRF>    Class   := <WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    0;55;1600;805
"Title:=panelMRF;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1""    
0: Title is: <panelOpenExit>    Class   := <WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    2;57;143;801
"Title:=panelOpenExit;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1""    


;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=Innovaya Studio;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1")    ;Innovaya Studio
_UIA_setVar("oP2","Title:=panelMRF;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1")    ;panelMRF
_UIA_setVar("oP3","Title:=panelOpenExit;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1")    ;panelOpenExit

_UIA_setVar("Open.mainwindow","title:=Open;classname:=WindowsForms10.Window.b.app.0.1e84ccb_r16_ad1")

;~ Actions split away from logical/technical definition above can come from configfiles 

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")

_UIA_action("Open.mainwindow","setfocus")


;~ *** Standard code Flexible***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Innovaya Studio;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=panelMRF;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1", $treescope_children)    
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=panelOpenExit;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1e84ccb_r16_ad1", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar("Open.mainwindow","title:=Open;classname:=WindowsForms10.Window.b.app.0.1e84ccb_r16_ad1")
_UIA_action("Open.mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_title:= <Open>
UIA_text:= <Open>
UIA_regexptitle:= <Open>
UIA_class:= <WindowsForms10.Window.b.app.0.1e84ccb_r16_ad1>
UIA_regexpclass:= <WindowsForms10.Window.b.app.0.1e84ccb_r16_ad1>
UIA_iaccessiblechildId:= <0>
UIA_id:= <butOpenInv>
UIA_handle:= <136658>
UIA_RuntimeId:= <42;136658>
UIA_BoundingRectangle:= <9;65;131;63>
UIA_ProcessId:= <8972>
UIA_ControlType:= <50000>
UIA_LocalizedControlType:= <button>
UIA_Name:= <Open>
UIA_HasKeyboardFocus:= <False>
UIA_IsKeyboardFocusable:= <False>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <butOpenInv>
UIA_ClassName:= <WindowsForms10.Window.b.app.0.1e84ccb_r16_ad1>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <136658>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <WinForm>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <True>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleName:= <Open>
UIA_LegacyIAccessibleRole:= <43>
UIA_LegacyIAccessibleState:= <0>
UIA_LegacyIAccessibleDefaultAction:= <Press>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:8568,hwnd:0x215D2 Main:Nested [pid:8972,hwnd:0x215D2 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

Share this post


Link to post
Share on other sites
JNutt

AutoItSetOption('MouseCoordMode', 0)
AutoItSetOption('SendKeyDelay', 10)

;Start Innovaya Studio
Run("c:\Program Files\Innovaya\R4\inv5d.exe", "", @SW_MAXIMIZE)
Local $iTRy = 0
Local $hWnd = 0

$hWnd = WinWaitActive('Innovaya Studio', '', 10)
If Not $hWnd Then
   MsgBox(0, "Error", "window is not found")
   Exit
Else
   WinActivate($hWnd)
EndIf

ControlClick($hWnd, '', '[NAME:butOpenInv]')

;choose file to open
WinWait('Select an INVx File')
WinActivate('Select an INVx File')
ControlClick('Select an INVx File', '', 1148)
Send('C:\Innovaya\Models\INVx\Innovaya\Archtectural 2017_V1.invx')
Send("{ENTER}")

;Load File
WinWait('Archtectural 2017_V1.invx')
WinActivate('Archtectural 2017_V1.invx')
Send("{ENTER}")

;Click ok to continue
WinWait('INV project has successfully been loaded')
WinActivate('INV project has successfully been loaded')
Send("{ENTER}")

;Enter to continue
;WinWait('Export Quantities to Excel')
;WinActivate('Export Quantities to Excel')
;Send("{ENTER}")

WinWait('Quantity Extraction')
WinActivate('Quantity Extraction')
Send("{ENTER}")

WinWait('Export Quantities to Excel')
WinActivate('Export Quantities to Excel')
Send("{ENTER}")

WinWait('Quantities Report Complete')
WinActivate('Quantities Report Complete')
Send("{ENTER}")

WinWait('Microsoft Excel - Sheet1')
WinActivate('Microsoft Excel - Sheet1')
MouseClick('primary', 1063, 22, 1, 0)
WinClose("[LAST]")

 

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

  • Similar Content

    • autotin
      By autotin
      Hello I am a first time user of AutoIT with little coding experience and I would REALLY really appreciate your help.
      I work in a warehouse where I am responsible for data entry along with a slew of other different tasks such as auditing and managing paperwork. Most of my time is tied up entering info to close receipts of product orders (8-12+ hours for thousands of products). The quantity actually produced by the warehouse is sometimes different from the quantity listed on the reciept (in this case 20). I need to change all the build qty for sublocation "1-WIP" from 20 to the actual quantity 22 and set all other numbers as 0. The form is an iframe coded with jQuery and freezes for 1-2 seconds after every entry and refreshes. As such, it doesn't allow me to use tab and I need to click and type every incorrect field.
      I have attached an image as an example from the webapp, FinaleInventory.
      I'm thinking that I probably need a macro that has a message box entry where I can type the corrected number entry I want. Then it uses image/character recognition (Tesseract?) to find "WIP" sublocation =,   Move the mouse over to the right to "Quantity" relative to location of WIP If quantity number = entry, then move to next "WIP" image (Not quite sure how to make Tesseract "find next") Elseif quantity number ≠ entry then click quantity number of "WIP" and type corrected entry Scroll down Loop until bottom of page I would greatly appreciate any help, ideas or pointers for this project. Thank you!
      -A newbie scripter

    • Rammanan
      By Rammanan
      Hi all, Below is my script,
      Pls advise me if any wrong on that....File exit in location but the return -1.
      FileOpen($file, 0)
         $line = FileReadLine($file)
         MsgBox(0,'',$line)
      FileClose($file)
      Local $aArray = _FileListToArrayRec($serverpath, "*|*.txt", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_NOPATH)
      If @error Then
              MsgBox($MB_SYSTEMMODAL, "Ooops!", "No files found")
          Else
          ;_ArrayDisplay($aArray, "Sorted tree")
                 Local $hSearch = FileFindFirstFile($line)
               MsgBox(0,'',$hSearch)
       
    • Theodoor
      By Theodoor
      Hi,
      I am trying to use the ControlClick in a "save as"-window to select the path of where to save the document.
      I found out that when in press the icon in front of the path, i select the path. So I am trying to press that button (i have attached a print screen of this window).
      While trying to figure out how i had to use the ControlClick, it said somewhere that i could us Au3Info to find out what title,... i should use with the ControlClick.
      The result of the Au3Info I have attached aswel.
      The ControlClick that i tried are these: (and none of these even move the mouse)
      ControlClick("[CLASS:ToolbarWindow32; INSTANCE:4]", "", "", "Left" ,1 ,10,10)
      ControlClick("[CLASS:ToolbarWindow32; INSTANCE:4]", "", "1001", "Left" ,1 ,10,10)
      ControlClick("[CLASS:ToolbarWindow32]", "", "", "Left" ,1 ,10,10)
      ControlClick("Save project as", "", "", "Left" ,1 ,10,10)
      I don't know what I am doing wrong.
      Should I use a controlID? is my windowtitle wrong?
      Can anyone help me?
      Thanks in advance,
      Theo


    • Trisha
      By Trisha
      I tried (using AutoIt) to automate a scenario where i  have to open IE with specific URL on my extranet(Xen Desktop or Citrix ) ,from there i need to download  file and then through WinSCP; I  have to move that file to another location that can be access from my Local system using VMWare.
      I did as far as the above step. Now i want to navigate from my extranet to my local desktop system. But i am not able to move  from there.Mouse click is also not working.Please find the below screenshot highlighted in YELLOW.
       


    • CYCho
      By CYCho
      Browsers seem to have a built-in feature to insert a check box (Prevent this page from creating additional dialogues) into the message box created by an web site. This check box seems to appear when the same message box is triggered in succession within a short span of time. My problem is that AutoIt cannot read the text of the IE11 message box when this check box is included. I started to experence this after my Windows 10 was updated to Anniversay Update. I would like to know if anyone has experienced the same thing and if there is a solution to let the AutoIt read the text.
×