Sign in to follow this  
Followers 0
quacky

ControlSend without control ID?

12 posts in this topic

I'm trying to use ControlSend to send "^j" to a minimized instance of Excel. However, there is no control ID associated with Excel when there are no spreadsheets open.

I'm sending ctrl-J to start a VB macro within Excel, which loads and parses the newest files in the directory.

I thought this would work:

ControlSend("XLDESK", "", "", "{CTRLDOWN}j{CTRLUP}")

... and it doesn't give me any error messages, but it doesn't seem to work either.

Thanks in advance!

Share this post


Link to post
Share on other sites



...ControlSend("XLDESK", "", "", "{CTRLDOWN}j{CTRLUP}")...

"XLDESK" is the Class

"Microsoft Excel" is the title

ControlSend("title", "text", controlID, "string" [, flag])


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

Share this post


Link to post
Share on other sites

"XLDESK" is the Class

"Microsoft Excel" is the title

ControlSend("title", "text", controlID, "string" [, flag])

Yeah, I realized that about 30 seconds ago then saw your response. Still doesn't work though... have any more insight into this? Thanks.

ControlSend("Excel", "", "", "^j")

Share this post


Link to post
Share on other sites

ControlSend("Microsoft Excel", "", "", "^j")
...I can not test right now...


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ControlSend("Microsoft Excel", "", "", "^j")
...I can not test right now...
ControlSend("[CLASS:XLDESK]", "", "", "^j")
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.

Share this post


Link to post
Share on other sites

ControlSend("Microsoft Excel", "", "", "^j")
...I can not test right now...
Thanks, but I don't think the problem is finding the title (and I did test it; didn't work). I'm able to use ControlSend just fine with programs like Notepad, but with Microsoft Excel 2007, I can't get a control ID for the main window.

This is what Info tells me:

>>>> Window <<<<

Title: Microsoft Excel

Class: XLMAIN

Position: -8, -8

Size: 1296, 1010

Style: 0x15CF0000

ExStyle: 0x00000110

Handle: 0x00070360

>>>> Control <<<<

Class: XLDESK

Instance: 1

ClassnameNN: XLDESK1

Advanced (Class): [CLASS:XLDESK; INSTANCE:1]

ID: <------ Don't I need this to use ControlSend?

Text:

Position: -1, 175

Size: 1282, 805

ControlClick Coords: 752, 345

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x000303CA

>>>> Mouse <<<<

Position: 751, 512

Cursor ID: 2

Color: 0xA4C3EB

>>>> StatusBar <<<<

>>>> Visible Text <<<<

Status Bar

Status Bar

Ribbon

Ribbon

General

>>>> Hidden Text <<<<

Vertical

PERSONAL

Vertical

Horizontal

MsoWorkPane

Collect and Paste 2.0

MsoWorkPane

Office Clipboard

Share this post


Link to post
Share on other sites

ControlSend("[CLASS:XLDESK]", "", "", "^j")
Tried that too, thanks... muttley

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Tried that too, thanks... muttley

Thanks as in it worked?

The class there is different as well: XLMAIN

So it would be:

ControlSend("[CLASS:XLMAIN]", "", "", "^j")

Edit: Or

ControlSend("[CLASS:XLMAIN]", "", "XLDESK1", "^j")
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.

Share this post


Link to post
Share on other sites

Thanks as in it worked?

The class there is different as well: XLMAIN

So it would be:

ControlSend("[CLASS:XLMAIN]", "", "", "^j")

Edit: Or

ControlSend("[CLASS:XLMAIN]", "", "XLDESK1", "^j")
I'm sorry, thanks as in "it didn't work but thanks anyway"... and neither did either of those... muttley

Share this post


Link to post
Share on other sites

Hard to help really... as control j does nothing without the macro your using for me.


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.

Share this post


Link to post
Share on other sites

Hard to help really... as control j does nothing without the macro your using for me.

My current set-up makes Excel active, then send "^j", which activates a VB macro within Excel.

What I'm trying to do is to just sent the "^j" to a minimized instance of Excel, but apparently I need the Control ID for the main window of Excel, and there isn't one that the AutoIt Window Info tool can see.

From what I can see it doesn't matter what's being sent to Excel - I can't even send just the letter "a", but I can do it with Notepad. Is it because it's Excel 2007?

Thanks for reading this.

Share this post


Link to post
Share on other sites

From the help file under ControlSend:

The control might first need to be given focus with the ControlFocus command....

WinSetState("[CLASS:XLMAIN]", "", @SW_MINIMIZE)
Sleep(1000)
$ret = ControlFocus("[CLASS:XLMAIN]", "", "XLDESK1")
ConsoleWrite(@CR & @CR & "Excel minimized - ControlFocus returned " & $ret & @CR & @CR)
$ret = ControlSend("[CLASS:XLMAIN]", "", "XLDESK1", "^j")
ConsoleWrite(@CR & @CR & "Excel minimized - ControlSend returned " & $ret & @CR & @CR)

WinActivate("[CLASS:XLMAIN]")
Sleep(1000)
$ret = ControlFocus("[CLASS:XLMAIN]", "", "XLDESK1")
ConsoleWrite(@CR & @CR & "ControlFocus returned " & $ret & @CR & @CR)
$ret = ControlSend("[CLASS:XLMAIN]", "", "XLDESK1", "^j")
ConsoleWrite(@CR & @CR & "ControlSend returned " & $ret & @CR & @CR)
Excel minimized - ControlFocus returned 0

Excel minimized - ControlSend returned 1

ControlFocus returned 1

ControlSend returned 1


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

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