Jump to content

MailSlot help


Recommended Posts

I am trying to run a semi-multithreaded application that checks to see if a game is running, and then attaches to it with NomadMemory

at startup, the script opens another instance of its self with

$dpid = Run(@ScriptName & " /detect")

which runs

If $CmdLine[0] > 0 Then
    If $CmdLine[1] = "/detect" Then
        While 1
            _MailSlotWrite($sMailSlot, "0")
            ProcessWait("game.exe")
            _MailSlotWrite($sMailSlot, "1")
            ProcessWaitClose("game.exe")
            _MailSlotWrite($sMailSlot, "0")
        WEnd
        Exit
    EndIf
EndIf

Then the While loop on the parent process checks during every loop to see if the game has been run/closed with

While 1
    $RunStatus = _MailSlotRead($sMailSlot, 1)
    If $RunStatus <> $RunStatus2 Then ;<-- Edit: I forgot to mention that $RunStatus2 is declared earlier in a part that I didn't post which is $RunStatus2 = _MailSlotRead($sMailSlot, 1)
        If $RunStatus = 1 Then
            GUICtrlSetData($Label3, "The game is running")
            GUICtrlSetColor(-1, 0x008000)
            $gpid = ProcessExists("game.exe")
            $ah_Handle = _MemoryOpen($gpid)
            $RunStatus2 = $RunStatus
        ElseIf $RunStatus = 0 Then
            GUICtrlSetData($Label3, "The game is not running")
            GUICtrlSetColor(-1, 0xFF0000)
            _MemoryClose($ah_Handle)
            $RunStatus2 = $RunStatus
        EndIf
    EndIf
...
WEnd

But for some reason, it never changes the label on the GUI, does anyone know why? Thanks

Edited by zeffy
Link to comment
Share on other sites

Could you post a (short) code that could actually be run and that would fail the same way this fails?

Without that here's my guess.

The way you put things _MailSlotRead($sMailSlot, 1) reads binary. That means that $RunStatus is never 1 nor 0. It's 0x31 or 0x30.

Solution could be:

_MailSlotRead($sMailSlot, 1, 1)

Then you will have 1 or 0 (ANSI).

♡♡♡

.

eMyvnE

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