falls process existiert cmdline weitergeben

  • hi, ich habe folgendes Problem: fals eine instanz meines programms schon offen ist will ich die comandline der 2. instanz an die erste weiterleiten

    bsp.:

    Spoiler anzeigen

    Inst1 hat cmdline "Hallo"und "servus" und gibt bei buttondruck die comandlineeinträge aus
    inst2 wird mit "Hi" aufgerufen
    nun soll inst 1 immer "hallo" "servus" und "hi" wiedergeben.

    Wie kann ich das machen?

    Einmal editiert, zuletzt von JuraX (3. Juni 2010 um 19:52)

    • Offizieller Beitrag

    Ich hatte das bei meinem Starplayer mit einem Edit-Control gelöst:

    Spoiler anzeigen
    [autoit]


    Global $sTitle = 'Starplayer v2.7.3'
    Global $iSelfPID = _WinAPI_GetCurrentProcessID()
    Global $aProcessList = ProcessList('Starplayer.exe')
    If $aProcessList[0][0] > 1 Then
    If $iSelfPID <> $aProcessList[1][1] Then WinWait($sTitle)
    EndIf
    If WinExists($sTitle) Then ; If Starplayer exists, then send Commandline to 1st instance.
    If $CmdLine[0] > 0 Then
    For $i = 1 To $CmdLine[0]
    If FileExists($CmdLine[$i]) Then
    Switch StringRight($CmdLine[$i], 4)
    Case '.mp3', '.m3u'
    ControlCommand($sTitle, '', '[CLASS:Edit; INSTANCE:3]', 'EditPaste', $CmdLine[$i] & @CRLF)
    EndSwitch
    EndIf
    Next
    EndIf
    Exit ; Only one instance. Exit the 2nd.
    EndIf

    [/autoit]