Jump to content

Recommended Posts

  • Moderators
Posted

rietproductions,

In short - No.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

  • Moderators
Posted (edited)

rietproductions, we have this wonderful wiki that can answer so many of your questions.

https://www.autoitscript.com/trac/autoit/wiki/AutoItNotOnToDoList

 

Edited 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!

  • 2 weeks later...
Posted (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 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.

Edited by Kinshima
Posted

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.

Posted

@JohnOne You said it very easily. But it is not quite easy to find a language which does things just like autoit. 

  Reveal hidden contents

 

Posted

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 Gude
How to ask questions the smart way!

  Reveal hidden contents

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

Posted
  On 10/18/2015 at 3:21 PM, kcvinu said:

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

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted (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 by kcvinu
  Reveal hidden contents

 

Posted

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

  Reveal hidden contents

 

Posted

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.

Posted (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 by kcvinu
  Reveal hidden contents

 

Posted (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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

  • 3 months later...
Posted

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.

Posted

Threads are evil.

  Reveal hidden contents

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 here
RegExp tutorial: enough to get started
PCRE 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)

  • 3 months later...
Posted (edited)
  On 10/18/2015 at 12: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.

Expand  
#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 by ZeroClock

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