Jump to content
Sign in to follow this  
Stimorol

Increasing variables based on input value

Recommended Posts

Stimorol

Hey there folks.
 
I'm trying to automate some formfilling with a script to make it easier due to a lot of redundant clicking.

This is the script I have now:

#region Recorder functions
Func Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

AU3RecordSetup()
#endregion Recorder functions
#region Variables
Local $Company = InputBox("NYT KORT", "Enter Company Firma")
Local $Barcode = InputBox("NYT KORT", "Enter Account number for the barcode")
Local $CardNumber= InputBox("NYT KORT", "Indtast kort #")
#endregion Variables

#region - Print new card
WinWaitActivate("Flexi shop - CardExchange® Entry","")
MouseClick("left",82, 753,1)
Sleep(200)
Send($Company)
Sleep(200)
Send("{TAB}")
Sleep(200)
Send("Kort " & $CardNumber)
Sleep(200)
Send("{TAB}")
Sleep(200)
Send("*C-" & $Barcode & "*")
Sleep(200)
MouseClick("left",82, 808,1)
Sleep(200)
MouseClick("left",1635, 180,1)
Sleep(200)
#endregion - Create new card

#region - Create card in database
Local $ChipCode = InputBox("NYT KORT", "Scan kort" & $CardNumber)
WinWaitActivate("AEOS - Windows Internet Explorer","")
MouseClick("left",284, 222)
Sleep(200)
Send($Company)
Sleep(200)
MouseClick("left",310, 244)
Sleep(200)
Send("Kort " & $CardNumber)
Sleep(200)
MouseClick("left",437, 499)
Sleep(200)
Send("Kunder")
Sleep(200)
MouseClick("left",642, 499)
Sleep(200)
MouseClick("left",617, 543)
Sleep(200)
Send($ChipCode)
Sleep(200)
MouseClick("left",1589, 937)
#endregion - Create card in database

#region - Print extra card
WinWaitActivate("Flexi shop - CardExchange® Entry","Flexi shop - CardExc")
MouseClick("left",406,797,1)
MouseMove(404,800)
MouseDown("left")
MouseMove(300,797)
MouseUp("left")
Send("{BACKSPACE}")
Send("Kort " & $CardNumber)
MouseClick("left",95,855,1)
MouseClick("left",1629,178,1)
#endregion - Print extra card

 I need a way to repeat #region - Print extra card each number higher than 1 in the $CardNumber input box plus i need it to ask for a new ChipCode for each other card.
There will only be one specific $Company and $Barcode (for each time the entire script runs, inputbox in the beginning) but the ammount of cards and the chipcode will change multiple times.

How can I make the script repeat the Print Extra Card section with an increasing $Cardnumber and ask for a new $ChipCode for said $Cardnumber..

After the Print Extra Card section is done (for each card)$Cardnumber needs to be used in the second section "Create Card in Database"

Is this possible?

Flowchart if this explains better.

uHyK2TQ.png

Edited by Stimorol

Share this post


Link to post
Share on other sites
rudi

Hi.

typo line 5: Its not WinWaitActivate() but WinWaitActive()

Suggestion: Use the autoit window info tool to get the control-ID of buttons etc, then use controlcommand() and not x/y coordinates.

 

REgards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
Stimorol

typo line 5: Its not WinWaitActivate() but WinWaitActive()

 

But...

Func WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

?

 

Suggestion: Use the autoit window info tool to get the control-ID of buttons etc, then use controlcommand() and not x/y coordinates.

Most of this is browser based, I werent able to get any form of ID from our database system.

But thanks Rudi!

 

Edited by Stimorol

Share this post


Link to post
Share on other sites
TheSaint

You probably should have called your function WinWaitActivated so as not to confuse Rudi and maybe others.

Have you actually used it with a Timeout greater than zero?

Not having your setup, it is not entirely clear to me what is going on.

However, in my opinion you should be using the Print New, Create Card, Print Extra as three separate functions.

That way, you can call whatever you require in a loop.

Not knowing the makeup of your $Cardnumber, it is a little hard to tell how it needs incrementing.

If it is a full number (i.e. 11234) you could just use addition (i.e. 11235),

which would be as simple as $Cardnumber = $Cardnumber + 1

On the other hand, if it just the last one or so digits that need incrementing, then you need to separate them off, do your addition and then add the result back onto the tail of the remainder. Probably easily achieved just using StringLeft and StringRight and maybe a new temporary variable.

Really though, I don't know enough.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
Stimorol

So there isn't any way of inputting how many times you want to repeat a script x number of times?

Share this post


Link to post
Share on other sites
Stimorol

Not knowing the makeup of your $Cardnumber, it is a little hard to tell how it needs incrementing.

If it is a full number (i.e. 11234) you could just use addition (i.e. 11235),

which would be as simple as $Cardnumber = $Cardnumber + 1

It would be "How many cards does the company need?" where it would range from anything between 1 and 20.

So say Company A needs 2 cards the $Cardnumber 2 (where it'd love it to run the first part of the script with $cardnumber=1 and then run it again with cardnumber=2 so it reads the input at the top as how many times it should do the script while incrementing the number from 1.

 

Share this post


Link to post
Share on other sites
TheSaint
$repeat = InputBox("Cards Query", "Enter number of cards required.", 1)
If $repeat > 0 Then
     For $r = 1 To $repeat
          ....
          Your code here
          ....
     Next
EndIf
 
That's the simplest method to give you an idea how it might be achieved.
 
Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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  

×