Sign in to follow this  
Followers 0
erbailey

Interact with specific programs

12 posts in this topic

I have followed the examples and learned how to open a webpage, click on links and submit searches etc... How can I do the same with programs? For example, how do I open up excel, (or any other program) and interact with the controls in the program?

Share this post


Link to post
Share on other sites



Start with the "Simple Notepad Automation" tutorial in the AutoIt help file.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

if you mean using that ie 2.0 libbrary thats just cuase its a brillaint udf that totaly automates ONE certian program (internet explorer)... to get such interfaces with other programs, other udfs are required...else you back to ye olde controlsend, wingettext ect

Edited by evilertoaster

Share this post


Link to post
Share on other sites

Well...

I wouldnt call it laziness because I am in automations, thats what I do. I have several programs that I have to run each morning. I have to go download reports... take some info out of those reports, email the results to my supervisor. Ultimately, id like to just set it up to run at 8am every morning before I even get to work. That way when I get here I can start playing Everquest or something.

No Im kidding, I think you gave me a hint on what I am looking for, "Controlsend" wingettxt etc...

This did bring another question up.. what is a UTF?

Can I interact with an API?

Am I just getting in way over my head?

Share this post


Link to post
Share on other sites

UTF- http://en.wikipedia.org/wiki/Unicode_Transformation_Format

:whistle: UDF is user defined function...someone made a nice interface for you to use rather than you having to manually manage getting objets and window handles and a bunch of stuff.....

SOME aplications have an API for them (most popular MS programs do) and tahts definatly the way to go if you can.

and yes it may possibly be curretly over your head but, if you try you grow taller and maybe soon it wont be :)

Share this post


Link to post
Share on other sites

Yes, I like to jump in and learn and thats what ive done... I did some experimenting and here is what Ive came up with. Perhaps all I need is a little boost to get me going in the right direction...

Run ("C:\Program Files\Microsoft Office\OFFICE11\Excel.exe")

$var = ControlGetHandle("Microsoft Excel - Book1","&File","MsoWorkPane2",)

MsgBox(64,"Info", "The handle is" & $var)

I wanted to see if I could get the handle (what I am going to do with it afterwards I dont know) and play around a bit.

I used the Autoit windo info tool ... the control did not have a ControlID so I used the classnameNN (I thought thats what it said to replace it with if there was no classID)

Anyway... my $var is blank

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

excel is a complicated app to interface with, remmer the controls must be normal window controls....if the aplication has its own special gui controls outside the standard thins you can wake with the win API (bascialyl everythign autoit can make) it can be trickey. I think there is actually an excel api/udf out there - http://www.autoitscript.com/forum/index.ph...mp;#entry106789

or so...that may be better for such things...

edit: also...i dont know what would happen if you try and display a window handle as text but...well i dont think its text...its probably a c struct or class or somthing...either way direct text output is not very conventional of a handle i dont think...

Edited by evilertoaster

Share this post


Link to post
Share on other sites

Yikes, I guess I am in over my head... I figured that since Excel is a Microsoft made program, it would have standard controls.

My plan to phase myself out then isnt an easy task to accomplish.

Thanks for your help I appreciate it.

Share this post


Link to post
Share on other sites

ehh it does have some standard controls (file menu ect) but drag your mouse over the worksheet cells and you see they dont all have a unique id (and indeed there could potentially be too many cells for this to be true!) so each cell is not directly accessable in this way.... try a nice simple program...like notepad :whistle:

Share this post


Link to post
Share on other sites

Working with Excel is easier if you use COM, which will allow you to automate tasks much more logically than clicks and sends will allow. In the absence of learning Excel COM and/or AutoIt with Excel COM, I recommend trying out the UDF at the link in my signature.

In addition, if you have some specific questions on how to do a particular thing, you might consider posting them here with a pseudo-code layout of what you've done and/or what you want to do with the workbook.

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

Well what I am wanting to do is this.

I have a script that uses Cisco VPN, gets a secure tunnel to my server, downloads an excel sheet. What I am having the issue with is opening the excel sheet up... selecting the first row, then turning on autofilter.

Share this post


Link to post
Share on other sites

Okay, here's some code to do that:

; Open the workbook, select first row, apply AutoFilter
$oExcel = ObjCreate("Excel.Application")
With $oExcel
    .Visible = True   ; False if you don't want Excel visible
    .WorkBooks.Open("C:\PathToTheFileYouWant.xls")
    .ActiveWorkbook.Sheets(1).Rows(1).Select()
    .Selection.AutoFilter  ; Once, to set the filter
    .Selection.AutoFilter  ; Twice, to then apply the filter
EndWith



; Do whatever else you need, then save & close out Excel
With $oExcel
    .Application.DisplayAlerts = 0
    .Application.ScreenUpdating = 0
    .ActiveWorkBook.Save
    .Application.DisplayAlerts = 1
    .Application.ScreenUpdating = 1
    .Quit
EndWith

Good luck!

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

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