Jump to content

Run Two Functions At Once Instead Of One At A Time


Arez
 Share

Recommended Posts

While 1

MouseClick("left", 0, 186, 2, 2.5)

WEnd

Makes the mouse stay at the left side of the screen indefinitely

Send("Test Message Here")

Types in text

Is there any way to make the first happen while the second does instead of one at a time?

Link to comment
Share on other sites

  • Moderators

While 1

MouseClick("left", 0, 186, 2, 2.5)

WEnd

Makes the mouse stay at the left side of the screen indefinitely

Send("Test Message Here")

Types in text

Is there any way to make the first happen while the second does instead of one at a time?

2 different scripts it can be done at the same time. AutoIt doesn't support MultiThreading... you might want to take a peak at AdlibEnable() in the helpfile... that may help you a bit.

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

While 1

MouseClick("left", 0, 186, 2, 2.5)

WEnd

Makes the mouse stay at the left side of the screen indefinitely

Send("Test Message Here")

Types in text

Is there any way to make the first happen while the second does instead of one at a time?

See if this will do it for you

$Count = 0
While 1
$Count += 1
MouseClick("left", 0, 186, 2, 2.5)
If $Count = 1 Then
Send("Test Message Here")
Else
$Count = 2
EndIf
WEnd

Thsi should only send the Send("Test Message Here") the first time the loop runs, but will do it all from the same code block even if not at exactly the same time.

Link to comment
Share on other sites

See if this will do it for you

$Count = 0
While 1
$Count += 1
MouseClick("left", 0, 186, 2, 2.5)
If $Count = 1 Then
Send("Test Message Here")
Else
$Count = 2
EndIf
WEnd

Thsi should only send the Send("Test Message Here") the first time the loop runs, but will do it all from the same code block even if not at exactly the same time.

Since that's only doing it the first time the loop runs, why even have it in the loop? Why not just have it outside the loop and save the extra time dealing with variables.

Send ("test message")
While 1
    MouseClick ("left", 0, 186, 2, 2.5)
    Sleep (100)
WEnd

Added a tiny bit of sleep because that's a lot of clicking....

Link to comment
Share on other sites

Since that's only doing it the first time the loop runs, why even have it in the loop? Why not just have it outside the loop and save the extra time dealing with variables.

Good question. I'm guessing Arez seems to want to do it all in one call, although I have no idea why that would be necessary???? I'm also gyessing for some reason he doesn't want to send the test message until after the mouse pointer is frozen, which is why I put it in the loop and not first.

Link to comment
Share on other sites

If the idea is to keep the mouse at the left of the screen would using _MouseTrap not be better than continual clicking. :)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

If the idea is to keep the mouse at the left of the screen would using _MouseTrap not be better than continual clicking. :)

I agree, but hey, he didn't ask ablut that only running th etwo at the same time and I figured he must have something going on at the left of his screen that makes him want to do that.

Link to comment
Share on other sites

Is there any way to make the first happen while the second does instead of one at a time?

Not directly but its pretty easy to have one script call itself passing command line arguments. Your end up with 2 or more copies running and doing different things but everything is still contained in just one script.

Here is the first few lines from one of mine.

Select
    Case $CmdLine[0] = 0; no args then call with args
        $gamepid = Run(@AutoItExe & ' "' & @ScriptFullPath & '" games')
        $apppid = Run(@AutoItExe & ' "' & @ScriptFullPath & '" apps')
    Case $CmdLine[1] = 'games'; games arg so run games part
        findgames()
        Exit
    Case $CmdLine[1] = 'apps'; app arg so run apps part
        findapps()
        Exit
EndSelect

basically it calls itself with arguments. If when called, it has arguments, it then calls the proper function for that argument.

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