Sign in to follow this  
Followers 0
SorryButImaNewbie

How Would you? ControlSend "string" changing

4 posts in this topic

Hello everyone!

I have run in to a problem, and I hoped that you guys can show me some bestpractice solution for it.

My Function should send a "code" (19 characters all, are numbers) to a control and then keep running, updateing the database and save something in PDF (through the program its handeling/ the program that the script is intended to use, I hope its understandable)

I can do all of that, but the tricky part is coming now. I have to make this so its runs with the program automated (for testing/debuggin purposes) and possible, do these "random data entry" multiple times. The problem that in the program, I can only use the same code twice a day. Also while the code has it's mandatory form, I don't know them all so Regex random generation is highly problametic, since it can generate something that wont be accepted. Right now i have 6 code, that i know will run, and can find more with a bit of trial/error aproach.

I think I will need an array of the codes i know are accepted, and make it so the function use all of them twice and no more in a single day. (don't know when the program resets the daily quota)

My other idea/aproach could be that it runs like: using first code in array till it gets an error MsgBox that this code has reached its daily limit, then goes back and starts with the next code in the line. If the next code is rejected I know that I'm out of code for the day, and I can warn the user of that with a MsgBox.

I'm not sure if my ideas are good ones, or not. I have reached the point where the codes runs and do everything properly with a pre-defined "code" in the script (I mean that I have written what to write to the TextBox in to the ControlSend string, so while Its not useable, i know that my script can run otherwise)

I thank for any advice or idea for how to handle this situation! and thank you for your help and contribution!

(If you have any question about the topic, pls ask and I do my best to answer it)

 

Share this post


Link to post
Share on other sites



Create either an array of the codes that you know or write them in an ini file and read them into your program. Use Timerinit and Timerdiff to manage the 2 times a day requirement. You could also use date.au3 and something like _NowTime.

Do they need to be saved in a pdf or will any file type work?

I am curious about the application that you are using this for.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

Morning! 

Well the application is another "home developed" system, I mean that it has been developed inside the company. Its basicly a big database interface. I'm writng an auto debug prgoram for it, right know I'm working on the functions I will use, then I will build a GUI that allows the user to call the functions they need.

I choose to have the array inside my script as a global array (global variable? not sure of the syntax) and use an If.... Then to "split" the scripts path between the 2 possible MsgBox that pops up.

If it gets the code has been used today twice already, then it goes in to a Do... Until loop trying till he gets the code selected message. My problem right now, that once it receive the message its waiting for, it stops running, I mean it doesn't seems to "leave" the loop and continue the script.

This solution is not optimal, since it can try to write a lot of used code, but I start to look into these Timerinit and Timerdiff functions.

Here is the fragment of my code i was talking about:

If WinExists("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") Then ;thats the error message for the daily limit reached
Do
WinKill("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )")
$i = $i + 1
ControlFocus($handle, "", "TEdit1")
Send("{CTRLDOWN}v{CTRLUP}")
ControlClick($handle, "", "[CLASSNN:TAdvBitBtn23]")
WinWaitActive("Befizetés") ;This is the form where we write the code
Local $handle3 = WinGetHandle("Befizetés")
ControlSend($handle3, "", "[CLASSNN:TComboBox3]", "ü{ENTER}")
ControlSend($handle3, "", "[CLASSNN:TEdit5]", $arrayEuroShell[$i])
ControlClick($handle3, "", "[CLASSNN:TBitBtn2]")
Sleep(1000)
Until WinActive("Információ", "Sikeres jegyvásárlás!") ;code accepted pop up window
Local $handleinfo = WinGetHandle ("Információ", "Sikeres jegyvásárlás!")  ;This was my last try yesterday (I run out of codes to try and my work time was at its end anyway)
EndIf
ControlClick($handleinfo,"", "[CLASSNN:TBitBtn1]") ;should click okey on the okey messagebox

Share this post


Link to post
Share on other sites

How would timerinit and diff help me?

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