Jump to content

Multithreading for AutoIt - finally


jennico
 Share

Recommended Posts

damnit.. and here i thought it was really multi-threading.. grr. Tried to run 20 of these basically at the same time, but the next one wouldn't run unless the previous had returned from its function.

grr..

going to look at CoProc that was mentioned here.

Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Who says I'm crying? :P

I'm just saying this isn't multithreading, so you can stop calling them threads. Use an other word instead: "function", I don't know if you've ever heard of it.

Honestly, I think you're a little butthurt. We all know that they aren't threads, so stop flooding the topic with your whining about how the OP

uses vocabulary.

On topic:

I think this is a good workaround.

Keeps your mind in the game (Not having like, 50 things to worry about in the mainloop)

Alot easier to program with this.

Nice job.

Link to comment
Share on other sites

Honestly, I think you're a little butthurt. We all know that they aren't threads, so stop flooding the topic with your whining about how the OP

uses vocabulary.

On topic:

I think this is a good workaround.

Keeps your mind in the game (Not having like, 50 things to worry about in the mainloop)

Alot easier to program with this.

Nice job.

How about we think of it this way. Would you call a motorbike a car? Sure, it does the same thing in terms of getting you from A to B, but one is a car, and one is a motor bike. Not the same are they?

So yes, I'm on little butthurt kips' side.

It is NOT multithreading, and there will probably never be multithreading in AutoIt, so stop wishing.

Link to comment
Share on other sites

How about we think of it this way. Would you call a motorbike a car? Sure, it does the same thing in terms of getting you from A to B, but one is a car, and one is a motor bike. Not the same are they?

So yes, I'm on little butthurt kips' side.

It is NOT multithreading, and there will probably never be multithreading in AutoIt, so stop wishing.

We all know that they aren't threads

I think this is a good workaround

Can you read my whole post next time before posting arguments that I agreed with? >_>

Edited by Dampe
Link to comment
Share on other sites

Link to comment
Share on other sites

I was whining about how the OP was using his vocab... I read all of the post as well, I just chose to ignore it.... :P

Ah no prob, just wasn't following where you're thoughts were exactly coming from :unsure:
Link to comment
Share on other sites

  • 5 months later...

thank you !! >_<

please more comments. i am not sure about some details in the functions. the params and count is not tested thoroughly. so please tell me your testing results that i can fix problems.

j.

Hey,

I'm struggling to get _adlibEnable working when sending multiple parameters. I've looked at the Call help section, and have got multiple params working with the Call function.

The simple code below shows the Call function working, and the _adlibEnable not working.

Any help greatly apprecitate...

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <_adlib.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 95, 200, 192, 124)
$ButAdLib = GUICtrlCreateButton("_Adlib", 10, 20, 75, 25, $WS_GROUP)
$ButCall = GUICtrlCreateButton("Call", 10, 120, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
dim $aParams[3]
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $ButAdLib
            $aParams[0] = "CallArgArray"
            $aParams[1] = 10
            $aParams[2] = 2
            _adlibEnable("timed", 1000, 3, $aParams)
        Case $ButCall
            $aParams[0] = "CallArgArray"
            $aParams[1] = 10
            $aParams[2] = 2
            Call("timed", $aParams)
    EndSwitch
WEnd

func timed($number1, $number2)
    MsgBox(1, "", $number1 & $number2)
EndFunc
Link to comment
Share on other sites

  • 2 months later...

Hi jenico

Thanks for the script. It by sure will help me, as I normally make programs related to asyncronous events and from time to time must check if things are going well, and other stuff.

Do you have a more recent version?

Thanks

Jose

Link to comment
Share on other sites

@jennico

I'm going to chime in here so you can get a different perspective.

The title of your thread: Multithreading for AutoIt - finally is what the experienced coders have issue with. Your title suggest AutoIt can do something it CAN NOT do. You have also said that in a different post. #601534

Now, saying all that, you may want to change the title of your OP to something else than Multithreading for AutoIt - finally Otherwise you will keep getting badgered on making a false claim in the OP. This is just my opinion and in no way implies what you did wasn't a nice piece of work. It is a good piece of work.

Link to comment
Share on other sites

  • 4 months later...

I encounter problem when I run the example. Please advise

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Autoit\Script\Muti-Task\Muti-T4.au3"

C:\Program Files\AutoIt3\Include\_Adlib.au3 (137) : ==> Variable used without being declared.:

If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0

If $al_ID > ^ ERROR

>Exit code: 1 Time: 0.330

;--Muti-T4.au3

#Include <_Adlib.au3>

Func fone()

for $n1 = 1 to 9000

GuiCtrlSetData($lab1,$n)

sleep(500)

next

EndFunc

Func ftwo()

for $n2 = 1 to 9000

GuiCtrlSetData($lab2,$n)

sleep(400)

next

EndFunc

Link to comment
Share on other sites

I run the other sample with below error message. Please advise how to fix it.

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Autoit\Script\Muti-Task\Muti-T5.au3"

C:\Program Files\AutoIt3\Include\_Adlib.au3 (225) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:

If $al_current[$al_ID] Then $t = __Euclid($t, $al_time[$al_ID])

>Exit code: 1 Time: 0.638

Link to comment
Share on other sites

  • 1 year later...

Hello, I'm using this example:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <GuiComboBox.au3>
#Include <GuiListBox.au3>
#Include <GuiEdit.au3>

#Include "_Adlib.au3"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 427, 407, 193, 125)
$List1 = GUICtrlCreateList("", 8, 8, 201, 214)
$List2 = GUICtrlCreateList("", 216, 8, 193, 214)
$Progress1 = GUICtrlCreateProgress(8, 232, 150, 17)
$Slider1 = GUICtrlCreateSlider(8, 256, 150, 45)
$Button1 = GUICtrlCreateButton("Button1", 8, 312, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 8, 352, 75, 25, 0)
$Edit1 = GUICtrlCreateEdit("", 216, 232, 185, 97)
$Label1 = GUICtrlCreateLabel("Label1", 112, 312, 80, 17)
$Label2 = GUICtrlCreateLabel("Label2", 112, 352, 36, 17)
$Button3 = GUICtrlCreateButton("Pause", 248, 360, 75, 25, 0)
$Button4 = GUICtrlCreateButton("Resume", 328, 360, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$iCount = 0

_AdlibEnable("_1",1)
_AdlibEnable("_2",1)
_AdlibEnable("_3",1)
_AdlibEnable("_4",400)
_AdlibEnable("_5",500)
_AdlibEnable("_6",6000)
_AdlibEnable("_7",700)
_AdlibEnable("_8",1)
_AdlibEnable("_9",1000)
_AdlibEnable("_0",2000)

_AdlibActive()


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
_AdlibPause(0)
Case $Button4
_AdlibResume(0)
EndSwitch
WEnd


Func _1()
_GUICtrlListBox_AddString($List1, @SEC &"="& Random(0, 9) )
EndFunc

Func _2()
_GUICtrlListBox_AddString($List2, @SEC &"="& Random(9, 0) )
EndFunc

Func _3()
GUICtrlSetData($Progress1, Random(0, 100, 1))
EndFunc

Func _4()
GUICtrlSetData($Slider1, Random(0, 100, 1))
EndFunc

Func _5()
ControlMove("", "", $Button1, Random(0, 18), Random(300, 350))
EndFunc

Func _6()
ControlMove("", "", $Button2, Random(0, 24), Random(336, 352))
EndFunc

Func _7()
_GUICtrlEdit_AppendText($Edit1, "Hellow World, welcome to my world" &@CRLF)
EndFunc

Func _8()
$iCount += 1
GUICtrlSetData($Label1, "count: " & $iCount)
EndFunc

Func _9()
ToolTip("Hello", Random(@DesktopHeight, @DesktopWidth, 1))
EndFunc

Func _0()
ConsoleWrite("The cow barks like a fish" &@lf)
EndFunc

And I get this error:

_Adlib.au3 (137) : ==> Variable used without being declared.:

If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0

Any ideas how to fix it?

Link to comment
Share on other sites

  • 1 month later...

Hello, I'm using this example:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <GuiComboBox.au3>
#Include <GuiListBox.au3>
#Include <GuiEdit.au3>

#Include "_Adlib.au3"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 427, 407, 193, 125)
$List1 = GUICtrlCreateList("", 8, 8, 201, 214)
$List2 = GUICtrlCreateList("", 216, 8, 193, 214)
$Progress1 = GUICtrlCreateProgress(8, 232, 150, 17)
$Slider1 = GUICtrlCreateSlider(8, 256, 150, 45)
$Button1 = GUICtrlCreateButton("Button1", 8, 312, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 8, 352, 75, 25, 0)
$Edit1 = GUICtrlCreateEdit("", 216, 232, 185, 97)
$Label1 = GUICtrlCreateLabel("Label1", 112, 312, 80, 17)
$Label2 = GUICtrlCreateLabel("Label2", 112, 352, 36, 17)
$Button3 = GUICtrlCreateButton("Pause", 248, 360, 75, 25, 0)
$Button4 = GUICtrlCreateButton("Resume", 328, 360, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$iCount = 0

_AdlibEnable("_1",1)
_AdlibEnable("_2",1)
_AdlibEnable("_3",1)
_AdlibEnable("_4",400)
_AdlibEnable("_5",500)
_AdlibEnable("_6",6000)
_AdlibEnable("_7",700)
_AdlibEnable("_8",1)
_AdlibEnable("_9",1000)
_AdlibEnable("_0",2000)

_AdlibActive()


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
_AdlibPause(0)
Case $Button4
_AdlibResume(0)
EndSwitch
WEnd


Func _1()
_GUICtrlListBox_AddString($List1, @SEC &"="& Random(0, 9) )
EndFunc

Func _2()
_GUICtrlListBox_AddString($List2, @SEC &"="& Random(9, 0) )
EndFunc

Func _3()
GUICtrlSetData($Progress1, Random(0, 100, 1))
EndFunc

Func _4()
GUICtrlSetData($Slider1, Random(0, 100, 1))
EndFunc

Func _5()
ControlMove("", "", $Button1, Random(0, 18), Random(300, 350))
EndFunc

Func _6()
ControlMove("", "", $Button2, Random(0, 24), Random(336, 352))
EndFunc

Func _7()
_GUICtrlEdit_AppendText($Edit1, "Hellow World, welcome to my world" &@CRLF)
EndFunc

Func _8()
$iCount += 1
GUICtrlSetData($Label1, "count: " & $iCount)
EndFunc

Func _9()
ToolTip("Hello", Random(@DesktopHeight, @DesktopWidth, 1))
EndFunc

Func _0()
ConsoleWrite("The cow barks like a fish" &@lf)
EndFunc

And I get this error:

_Adlib.au3 (137) : ==> Variable used without being declared.:

If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0

Any ideas how to fix it?

Why are you using this UDF when there's now a native function in autoit that does the same? AdlibRegister() and AdlibUnRegister().

Try those.

Link to comment
Share on other sites

Why are you using this UDF when there's now a native function in autoit that does the same? AdlibRegister() and AdlibUnRegister().

Try those.

This one has additional features, like pausing & resuming adlibs, status info about adlibs, etc. I find it

very handy coz I have a number such adlibs running

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...