Jump to content

UDF : Multi-threading made easy


Go to solution Solved by Nine,

Recommended Posts

Posted (edited)

How does it feel when you have written more than 39,000 program codes and because of an unwanted change, your compiled program is decompiled by a thief?

Thanks to my dear friend Nine for sharing his nice code

I compile my program with the following parameters
The presence of your line code made me worry that a copy of the program source should be saved in the compiled version

Edited by Parsix
Posted

@Parsix  Please edit your post and make it normal font.  All programs can be decompiled, even more easily if it is a scripting language.  The way this UDF is made, it is needed to include the original code inside the .exe.  If you are afraid that your code get stolen, there is nothing much you can do against someone with bad intents.

Posted (edited)
51 minutes ago, Nine said:

@Parsix  Please edit your post and make it normal font.  All programs can be decompiled, even more easily if it is a scripting language.  The way this UDF is made, it is needed to include the original code inside the .exe.  If you are afraid that your code get stolen, there is nothing much you can do against someone with bad intents.

It is the intellectual preoccupation of every programmer

Edited by Parsix
  • 9 months later...
Posted

@Nine Hellooo ! I just tested your PMT UDF with the example provided, but I got 2 issues. The 1st one comes from this line :

Local $iPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & $sFile, "", Default, $STDOUT_CHILD)

How can it work if there is at least 1 space in $sFile ?

These are my 3 tests :

; Local $sFile = _TempFile(@ScriptDir, "~~", ".au3", 12) ; won't work for me as plenty of spaces in path
; Local $sFile = _TempFile("F:\Temp space\", "~~", ".au3", 12) ; won't work for me as 1 space in path
Local $sFile = _TempFile("F:\", "~~", ".au3", 12) ; ok

For example, with the 2nd test, e.g. when "F:\Temp space\" is used :

Runissuewhenspace(s)infilepath-name.png.6b8d970a27448fc30a41ea1c174853f7.png

Do you have the same issue or is it just me ?
Thanks

Posted (edited)
4 hours ago, pixelsearch said:

[...] but I got 2 issues.

Glad we could catch the 1st one.

So apparently all users of the function (except me) got a @ScriptDir that doesn't contain any space, interesting... or maybe some users fixed the issue as you just did (I preferred to share the issue by posting it, instead of fixing it silently on my computer)

Concerning the 2nd issue, I'm perplexed because it seems to me that's it's related to my old OS. Anyway, let's share it too : what happens on your computer when you do this :

1) Create a called script named MyMessageBox.au3 which contains the following line :

MsgBox(0, "", "In MyMessageBox.au3")

2) Create a calling script that contains these lines :

#include <File.au3>

Local $sFile =  @ScriptDir & "\MyMessageBox.au3"
Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sFile & '"', "", Default, $STDOUT_CHILD)
ProcessWait($iPID, 5)
; FileDelete($sFile)

* When you run the calling script (once or more), then you'll always see the MessageBox from the called script displayed, so far so good.

* But If you uncomment the FileDelete line, what happens when you run the calling script ?
On my computer, an error always appears because the called script has been deleted from disk :

FileDeletecreatesanissue.png.4f0433fb66f06d41da4bc2b9ed8e0ede.png

Which explains why I can't "FileDelete" any of the 3 temporary files found in your UDF example, or I'll get this error. On my computer, the example associated to your UDF works fine only if I comment out this line in the UDF (which will leave the temp files on disk after the script ends, but it's better than getting blocking error messages)

; FileDelete($sFile) ; won't work for me when $sFile is deleted here. UDF works when this line is commented out.

Anyway, I guess it works fine for all of you because noone ever complained  when running your UDF
Edit: this test was done uncompiled, for what it's worth...

Edited by pixelsearch
typo
Posted (edited)

Sorry I don't get it.  Could you make a script running my UDF, that will show the issue.  All I see from your examples is a hack of my UDF. 

Edited by Nine
Posted (edited)
10 minutes ago, Nine said:

Could you make a script running my UDF,

The script is your example, untouched, as found in 1st post !

On my computer, your example works if I comment out this line in the UDF

; FileDelete($sFile)

But it brings 3 fatal errors if I leave it uncommented, as explained in my preceding post :

FileDelete($sFile)

 

Edited by pixelsearch
added "in the UDF"
Posted (edited)

Again, I cannot debug something I do not see.  Maybe it is a timing issue. But it is certainly not a question of space in the temp file.  So what are we searching for exactly ?  Not very clear...

Edited by Nine
Posted

"Space in the temp file" : you fixed it, so it's not a problem anymore, let's forget it forever.

OK, let's start from scratch :
1) I just download your reworked UDF and your example, place them both in F:\
2) I run the example and here is what is displayed on my screen :

3filedeleteissues.png.3d1e17689c6aed31d0bb89f1c3bed7d5.png

==============

Before running your example a 2nd time, IF I open your UDF (for the 1st time) and do one change in it (commenting out the FileDelete line) then the example works fine, without errors !

So it may be a Timing issue as you suggested, idk

 

Posted (edited)

Sorry I cannot replicate your problem.  I just used USB card, copied the the 2 files (udf and ex), started it from window explorer without Scite, and all work perfectly.  So there must be something on your side that refrain the execution of the UDF.  Unless I can reproduce your issue, I am afraid I cannot help anymore.

Edited by Nine
remove comment
Posted

I compiled the given example and it fails.
Error: Process has dropped when "#Au3Stripper_Parameters=/mo"
now, without the Au3Stripper it gets worse:
AutoIt Error:  Line 2  (File "R:\This TEMP\~~bdnpztbvewcv.au3"):
#include <R:\This TEMP\Include\Constants.au3>
Error: Error opening the file.

..then the Process has dropped error.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

I added this UDF to the wiki :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

@argumentum  You cannot use stripper with this UDF.  You must understand that each function is separated from the rest of the code.  So defining a global variable outside of the function will not work.

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...