Sign in to follow this  
Followers 0
tekhed

Looping batch of instructions

7 posts in this topic

New to scripting in general, so I haven't made sense of a way to loop the following script until clipboard = empty.

;
; AutoIt Version: 3.0
; Language:    English
; Platform:    WinXP
; Author:        Michael Harrell
; Purpose:      To automatically enter purchase order data, even if it is only cut-and-paste!;)


; activate excel window, make sure to start spreadsheet active cell on A1!
$text = ClipGet ()
Do
WinActivate("Microsoft Excel - AS400.xls")
Send("{DOWN}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{ENTER}")
WinWaitActive("CALL CMSM04 - Microsoft Internet Explorer")
send("{ENTER}")
Until $text = 1

The above code doesn't actually work, because the 'Do - Until' loop is not accurate. How would I get AutoIT to repeat the cut/paste instructions until it goes back into excel, tries to copy something, but copies nothing then quits?

Thanks in advance,

Mike

Share this post


Link to post
Share on other sites



Crap, wrong place to post this, sorry... :">

Share this post


Link to post
Share on other sites

Have tried a variety of functions (If/Then, While/Wend, the one you suggested), with no success. Is there maybe another way to accomplish what I'd set out to do, cut-and-paste until clipboard is empty?

Thanks,

Mike

Share this post


Link to post
Share on other sites

Try:

While ClipGet()<>""
  WinActivate("Microsoft Excel - AS400.xls")
  Send("{DOWN}^c")
  ...
  WinWaitActive("CALL CMSM04 - Microsoft Internet Explorer")
  send("{ENTER}")
WEnd

Maybe you can give more specific detail, WHY it does not work? (Does not compile, does not get out of loop, ...)

Greetings,

ZeD

Share this post


Link to post
Share on other sites

Good point, sorry. It ignores the function itself, so it would simply run the entire script, ignore while/wend or do/until, and end.

Share this post


Link to post
Share on other sites

Is this already fixed? lol wouldnt u do

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       WinXP
; Author:         Michael Harrell
; Purpose:        To automatically enter purchase order data, even if it is only cut-and-paste!;)


; activate excel window, make sure to start spreadsheet active cell on A1!
$text = ClipGet ()
Do
WinActivate("Microsoft Excel - AS400.xls")
Send("{DOWN}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{TAB}")
WinActivate("Microsoft Excel - AS400.xls")
Send("{RIGHT}^c")
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
send("^v{ENTER}")
WinWaitActive("CALL CMSM04 - Microsoft Internet Explorer")
send("{ENTER}")
Until @error = 1

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       WinXP
; Author:         Michael Harrell
; Purpose:        To automatically enter purchase order data, even if it is only cut-and-paste!;)


; activate excel window, make sure to start spreadsheet active cell on A1!
$text = ClipGet ()
Do
Call("window2")
Send("{DOWN}^c")
Call("window1")
send("^v{TAB 6}")
Call("window2")
Send("{RIGHT}^c")
Call("window1")
send("^v{TAB 2}")
Call("window2")
Send("{RIGHT}^c")
Call("window1")
send("^v{TAB}")
Call("window2")
Send("{RIGHT}^c")
Call("window1")
send("^v{TAB 4}")
Call("window2")
Send("{RIGHT}^c")
Call("window1")
send("^v{TAB 2}")
Call("window2")
Send("{RIGHT}^c")
Call("window1")
send("^v{TAB}")
Call("window2")
Send("{RIGHT}^c")
Call("window1")
send("^v{ENTER}")
WinWaitActive("CALL CMSM04 - Microsoft Internet Explorer")
send("{ENTER}")
Until @error = 1
Exit


Func window1()
WinActivate("CALL CMSM04 - Microsoft Internet Explorer")
EndFunc

Func window2()
WinActivate("Microsoft Excel - AS400.xls")
EndFunc

i hope i cleaned up the code for ya... this way makes it less confusing. i seperated your winactive into function calls. al the sending of the tab key, you don't need to kee p going {tab}{tab}{tab}{tab}{tab} just do this instead, {tab 5} the space and the number after words tells the send to send that key 5 times in a row.


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

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