Jump to content

Trying to control command items without control IDs - (Moved)

Recommended Posts

I am new to AutoIt and am trying to create a program for my users to run.  It opens a specified document in Microsoft Word, and then goes into File, Info, Inspect Document, which brings up Document Inspector.  There are a series of checkboxes in the Document Inspector, and I need to uncheck some, and check others, but the initial state of the checkboxes varies from user to user.  I know you can ControlCommand something to make sure it is checked, but it appears it needs a specific control ID (for example, "Button4" if working with buttons).  I know about  setting coord mode to window in AutoIt Window Info (x64), and have tried it both Spy++ Control Detection Logic both on and off.  Unfortunately, the only thing that ever changes in this window are the mouse coordinates.  While I could do a MouseClick, it would only toggle the checkbox, not set it to a specific state.  Is there any way around something like that?  If I can't automate it, the users will have to do it manually (and they don't want to).  I hope I've posted this in the correct way.

Link to post
Share on other sites


Check this:




Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * for other useful stuff click the following button:


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to post
Share on other sites
  • 2 weeks later...

Thank you all for the answers above, particularly @mLipok.  I have been struggling to figure this out.  I have done CTRL+W on all the elements of the Word dialogue box I want to ControlCommand, redlined them to each other, and created a spreadsheet that shows which elements are different from each other.  However, I'm having difficulty figuring out how I translate that into the AutoIT script.  For example, the only thing that really comes up differently (aside from names/titles) for each of the elements (see dialogue box with checks above) are these coordinates (for example): Class   := <NetUICheckbox> controltype:= <UIA_CheckBoxControlTypeId>,<50002>, (0000C352) 2629;339;206;16.  Each checkbox has all the same text, except for those two coordinates.  I am very new to AutoIt and have been searching the internet, your links above, and the Help file, and can't seem to find exactly what I should do with the information SimpleSpy gave me on these elements.  Any help would be appreciated!  In particular, I'm wanting to make sure each of the checkboxes (see figure above) is either checked or unchecked, depending on the item.

ControlCommand("Document Inspector", "",  ____________________________________, "Check")

Link to post
Share on other sites

Thank you, @junkew.  I now have a Word macro that saves the document the way I want.  However, I need to combine the AutoIt script with the Word macro, and all the examples I'm finding involve opening a specific Word document.  I need the AutoIt script to run (which opens a user-specified document), and then the Word macro to run inside that open document (which will always be different).  For example, this is what I have so far.  At the point where I have "xxx," I need it to activate the Word document the user has opened, and run the Word macro (which we will make available to the users in advance) on the open document.  The macro will finish out what the users need to do (i.e., after metadata removal, save the document, and bring up a message telling them what to do next).  Even better would be if I could run the macro, and then do what the users need to do next.

AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("SendKeyDelay", 10)
Opt("WinTitleMatchMode", 2)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\koda_1.7.3.0\Forms\IP Form.kxf
Global $Form1 = GUICreate("Remove Metadata and Lock Version as Record", 565, 364, 192, 124)
Global $Label1 = GUICtrlCreateLabel("NOTE:", 16, 16, 59, 27)
GUICtrlSetFont(-1, 12, 400, 0, "Arial Black")
Global $Label2 = GUICtrlCreateLabel("1. Document must be a WORD document and must be CLOSED.", 30, 50, 454, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Label3 = GUICtrlCreateLabel("2. Word must be CLOSED.", 30, 84, 193, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Label4 = GUICtrlCreateLabel("3. DeskSite must be open and document should not show as checked out.", 30, 118, 513, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Label5 = GUICtrlCreateLabel("DeskSite Document Number:", 74, 162, 207, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Input1 = GUICtrlCreateInput("", 288, 160, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Label6 = GUICtrlCreateLabel("If all criteria met and document number filled in, hit Continue.", 103, 204, 416, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Label7 = GUICtrlCreateLabel("Otherwise, close this box with the X.", 103, 232, 251, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Label8 = GUICtrlCreateLabel("After hitting Continue, do not use your keyboard or mouse until prompted.", 30, 288, 505, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Button1 = GUICtrlCreateButton("Continue", 233, 320, 99, 33)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
         Case $Button1
            Global $DeskSiteNum = GUICtrlRead($Input1)
            WinClose("Remove Metadata and Lock Version as Record")
            WinActivate("iManage Work")
            MouseClick("Primary", 139, 46, 1, 0)
            MouseClick("Primary", 102, 84, 1, 0)
            WinWaitActive("Search Dialog", "", 30000)
            WinActivate("Search Dialog")
            ControlClick("Search Dialog", "", 331)
            ControlClick("Search Dialog", "", 300)
            Send ("{ENTER}")
            WinActivate("iManage Work")
            MouseClick("Primary", 215, 49, 1, 0)
            MouseClick("Primary", 256, 117, 1, 0)
            MouseClick("Primary", 340, 175, 1, 0)
            WinWaitActive("New Version Profile", "PCR1",30000)
            WinActivate("New Version Profile")
            ControlClick("New Version Profile", "", 391)
            Send("FILED: ", 10)
            ControlClick("New Version Profile", "", 5310)
            Send("Metadata removed and version declared as Record.  ", 10)
            ControlClick("New Version Profile", "", 1)



Link to post
Share on other sites


  • Attach to running word.application
  • Get activedocument
  • Set the properties similar like you would do in vba
  • There is no need to use click commands from AutoIt

And i think you can put vba macros in a shared document or template so its allways available when word is open but approach with AutoIt and objget should work for sure.

Edited by junkew
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...