Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Prüfen ob Programm schon läuft (if - else Anweisung)

Allgemeines zum Thema EventGhost
Post Reply
mlrtimbf
Posts: 3
Joined: Mon Jun 22, 2009 10:40 pm

Prüfen ob Programm schon läuft (if - else Anweisung)

Post by mlrtimbf »

Hi,

kann ich irgendwie prüfen ob ein bestimmtes Programm schon läuft oder nicht und dann entsprechend 2 unterschiedliche Aktionen durchführen?
Quasi eine If - Else Anweisung...
Prinz
Plugin Developer
Posts: 194
Joined: Mon Apr 07, 2008 4:58 am

Re: Prüfen ob Programm schon läuft (if - else Anweisung)

Post by Prinz »

mlrtimbf wrote:Hi,

kann ich irgendwie prüfen ob ein bestimmtes Programm schon läuft oder nicht und dann entsprechend 2 unterschiedliche Aktionen durchführen?
Quasi eine If - Else Anweisung...
Hier gibt es mehrere M├Âglichkeiten.
  1. Du kannst mittels der "Finde Fenster" nach dem Fenster des Programms suchen.
  2. Oder direkt mittels eines Python-Scripts untersuchen, ob ein bestimmter Prozess läuft. Hierzu ein Beispiel:

    Code: Select all

    <?xml version="1.0" encoding="UTF-8" ?>
    <EventGhost Version="1030">
        <Action>
            EventGhost.PythonScript(u'from win32com.client import GetObject\nWMI = GetObject(\'winmgmts:\')\nprogram = \'notepad.exe\'\nif len( WMI.ExecQuery(\'select * from Win32_Process where Name="\' + program + \'"\') ) > 0 :\n    res = True\nelse :\n    res = False\nprint res\neg.result = res')
        </Action>
    </EventGhost>
Mittels eines nachfolgenden Sprungbefehls kannst Du dann abhängig vom Ergebnis verzweigen.

Den obigen Code kannst Du kopieren und in das Konfigurationsfenster direkt einf├╝gen. "program" soll den String des ├╝berwachenden Programm enthalten, im Beispiel 'notepad.exe'.

Gruß
Prinz
Mein HTPC:
Mainboard: Gigabyte GA-G33M-DS2R
CPU: Intel E5200
OS: WinXP SP3
Graphic card: NVIDIA GeForce 210 512MB
TV-Cards: 2 * Digital Everywhere FloppyDTV-C, Terratec Cinergy 1200 DVB-C
HTPC software: DVB Viewer / EventGhost
Post Reply