Popular Post Nine Posted March 18, 2024 Popular Post Posted March 18, 2024 (edited) I need from from time to time to run small processes to perform task that would otherwise clog the main process. Yes, there is a number of other UDF that could have done it very well, but I felt they were an over-kill for what I wanted. Don't throw me stones, I know it's not really multi-threading, but it is as close as I could get with simple AutoIt. If someone wonders why I called it PMT, the P stands for Pretending. And I'm also not pretending it is an elaborate UDF. Just small and simple to use... Version 2025-01-03 * changed how temporary files are deleted * changed location of temporary files to use standard folder * added support to unusual location of AutoIt Version 2025-01-02 * corrected bug when temporary files has space within their name. Version 2024-03-24 * corrected bug when 8 parameters (max) is passed to the function Example : #AutoIt3Wrapper_Res_SaveSource=y #include "PMT-UDF.AU3" #include <Constants.au3> _PMT_Init() Local $hProc1 = _PMT_Start("Test1", Default, "Test 1") _PMT_Start("Test2") _PMT_Start("Test3", 5) Local $sResponse While Sleep(50) $sResponse = _PMT_GetResponse($hProc1) If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped") If $sResponse <> "" Then MsgBox($MB_OK, "Success", $sResponse & @CRLF) ExitLoop EndIf WEnd Func Test1($sTitle, $sMessage) Local $iResp = MsgBox($MB_OK, $sTitle, $sMessage) Return "Done with value " & $iResp EndFunc Func Test2() MsgBox($MB_OK, "2", "Test 2") EndFunc Func Test3($iTimeout) MsgBox($MB_OK, "3", "Test 3", $iTimeout) EndFunc You can pass up to 8 parameters to _PMT_Start. It is up to you to manage the right number. You cannot pass structures, maps or arrays as parameter (only bool, ptr, hWnd, int, float, string, and the keyword Default). You could use my WCD-IPC if need be to exchange large amount of data. If you want to run it compiled, you need to have add #AutoIt3Wrapper_Res_SaveSource=y at the start of your script. In the case you decide to compile your script, _PMT_Init allows you to identity where AutoIt3 is located (in the situation where AutoIt is not installed in the usual directory) to get the right includes in your "threads". Let me know if you have any question, or suggestion, I will be glad to hear them. Enjoy. PMT-UDF.au3 Edited January 3 by Nine ad777, CYCho, argumentum and 5 others 8 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Nine Posted March 24, 2024 Author Posted March 24, 2024 New version available mutleey 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Parsix Posted March 25, 2024 Posted March 25, 2024 #AutoIt3Wrapper_Res_SaveSource=y can be do not use this line ? put a source of script in compiled exe is not good idea
Nine Posted March 25, 2024 Author Posted March 25, 2024 @Parsix If you don't understand something, do not suggest useless idea “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Parsix Posted March 25, 2024 Posted March 25, 2024 #AutoIt3Wrapper_Res_SaveSource=y explaned in help file.
argumentum Posted March 26, 2024 Posted March 26, 2024 1 hour ago, Parsix said: explaned in help file. If you read the code, and the post, and the UDF, then you'll understand what and why. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Parsix Posted March 26, 2024 Posted March 26, 2024 (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 March 26, 2024 by Parsix
Nine Posted March 26, 2024 Author Posted March 26, 2024 @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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Parsix Posted March 26, 2024 Posted March 26, 2024 (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 March 26, 2024 by Parsix Nine 1
pixelsearch Posted January 2 Posted January 2 @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 : Do you have the same issue or is it just me ? Thanks Nine 1
Nine Posted January 2 Author Posted January 2 (edited) You are right. It needs to be embedded in quotes. Thanks for catching it. New version available. Edited January 10 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
pixelsearch Posted January 3 Posted January 3 (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 : 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 January 3 by pixelsearch typo
Nine Posted January 3 Author Posted January 3 (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 January 3 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
pixelsearch Posted January 3 Posted January 3 (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 January 3 by pixelsearch added "in the UDF"
Nine Posted January 3 Author Posted January 3 (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 January 10 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
pixelsearch Posted January 3 Posted January 3 "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 : ============== 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
Nine Posted January 3 Author Posted January 3 (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 January 3 by Nine remove comment “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
argumentum Posted January 3 Posted January 3 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.
water Posted January 3 Posted January 3 I added this UDF to the wiki Nine and argumentum 1 1 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
Nine Posted January 3 Author Posted January 3 @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. argumentum 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now