Jump to content

Button Help


Recommended Posts

Hello,

I want to automate some of my Ms Excel repetative work.

I start Excel by "Run" command.
Now I want to
1) click on "BOLD" icon and
2) Select FontSize Dropdown menu to Select any other fontsize other than Default size.

I plan to use ControlFocus for BOLD Buttons and then CLICK, but How to get CONTROLID of BOLD Button.
I used Info Tool but it gives me following Summary details.

>>>> Window <<<<
Title: Microsoft Excel - Book1
Class: XLMAIN
Position: -8, -8
Size: 1040, 738
Style: 0x15CF0000
ExStyle: 0x00000110
Handle: 0x001703B4

>>>> Control <<<<
Class: MsoCommandBar
Instance: 3
ClassnameNN: MsoCommandBar3
Name: 
Advanced (Class): [CLASS:MsoCommandBar; INSTANCE:3]
ID: 
Text: Formatting
Position: -1, 52
Size: 677, 26
ControlClick Coords: 155, 15
Style: 0x56000000
ExStyle: 0x00000000
Handle: 0x000F0808

>>>> Mouse <<<<
Position: 154, 89
Cursor ID: 0
Color: 0xF2F2F2

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Task Pane
New Workbook
New
Worksheet Menu Bar
Type a question for help
Formatting
10
Arial
Standard
100%
Book1

>>>> Hidden Text <<<<
MsoWorkPane
________________________________________________

Any Help Please

Regards

Link to comment
Share on other sites

Please have a look at the Ecxel UDF, function _ExcelFontSetProperties, that comes with AutoIt. Or my Excel Rewrite (still an alpha version).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks Water for your Reply.

I get Some Idea for one of my question.

But I Need to know, how to click certain button,e.g."Bold" when we can't retrieve ControlID from InfoTool.

Regards

Link to comment
Share on other sites

When you use the Excel UDF then there is no need to click on buttons. It is all being done using COM.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks Water;

I am experimenting with Excel UDF.May be I am on a right path.

But still my question is unanaswered. How to click certain BUtton when there is no specific Id

E.g. Take another case apart from EXCEL, say Dev C++ (C++ IDE),

To open new Source File, I may write script like:

send("{Ctrl}")

send("N")

Alternatively I click on Icon for " New Source file" on Main MenuBar.

So here how to click this Icon.

May I use ControlClick Coords.

Give me some clue.

Regards

Link to comment
Share on other sites

AutoIt allows to access a control not only by Id. Please check the help file.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks Water,

My Scrip is as:

Run("C:Dev-Cppdevcpp.exe")
Opt("WinTitleMatchMode", 1)
WinWaitActive ("Dev")
WinSetState("Dev","",@SW_MAXIMIZE)
ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]" )

IDE open Normally but doesn't click on "Source File" Icon, that I want.

O.K I change Last line as:

ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]",left ,1,62,13).

 But it Gives Syntax Error

Info Tool Summary:

>>>> Window <<<<
Title: Dev-C++ 4.9.9.2
Class: TMainForm
Position: -8, -8
Size: 1040, 738
Style: 0x17CF0000
ExStyle: 0x00010110
Handle: 0x01570646

 

>>>> Control <<<<
Class: TToolBar
Instance: 8
ClassnameNN: TToolBar8

Name:
Advanced (Class): [CLASS:TToolBar; INSTANCE:8]
ID: 13501826
Text:
Position: 12, 3
Size: 177, 22
ControlClick Coords: 62, 13
Style: 0x5600084E
ExStyle: 0x00010000
Handle: 0x00CE0582

>>>> Mouse <<<<
Position: 74, 58
Cursor ID: 0
Color: 0xDEDEDE

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Project
tbClasses
Specials
Search
Edit
Project
Options
Compile and Run
Main

>>>> Hidden Text <<<<
Debug
Classes
Compiler
Debug
Output

Edited by daya
Link to comment
Share on other sites

Should be

ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]","left" ,1,62,13)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Do some error checking:

$iReturn = ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]","left" ,1,62,13)
MsgBox(0, "", "Returnvalue is: " & $iReturn)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This means that ContrloClick was not successfull.

According to the help file: "Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick()."

Is there a reason that you pass the coordinates where to click? As Default AutoIt clicks in the middle of the Control.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Still No luck.

My scrip is

 

Run("C:Dev-Cppdevcpp.exe")
Opt("WinTitleMatchMode", 1)
WinWaitActive ("Dev")
WinSetState("Dev","",@SW_MAXIMIZE)
WinActivate("Dev-C++ 4.9.9.2","Source File")
ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]")
$iReturn = ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]")
MsgBox(0, "", "Returnvalue is: " & $iReturn)
 

Alternatively I tried:

Run("C:Dev-Cppdevcpp.exe")
Opt("WinTitleMatchMode", 1)
WinWaitActive ("Dev")
WinSetState("Dev","",@SW_MAXIMIZE)
WinActivate("[CLASS:TToolBar; INSTANCE:8]","Source File")
ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]")
$iReturn = ControlClick("Dev-C++ 4.9.9.2", "Source File","[CLASS:TToolBar; INSTANCE:8]")
MsgBox(0, "", "Returnvalue is: " & $iReturn).

 

Info tool Summary is   same as previous post.

I don't need to pass control coordinates. That's I tried to alter syntax.

 

Regards

Link to comment
Share on other sites

I still don't get why you think you need to click a button. Using COM allows to do whatever you need to do without clicking a single button.

Can you please elaborate?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Dear Water,

Thanks for your help.

I am new to Autoit and specifically any programming Environment.

I just wanted to learn about Windows application Automation.And this ControlClick made me curious.

Ok I am trying for COM.

Can you please direct me for this way.

Regards

Link to comment
Share on other sites

Sure!

First a few questions:

  • Which version of Excel do you run?
  • Which file format do you want to use (xls or xlsx)?
  • Do you want to create a new Excel workbook or open and modify an existing one?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This opens an existing workbook and sets cell "A1" to bold and font size 16:

#include <Excel.au3>
Global $oExcel = _ExcelBookOpen("C:\temp\test.xls")
If @error Then Exit MsgBox(0, "Error", "_ExcelBookOpen returned error " & @error)
$oExcel.ActiveSheet.Range("A1").Font.Size = 16
$oExcel.ActiveSheet.Range("A1").Font.Bold = True

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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