rietproductions Posted October 3, 2015 Share Posted October 3, 2015 Is there any way to perform multithreading in autoit? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 3, 2015 Moderators Share Posted October 3, 2015 rietproductions,In short - No.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rietproductions Posted October 3, 2015 Author Share Posted October 3, 2015 rietproductions,In short - No.M23Indeed short why not ? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 3, 2015 Moderators Share Posted October 3, 2015 (edited) rietproductions, we have this wonderful wiki that can answer so many of your questions.https://www.autoitscript.com/trac/autoit/wiki/AutoItNotOnToDoList Edited October 3, 2015 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Celtic88 Posted October 4, 2015 Share Posted October 4, 2015 you can use multi process method! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 4, 2015 Moderators Share Posted October 4, 2015 Multi process and multi threaded are two very things. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Kinshima Posted October 18, 2015 Share Posted October 18, 2015 (edited) Func _START_BACKGROUND_FUNCTION($f) Local $handle = DllCallbackRegister("_SubThread", "int", "ptr") Local $dllstr = DllStructCreate("Char[200]") DllStructSetData($dllstr, 1, $f) ;arg/parameter 1 Local $return = DllCall("kernel32.dll", "hwnd", "CreateThread", "ptr", 0, "dword", 0, "long", DllCallbackGetPtr($handle), "ptr", DllStructGetPtr($dllstr), "long", 0, "int*", 0) ;$return[0] - handle ;$return[6] - thread id EndFunc ;==>_START_BACKGROUND_FUNCTION Func _SubThread($x) Local $get = DllStructCreate("char[200]", $x) Call( DllStructGetData($get, 1)) EndFunc ;==>_SubThread Func _TEST() MsgBox(0,"","Yes but there are so many problems that it is very limited.") EndFunc Func _TEST2() MsgBox(0,":)","(: :) :(") EndFunc _START_BACKGROUND_FUNCTION("_TEST") _START_BACKGROUND_FUNCTION("_TEST2") msgbox (0,0,"Can AutoIt mutlithread"); if you close main process all subtreads are closedIt is possible but there are some limitations. This runs a function in the background. I don't know what you need it for i can show you sometime how you pass values back and forth but it is somewhat advanced. Edit: This example is already wrong, in some cases after it finishes the subtread it will continue to run the main thread, the only difference is if $return rertuns the data or not. You can use this Return or Not data to cancel out or continu after the function completes. Try the example a few times and you will see. It is not impossible to make it solid and stable but it is a lot of work. Edited October 18, 2015 by Kinshima Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2015 Share Posted October 18, 2015 It's been argued many times that you can, and nothing is impossible etc...But the fact is that AutoIt was not designed for it, and so if you can it will be very unstable and really not worth it.If you think you absolutely 100% need it, then I suggest you turn to a language that supports it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kcvinu Posted October 18, 2015 Share Posted October 18, 2015 @JohnOne You said it very easily. But it is not quite easy to find a language which does things just like autoit. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
BrewManNH Posted October 18, 2015 Share Posted October 18, 2015 His point wasn't that other languages are easier or as easy, his point was that if you REALLY need multi-threading, then don't use AutoIt because it won't work very well if at all.Nothing AutoIt does can't be done in another language, it's just not as easy to write it in other languages. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2015 Share Posted October 18, 2015 @JohnOne You said it very easily. But it is not quite easy to find a language which does things just like autoit. In fairness, I'd despair if someone who can write an AutoIt script or even know what a script is, that could not find a mainstream and well supported language that can do everything AutoIt can and more, while supporting multithreading.People are disappointed when they learn there is no support for it, but that's all it is disappointment. You can spend 6 weeks trying to multithread in AutoIt or you can spend 6 weeks learning C++ or C# etc... Muhammad_Awais_Sharif and Xandy 2 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kcvinu Posted October 18, 2015 Share Posted October 18, 2015 (edited) @JohnOne , We can do a specific thing in other languages but it is not as easy like in autoit. For eg. iniRead(). In vb.net, we can call the API function for this. But you can do the job in one line code in autoit. @BrewManNH I agree 100% with you. Edited October 18, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
JohnOne Posted October 19, 2015 Share Posted October 19, 2015 I can tell you what is much harder than writing an IniRead function in VB.net, getting multithreading to work proper in AutoIt. kcvinu 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kcvinu Posted October 19, 2015 Share Posted October 19, 2015 @JohnOne I know that. But why don't autoit include most of its ability to it's COM version. If so, we can glue it in our projects. I mean if i can use a UDF inside vb.net with COM, it is great help. Then this multithreading or OOP is not a problem for us. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
JohnOne Posted October 19, 2015 Share Posted October 19, 2015 I'm pretty sure VB.net would be able to ShellExecute your AutoIt scripts/compiled scripts.We know it would be great to have multithreading, but it's specifically stated that there will never be any.Shame, but a fact, so wasting any energy at all on it is wasted time for me.Parallel processing or another language are the only options. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kcvinu Posted October 19, 2015 Share Posted October 19, 2015 (edited) @JohnOne I did that in few times. But i think it is not possible to get the data from external exes which run by shell execute. Edit - I am not arguing for multithreading. Infact i don;t know how to use multithreading. I have tested it some times. It is quite easy to start a multi threaded process, but not easy to switch between process or come back to main thread (UI thread) Edited October 19, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
JohnOne Posted October 19, 2015 Share Posted October 19, 2015 (edited) It probably has CreateProcess where you can read stdout or create a pipe or something. But it's still convoluted compared to languages which support threads natively.I know you're not asking for threads, conversation is for OP benefit. Edited October 19, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tonycst Posted February 17, 2016 Share Posted February 17, 2016 What is the easiest language to learn after autoit that has multithreading ? And that has eazy IDE that helps you learn like autoit scite does. The only reason why i stick to autoit is because scite makes it very eazy to program etc, but i now i need to evolve. thanks in advance. I really hope autoit will evolve into something like multithreading language some day. Link to comment Share on other sites More sharing options...
jchd Posted February 17, 2016 Share Posted February 17, 2016 Threads are evil. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
ZeroClock Posted May 20, 2016 Share Posted May 20, 2016 (edited) On 18/10/2015 at 2:52 PM, Kinshima said: Func _START_BACKGROUND_FUNCTION($f) Local $handle = DllCallbackRegister("_SubThread", "int", "ptr") Local $dllstr = DllStructCreate("Char[200]") DllStructSetData($dllstr, 1, $f) ;arg/parameter 1 Local $return = DllCall("kernel32.dll", "hwnd", "CreateThread", "ptr", 0, "dword", 0, "long", DllCallbackGetPtr($handle), "ptr", DllStructGetPtr($dllstr), "long", 0, "int*", 0) ;$return[0] - handle ;$return[6] - thread id EndFunc ;==>_START_BACKGROUND_FUNCTION Func _SubThread($x) Local $get = DllStructCreate("char[200]", $x) Call( DllStructGetData($get, 1)) EndFunc ;==>_SubThread Func _TEST() MsgBox(0,"","Yes but there are so many problems that it is very limited.") EndFunc Func _TEST2() MsgBox(0,":)","(: :) :(") EndFunc _START_BACKGROUND_FUNCTION("_TEST") _START_BACKGROUND_FUNCTION("_TEST2") msgbox (0,0,"Can AutoIt mutlithread"); if you close main process all subtreads are closed It is possible but there are some limitations. This runs a function in the background. I don't know what you need it for i can show you sometime how you pass values back and forth but it is somewhat advanced. Edit: This example is already wrong, in some cases after it finishes the subtread it will continue to run the main thread, the only difference is if $return rertuns the data or not. You can use this Return or Not data to cancel out or continu after the function completes. Try the example a few times and you will see. It is not impossible to make it solid and stable but it is a lot of work. expandcollapse popup#include <Array.au3> Opt("MustDeclareVars", 1) Func Test_1($x) Local $Array = _STCBF_Struct($x) Local $At = '' For $i = 0 To (UBound($Array)-1) Step 1 $At &= $Array[$i] &' - ' ;ConsoleWrite("$Array["& $i &"] = "& $Array[$i] &@CRLF ) Next MsgBox(0x40, "Thread-1", "Added Thread #1" &@CRLF&@CRLF& StringLeft($At,(StringLen($At) -3)) ) EndFunc ;==> _Thread_Start Func Test_2($x) Local $Array = _STCBF_Struct($x) Local $At = '' For $i = 0 To (UBound($Array)-1) Step 1 $At &= $Array[$i] &' - ' ;ConsoleWrite("$Array["& $i &"] = "& $Array[$i] &@CRLF ) Next MsgBox(0x40, "Thread-2", "Added Thread #2" &@CRLF&@CRLF& StringLeft($At,(StringLen($At) -3)) ) EndFunc ;==> _Thread_Start Func Test_3($x) Local $Array = _STCBF_Struct($x) Local $At = '' For $i = 0 To (UBound($Array)-1) Step 1 $At &= $Array[$i] &' - ' ;ConsoleWrite("$Array["& $i &"] = "& $Array[$i] &@CRLF ) Next MsgBox(0x40, "Thread-3", "Added Thread #3" &@CRLF&@CRLF& StringLeft($At,(StringLen($At) -3)) ) EndFunc ;==> _Thread_Start Local $Ax[4] = [100, 'A', 200, 'B'] Local $N = 10 Local $Bx[4] = [300, 'C', 400, 'D'] _Sub_Thread_CallBack_Func("Test_1", $Ax) _Sub_Thread_CallBack_Func("Test_2", $N) _Sub_Thread_CallBack_Func("Test_3", $Bx) MsgBox(0x40, "Thread-0", "## Default_Thread ##") ;################################################################################################################################################# Func _Sub_Thread_CallBack_Func($F, ByRef $P) Local $Px = "", $L = StringLen($P) If IsArray($P) Then For $i = 0 To (UBound($P)-1) Step 1 $Px &= $P[$i] &"," Next $Px = StringLeft($Px, (StringLen($Px) -1) ) $L = StringLen($Px) $P = $Px EndIf Local $H = DllCallbackRegister($F, "int", "DWORD_PTR") Local $S = DllStructCreate("INT; Char["& $L &"]") DllStructSetData($S, 2, $P) DllStructSetData($S, 1, $L) Local $R = DllCall("kernel32.dll", "hwnd", "CreateThread", "ptr", 0, "dword", 0, _ "long", DllCallbackGetPtr($H), "ptr", DllStructGetPtr($S), "long", 0, "int*", 0) ;DllCallbackFree($H) ;Return $R Sleep(10) EndFunc Func _STCBF_Struct(ByRef $x) Local $y = DllStructGetData(DllStructCreate("INT; Char["& DllStructGetData(DllStructCreate("INT; Char[1]", $x), 1) &"]", $x), 2) Local $Ar = StringSplit($y, ',', 2) Return $Ar EndFunc ;################################################################################################################################################# Edited May 20, 2016 by ZeroClock Link to comment Share on other sites More sharing options...
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