Jump to content

How can I run 2 other functions in same time


kuebk
 Share

Recommended Posts

So I'm making some kind of bot, and when I'm starting it, it is doing something in first window, but when I press 2nd button in my GUI I want it to do something in second window while it is still doing what it was in first window.

Anyone could help me?

Link to comment
Share on other sites

  • Moderators

/AutoIt3ExecuteScript

And/Or

AdlibEnable()

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm looking for something other, I want 2 functions to be ran at same time.

Technically running two functions at the same time in the same script is not possible in au3 at the moment because autoit3 is not multi threaded.

You could try one of Smoke_N's suggestions or you could try this. Changing the boolean values of $RunOne and $RunTwo would toggle the execution of their respective code blocks. Just make sure there are no infinite loops in any of the blocks or it will get stuck.

Global $RunOne=True,$RunTwo=True
Runner()

Func Runner()
    While 1
        If $RunOne then
            ;do function one's stuff here
        EndIf
        
        If $RunTwo Then
            ;do function two's stuff here
        EndIf
    WEnd
EndFunc
Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • Moderators

I'm looking for something other, I want 2 functions to be ran at same time.

Then you don't have the concept of either suggestion I gave or the understanding of how AutoIt works.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@SolidSnake

I think that's going to do $RunOne first before $RunTwo, because $RunOne is listed first and it'll just go through $RunOne 's commands and then check for $RunTwo 's

EDIT: forget that, you edited your post

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Technically running two functions at the same time in the same script is not possible in au3 at the moment because autoit3 is not multi threaded.

You could try one of Smoke_N's suggestions or you could try this. Changing the boolean values of $RunOne and $RunTwo would toggle the execution of their respective code blocks. Just make sure there are no infinite loops in any of the blocks or it will get stuck.

Global $RunOne=True,$RunTwo=True
Runner()

Func Runner()
    While 1
        If $RunOne then
            ;do function one's stuff here
        EndIf
        
        If $RunTwo Then
            ;do function two's stuff here
        EndIf
    WEnd
EndFunc
The problem is that this 2 functions are doing what I want in infinitive loops. Any other possible solution?
Link to comment
Share on other sites

Did you not listen? AutoIt is NOT multi-threaded, which makes that merely impossible. The only way is to have 2 scripts, which you could call one from the other when a certain button is pressed.

Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Link to comment
Share on other sites

Perhaps another way is to have one script a delayed effect and start the other one regularly, so the outcome is both of them running at the same time.

All things considered, it might just be easy trying a language that has multi-thread capabilities.

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
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...