Jump to content

2 functions running "parallely"


dudenyc
 Share

Recommended Posts

Hello all, here is an example of my problem:

HotKeySet ("{F3}",  "Send_2")
HotKeySet ("{F4}",  "Click")
HotkeySet ("{END}", "Stop")
;********** Send_1 **********
Func Send_2 ()
    While (1)
        Send ("2")
    WEnd
EndFunc
;********** Click **********
Func Click ()
    While (1)
        MouseClick ("Right")
    WEnd
EndFunc
;********** Stop **********
Func Stop ()
    While (1)
        Sleep (1000)
    Wend
EndFunc
;********** Repeater **********
; Continuous Loop Of Program.
While (1)
    Sleep (1)
WEnd
oÝ÷ ØÚ0#§¶Ú+º{a{gîËb¢{nÞ¥ªÚW¥É»­!©pk+!j÷µ~éܶ*'®éçxµ«báh­ìZ^¦·¬²)à|"[ØÛø¿n·©y«^v§£
kzË"xÂ)e²Ú)¶ºw-í¢Ç§v&öþ/Ûjwh¢¸ ×%É"
Þ¥æ­yÙrwH¶.Zn­rx§Øh±íºw-춶«~ÞÅ©©éb殶­s`£²¢¢¢¢¢¢¢¢¢¢6öÖ&ò¢¢¢¢¢¢¢¢¢ ¤gVæ26öÖ&ò vÆR Ö÷W6T6Æ6²gV÷Cµ&vBgV÷C² 6VæBgV÷C²"gV÷C² tVæ@¤VæDgVæ0

But it's very inconvenient since I have more complicated functions to run "parallely" later on.

Any input on how to run multiple functions paralelly in one scripting program will be greatly appreciated. Thanks a bunch in advance guys ;).

Link to comment
Share on other sites

Take this and run with it. ;)

HotKeySet('{F2}', 'togone')
HotKeySet('{F3}', 'togtwo')
HotKeySet('{escape}', 'quit')

$runone = False
$runtwo = False

While 1
    If $runone = True Then Send('a')  ;stick func 1 here
    If $runtwo = True Then Send('b')  ;stick func 2 here
    Sleep(100)
WEnd

Func togone()
    $runone = NOT $runone
EndFunc

Func togtwo()
    $runtwo = NOT $runtwo
EndFunc

Func quit()
    Exit
EndFunc
Link to comment
Share on other sites

Take this and run with it. ;)

Okay, I tried to make something funny out of running with your sharp code - but it was just too much of a stretch - the running part, not your sharp code :-)

See what that chat forum will do to ya...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Hm if you really want your functions to run parallely (both work at the same time), one possibility would be to split the functions into two programs.

Otherwise you could use multithreading i think (i'm not that familiar with it, but there are some threads, that deal with it).

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

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