grakker Posted March 16, 2004 Share Posted March 16, 2004 This is so basic that I'm a little embarrassed putting it up here, but I can't figure it out so, here is my situation: In my job I have to run a variable number of reports every morning from a crappy application my company uses. The app has some primitive scripting abilities, but it is unable to print out hardcopy from the script. So I figure out how many of my different reports I need to run, run it as a script, come back to my computer about 10 minutes later and I have layers of reports that I need to print out. For each screen I need to type 1. CNTRL-P 2. {ENTER} // for the confirm print window 3. wait for the printing status window to close 4. {ESC} // to exit from the report window 5. N // No, I don't want to save the report Then I'm back to a new report with basically the same title and slightly different information. The whole loop takes about 2 seconds, but every day it's getting a little more annoying. So I found autoit and thought this would do the trick. Here is the basic script I wrote: HotKeySet ("^L", "mPrint") Func mPrint () SEND("^p{ENTER}") SLEEP(500) WinWaitActive("Printing") WInWaitClose("Printing") SEND("{ESC}N") EndFunc I just want to get it to run once, then I can through it in a little loop with a window asking how many times to run through it. Anyone point me to where I'm really missing the boat? Thanks Link to comment Share on other sites More sharing options...
scriptkitty Posted March 17, 2004 Share Posted March 17, 2004 (edited) You just never call out the function before it ends. Try this HotKeySet ("^L", "mPrint") while 1 ; this is an endless loop, hotkey functions work fine as long as AutoIt is running ; so this will keep it running, press your hotkey to activate. sleep(10) wend Func mPrint () SEND("^p{ENTER}") SLEEP(500) WinWaitActive("Printing") WInWaitClose("Printing") SEND("{ESC}N") EndFunc good luck on your scripting adventures.... Edited March 17, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
grakker Posted March 17, 2004 Author Share Posted March 17, 2004 Ahhh... OK, I think that I just saw the light. I'm too used to writing up little bash or php things. I saw variations of that and just figured that it was wrong, because a infinite loop would never exit to allow the function to get called, and the function isn't called in the loop, so..... That's where I was stuck. Anyways, thanks for the help, it works perfectly and I'm on my way. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now