Jump to content
beekeeper222

multiplying variable every loop

Recommended Posts

I want to make a scrip that does a simple action in excel, by clicking on each unit, doing a simple action and then moving to the higher/lower unit, I came up with that idea, but don't know how to multiply variable $moveY x+1 time every time loop runs

$OriginalX = MouseGetPos(0)
    $OriginalY = MouseGetPos(1)
    $MoveX = 0
    $MoveY = -73
Dim $i=1
While $i<=10
  ;Action
   MouseMove(403,964) ;starting unit coords
    MouseMove($OriginalX + $MoveX, $OriginalY + $MoveY)
   WEnd

 

Share this post


Link to post
Share on other sites
For $i = 1 To 10
    ;Action
    MouseMove(403,964) ;starting unit coords
    MouseMove($OriginalX + $MoveX*$i, $OriginalY + $MoveY*$i)
Next

 

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Sure, you just change $MoveY each time you click, but wouldn't recommend this method for Excel, in fact I rarely recommend mouseclick or send for anything.

Share this post


Link to post
Share on other sites
9 minutes ago, beekeeper222 said:

But i'd have to write the script all over again, that one is almost completed

I agree with @Subz !
Your script may seem almost completed to you, but you are using a rather unreliable approach. It should not take too much effort to rebuild the script using the Excel UDF. On the long run, you will probably even save time if, for example, extensions are required.


Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...