Sign in to follow this  
Followers 0
Chrispy1

FileOpen, SendKey, and then Close Help

5 posts in this topic

Hi all,

I have just had my Laptop reimaged for work (I'm running WinXP Sp2) and first things first, I reinstalled AutoIT and SciTe. I have to write a script that will do the following:

Start with the first file in the Directory (they are all Visio Diagrams)

Send Ctrl-Shift-b to run my macro, which saves the file as a GIF

Close and move onto the next diagram

Right now, all I've got is

In the first line, I have ... to remove most of the path; I do have the actual path in my code

FileOpen ("C:\...\Desktop\ORBM416234_1AMH1.vsd",1)  send("{ctrldown}")
send("{shiftdown}")
send("{b}")
send("{shiftup}")
send("{ctrlup}")

Which I know is not the most efficient way of doing it, but right now I'm just trying to get something functional.

Problem #1 - even when I just have the FileOpen line, nothing happens. I've tried multiple files, multiple path formats, and I get nothing. Very frustrating.

Probem #2 - Is there an easier way to send the keystrokes to the file? I've also tried ^+b, but that doesn't work either

Problem #3 - I am horrible at looping, so was thinking of using the file name in each FileOpen line - and then I get a list of the files, and it's 75,000 records long. Um, yeah, never mind about that.

Any suggestions at all?? Really appreciate your help...

Chris

Share this post


Link to post
Share on other sites



Hi all,

I have just had my Laptop reimaged for work (I'm running WinXP Sp2) and first things first, I reinstalled AutoIT and SciTe. I have to write a script that will do the following:

Start with the first file in the Directory (they are all Visio Diagrams)

Send Ctrl-Shift-b to run my macro, which saves the file as a GIF

Close and move onto the next diagram

Right now, all I've got is

In the first line, I have ... to remove most of the path; I do have the actual path in my code

FileOpen ("C:\...\Desktop\ORBM416234_1AMH1.vsd",1)  send("{ctrldown}")
send("{shiftdown}")
send("{b}")
send("{shiftup}")
send("{ctrlup}")

Which I know is not the most efficient way of doing it, but right now I'm just trying to get something functional.

Problem #1 - even when I just have the FileOpen line, nothing happens. I've tried multiple files, multiple path formats, and I get nothing. Very frustrating.

Probem #2 - Is there an easier way to send the keystrokes to the file? I've also tried ^+b, but that doesn't work either

Problem #3 - I am horrible at looping, so was thinking of using the file name in each FileOpen line - and then I get a list of the files, and it's 75,000 records long. Um, yeah, never mind about that.

Any suggestions at all?? Really appreciate your help...

Chris

Problem #1

FileOpen prepares the file so that it can be read from or written to. I think what you need is

ShellExecute("C:\...\Desktop\ORBM416234_1AMH1.vsd")

BTW I assume you haven't really got the path exactly as written there. If you have then write the full path the the file exactly.

then when the Visio program has started up do your Send thing.

If you don't like loops then you should try playing with them, try the examples and get to understand them. I would say that it's difficult to write useful programs without loops of some kind. I remember when I had problems understanding for/next, but I'm glad I kept trying. Now I can't understand what I found difficult and I'm sure it will be the same for you if you are prepared to keep trying. Actually we use loops all the time though we aren't conscious of it. For example, there are some people with brain injuries who will not know when to stop performing some action because the bit in their brain which loops until that action is done is faulty. There was a famous case of a woman who wrote to her doctor like this

"I am writing to tell you that I am writing to tell you that I am writing to tell you that.." and the doctor knew straight away what was wrong with her.

I think I've gone off at a tangent a tangent a tangent..


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Hey martin,

The main reason I'm hesitant to use For...Each loops is because I can't seem to get variables right. I have just re-written my AutoIT script that works beautifully on one file (yes, the"..." is the actual path in my code):

ShellExecute("C:\Documents and Settings\...\Desktop\New folder\myfile.vsd")
WinWait("myfile.vsd - Microsoft Visio","")
If Not WinActive("myfilevsd - Microsoft Visio","") Then WinActivate("myfile.vsd - Microsoft Visio","")
WinWaitActive("myfile.vsd - Microsoft Visio","")
Send("{CTRLDOWN}{SHIFTDOWN}b{SHIFTUP}{CTRLUP}")

however, when I try and use $file (even with declaring it), I get file not found errors...I guess I'll just have to take the time and learn this today.

Thanks for your help!

Chris

Share this post


Link to post
Share on other sites

Hey martin,

The main reason I'm hesitant to use For...Each loops is because I can't seem to get variables right. I have just re-written my AutoIT script that works beautifully on one file (yes, the"..." is the actual path in my code):

ShellExecute("C:\Documents and Settings\...\Desktop\New folder\myfile.vsd")
WinWait("myfile.vsd - Microsoft Visio","")
If Not WinActive("myfilevsd - Microsoft Visio","") Then WinActivate("myfile.vsd - Microsoft Visio","")
WinWaitActive("myfile.vsd - Microsoft Visio","")
Send("{CTRLDOWN}{SHIFTDOWN}b{SHIFTUP}{CTRLUP}")

however, when I try and use $file (even with declaring it), I get file not found errors...I guess I'll just have to take the time and learn this today.

Thanks for your help!

Chris

If "..." is in the path in your code then you need to replace it with the user name I think. Look at the file in explorer and use the path in the address window.

Don't see $file so I can't comment on that.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If "..." is in the path in your code then you need to replace it with the user name I think. Look at the file in explorer and use the path in the address window.

Don't see $file so I can't comment on that.

The "..." is not in my code, it's my full NT Login user id and i don't want that on the forum ;-)

All I did for the $file was

Dim $file

ShellExecute("C:\Documents and Settings\...\Desktop\New folder\" & $file)

Sorry for the confusion with the path!!

Chris

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