Sign in to follow this  
Followers 0
SorryButImaNewbie

Why would autoit run differently on consecutive runs?

9 posts in this topic

Have a good day dear reader!

I'm writing a code to auto bug test in a realativly big system.

I'm needed to save some results on PDF for that i use PDF creator 1.7.1

On different tests i usually copy my code and simply rewrite the part where it "names" the PDF before saving. My usuall "1st test" with any code that I check if it runs the same way 5 different times. (The very fact that I developed this habbit show how many times i run in to this) I usually need to do more then rewrite the name of the PDFs, sometimes I add Sleep or change the logic how i arrive to some kind of solution. The annoying thing is, when I start testing a code and I see it runs as I intended once-twice even third-time and then at the fourth-time It doesn't act as it should for some reason (in this particular instance It didn't get the ControlGetText)

I don't know if there is something wrong with the way I use a command or what can i do to avoid this as much as possible

Here is the code fragment I was talking about

before it, the script create the data in the program for testing and the PDF creator automaticly started by the program

Thank you for your noble help dear Sir/Brave Traveler!

PS: I couldn't find any other thread about this, sorry if it has been answered already

 
WinWaitActive("PDFCreator")
Local $handle4 = WinGetHandle("PDFCreator", "")
Sleep(5000)
ControlFocus($handle4, "", "ThunderRT6TextBox5")
Sleep(500)
Local $VJdate = "TeszttVJ" & ControlGetText($handle4, "", "ThunderRT6TextBox5")
MsgBox(0, "VJdate teszt", $VJdate)
Sleep(1000)
ControlSetText($handle4, "", "ThunderRT6TextBox6", $VJdate & "(1)EuroSztornó")
Sleep(1000)
ControlClick("PDFCreator 1.7.1", "", "[CLASSNN:ThunderRT6CommandButton7]")
Sleep(2000)
Send("{ENTER}")
Sleep(1000)
WinWaitActive("PDFCreator")
Sleep(1000)
Local $handle5 = WinGetHandle("PDFCreator", "")
ControlSetText($handle5, "", "ThunderRT6TextBox6", $VJdate & "(2)EuroSztornó")
Sleep(1000)
ControlClick("PDFCreator 1.7.1", "", "[CLASSNN:ThunderRT6CommandButton7]")
Sleep(2000)
Send("{ENTER}")
 

Share this post


Link to post
Share on other sites



IIRC PDFCreator has a COM interface. This means you do not need to automate the GUI but can reliable script PDFCreator via COM methods.

A german web site states that starting with version 0.8.1 RC9 released in 2006 PDFCreater has this API.

Starting with version 0.9.0 the installer offers to install additional COM examples.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

But if the program automaticly opens the PDF creator, I can still use a COM interface to "tell" it what to do?

Sorry I never used COM interface before (actually I just googled it, I learnt about it in university, but just that it's an interface between programs, or what ever else I already forgot) so I would prefer to use the basic autoit functions, since I see that it can work. Also I have to ask for permisson to download things (Not like I wouldn't get one for a COM interface)

But thanks for the tip water, now i can at least search better about the topic :)

Share this post


Link to post
Share on other sites

But if the program automaticly opens the PDF creator, I can still use a COM interface to "tell" it what to do?

Sorry I never used COM interface before (actually I just googled it, I learnt about it in university, but just that it's an interface between programs, or what ever else I already forgot) so I would prefer to use the basic autoit functions, since I see that it can work. Also I have to ask for permisson to download things (Not like I wouldn't get one for a COM interface)

But thanks for the tip water, now i can at least search better about the topic :)

AutoIt allows to attach to an already running instance of a program by using ObjGet.

As far as I understand the web site you do not need to install any additional software to use COM. It is builtin. The installer just installs additional COM examples.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you guys, you gave me valuable homework :)

(any additional info is still welcome ofc)

Share this post


Link to post
Share on other sites

Thanks Bert!

I only gave myself this name, because I was put in to a position where i have to work with autoit and the only education i got about it was the previus guy who showed it to me for a day, I used other languages but always object oriented, so Its a roundabout way of saying that I'm a newbie in it. However i really start to love it, its and incredibly versatile tool

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