Jump to content

multi threading


 Share

Recommended Posts

hello, im experimenting with AuThread udf, i dont understand how get the message ONLY  from a specific thread, im using as is shown in the example

@AutoItPID

this is my code, do you know what im doing wrong?

#include 'authread.au3'
Global $Paused = True
Local $iPIDA,$iPIDB
HotKeySet("{p}", "TogglePause")

_AuThread_Startup()

$hThread = _AuThread_StartThread("myThreadFunction")
$hThreadb = _AuThread_StartThread("myThreadFunction2")

While True

    While $Paused
        Sleep(100)
        $msgA = _AuThread_GetMessage($iPIDB) ;this is the problem
        If $msgA Then
            ToolTip($msgA,0,0)
            Sleep(100)
        EndIf

    WEnd

WEnd

Func myThreadFunction()

    While True

        Global $iPIDA = @AutoItPID
        $threading = PixelGetColor(37, 215,0) ;desktop icon
        If ($threading = 0x6E7B9D) Then
            ToolTip($iPIDA,0,50)
            _AuThread_SendMessage(_AuThread_MainThread(),'no')
        Else
            ToolTip($iPIDA,0,50)
            _AuThread_SendMessage(_AuThread_MainThread(),'yes')
        EndIf

    WEnd

EndFunc

Func myThreadFunction2()

    While True

        Global $iPIDB = @AutoItPID
        $threadingb = PixelGetColor(28, 317,0) ;other desktop icon
        If ($threadingb = 0x7E718D) Then
            ToolTip($iPIDB,0,100)
            _AuThread_SendMessage(_AuThread_MainThread(),'no-no')
        Else
            ToolTip($iPIDB,0,100)
            _AuThread_SendMessage(_AuThread_MainThread(),'yes-yes')
        EndIf

    WEnd

EndFunc

Func TogglePause()
    $Paused = NOT $Paused
;~     While $Paused
;~         sleep(100)
;~         ToolTip('Script is "Paused"',0,0)
;~     WEnd
;~     ToolTip("")
EndFunc

 

Link to comment
Share on other sites

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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