Jump to content

Looping batch of instructions


tekhed
 Share

Recommended Posts

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

Link to comment
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

Link to comment
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]
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...