Jump to content

Recommended Posts

Posted

Once again, I'll have to rely on your help.

I'm trying to make a script that will count how many times the "For" has been run and associate this variable to the "send" command. Is it at all possible?

Just to be more descriptive: I have an Excel spreadsheet(rows will vary) where I have to copy the contents of a cell and paste it into another program. This will be repeated until the last cell contents. Here's the code I have so far:

;Typing basic data
WinActivate("XXXXXX")
WinWaitActive("XXXXXXX")
ControlSend("XXXXX","","Edit1","va01")
Send("{Enter}")
WinWaitActive("YYYYYY")
MouseClick("left",136,177,1)
Send("AAAA")
Send("{TAB}")
Send("9999")
Send("{TAB}")
Send("l")
Send("{TAB}")
Send("00")
Send("{Enter}")

;Order Entry Screen
WinWaitActive("YYYYYY")
Send("ONEFACT")
Send("{TAB 3}")
Send("ONEFACT")
Send("{ENTER}")

_ExcelBookOpen($sFilepath, $fVisible, $fReadOnly)

    For $j = 1 to $iRowEnd - 4
        $Count=$Count+1
    WinActivate("XXXXXXX")
    WinWaitActive("XXXXXx")
    Send("{F5}")
    WinWaitActive("Go To")
    Send("J4")
    Send("{ENTER}")
    WinActivate("XXXXXX")
    WinWaitActive("XXXXXXX")
    Send("{CTRLDOWN}c{CTRLUP}")
    WinActivate(" ZZZZZZZZZZZ")
    WinWaitActive(" ZZZZZZZZZZZZZZZ")
    MouseClick("left", 198, 114,1)
    Send("{DEL 255}")
    Send("{CTRLDOWN}v{CTRLUP}")

;Pasting Street/House Number
    WinActivate("XXXXXXXXX")
    WinWaitActive("XXXXXXX")
    Send("{F5}")
    WinWaitActive("Go To")
    Send("K4")
    Send("{ENTER}")
    Send("{CTRLDOWN}c{CTRLUP}")
    WinActivate(" ZZZZZZZZZZZZZZZ")
    WinWaitActive(" ZZZZZZZZ")
    MouseClick("left", 198, 185,1)
    Send("{CTRLDOWN}v{CTRLUP}")
    Send("{DOWN $Count}")
        Next
Posted

From the help file under Send():

If you wish to use a variable for the count, try

$n = 4

Send("+{TAB " & $n & "}")

But... you are using _ExcelBookOpen(), which implies you are including ExcelCOM_UDF.au3, so why hack it like this when you have such a powerful tool available to just do the copy and paste directly? For example, _ExcelSheetUsedRangeGet() will tell you what the last row/column is, and with _ExcelCopy()/_ExcelPaste() this could be done much better.

<_<

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Thanks PSalty! I know this methodology is not the brightest but I was writing it on the run and had to have that logic implemented quickly. I figured that implementing this using the regular functions AutoIT has I would be able to enhance it to use it better with the ExcelCOM UDF. For now, the previous method with a few arrangements will do the work. This afternoon I'll get to the script again and try to implement it using the Excel UDF.

The possibilities that AutoIT brings always amazes me, specially when we can ally it to UDFs.

BTW, I'm finding this forum one of the best I've participated on any kind of subjects. There's always someone willling to help.

Thank you once again!

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
  • Recently Browsing   0 members

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