Sign in to follow this  
Followers 0
kuebk

How can I run 2 other functions in same time

10 posts in this topic

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?


Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

/AutoIt3ExecuteScript

And/Or

AdlibEnable()

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

/AutoIt3ExecuteScript

And/Or

AdlibEnable()

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

Edited by kuebk

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@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

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

The way to get what you want, OP, is to have 2 compiled scripts that are called via run()'s, or non-compiled scripts via smoke's suggestion; in a 3rd script.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0