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.
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.
Stop App / Start another App after event
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Stop App / Start another App after event
Hello Community,
I have opened a topic in the German forum, but nobody could help me.
The following szenario:
When I mount a dvd or a iso-image (Event: "System.DriveMounted.H"), EG should check, if a application like dvbviewer runs this time. And, if so, EG should close dvbviewer and start PowerDVD. After remove of the dvd or the iso-image, EG should close PowerDVD and start dvbviewer. If no app runs, EG should only start PowerDVD.
Is this possible?
Thanks for all advices.
GBWebmaster
I have opened a topic in the German forum, but nobody could help me.
The following szenario:
When I mount a dvd or a iso-image (Event: "System.DriveMounted.H"), EG should check, if a application like dvbviewer runs this time. And, if so, EG should close dvbviewer and start PowerDVD. After remove of the dvd or the iso-image, EG should close PowerDVD and start dvbviewer. If no app runs, EG should only start PowerDVD.
Is this possible?
Thanks for all advices.
GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
Re: Stop App / Start another App after event
Maybe something like this will do the trick? (copy&paste into EG)
Change all the paths of the programs to correspond with your setup. I didn't test if it works or not..
If it doesnt work right out of the box tinker about with the macros, you should be able to see the idea how it can be done.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1397">
<Folder Name="Disk Insert/Remove" Expanded="True">
<Macro Name="Disk inserted">
<Event Name="System.DriveMounted.H" />
<Action>
Window.FindWindow(u'dvbviewer.exe', None, None, None, None, None, False, 0.0, 2)
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(825), 0, True)
</Action>
<Action>
System.Execute(u'C:\\Program Files (x86)\\PowerDVD\\powerdvd.exe', u'', 0, False, 2, u'')
</Action>
</Macro>
<Macro Name="Disk Removed">
<Event Name="System.DriveRemoved.H" />
<Action>
Window.FindWindow(u'powerdvd.exe', None, None, None, None, None, False, 0.0, 2)
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(838), 0, True)
</Action>
<Action>
System.Execute(u'C:\\Program Files (x86)\\DVBViewer\\dvbviewer.exe', u'', 0, False, 2, u'')
</Action>
</Macro>
<Macro Name="DVBViewer: Exit" id="825">
<Action>
Window.FindWindow(u'dvbviewer.exe', None, None, None, None, None, False, 0.0, 0)
</Action>
<Action>
Window.Close()
</Action>
</Macro>
<Macro Name="PowerDVD: Exit" id="838">
<Action>
Window.FindWindow(u'powerdvd.exe', None, None, None, None, None, False, 0.0, 0)
</Action>
<Action>
Window.Close()
</Action>
</Macro>
</Folder>
</EventGhost>- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
Great, it works.
Thank you very much.
GBWebmaster
Thank you very much.
GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
One more question, sorry.
Is there a chance to start the movie playback in PowerDVD automatically. At the present time I must press the "Play-Button" to start the movie in PowerDVD.
GBWebmaster
Is there a chance to start the movie playback in PowerDVD automatically. At the present time I must press the "Play-Button" to start the movie in PowerDVD.
GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Stop App / Start another App after event
Maybe this is the way:Python script:I didn't test if it works or not ...
Pako
Code: Select all
from time import sleep
findPowerDVD = eg.WindowMatcher('PowerDVD{*}.exe', 'CyberLink PowerDVD{*}')
hwnds = []
while not hwnds:
hwnds = findPowerDVD()
sleep(0.1)Pako
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Stop App / Start another App after event
I realized the need to do some insurance in case that PowerDVD will not start:Python script:I didn't test if it works or not ...
Pako
Code: Select all
from time import sleep
findPowerDVD = eg.WindowMatcher('PowerDVD{*}.exe', 'CyberLink PowerDVD{*}')
hwnds = []
i = 0
while not hwnds:
hwnds = findPowerDVD()
sleep(0.1)
i += 1
if i == 200:
break
if i < 200:
eg.SendKeys(hwnds[0], '{Return}')
else:
print "Cyberlink PowerDVD not found"Pako
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
Hello Pako,
after insert the scriptcode, I get the following errors:
Is it a problem, that I work with the PowerDVDCinema10.exe under "C:\Program Files (x86)\CyberLink\PowerDVD10\PowerDVD Cinema\PowerDVDCinema10.exe"?
GBWebmaster
after insert the scriptcode, I get the following errors:
Code: Select all
15:09:25 Error compiling script.
15:09:25 Traceback (most recent call last):
15:09:25 IndentationError: unexpected indent (1, line 1)GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Stop App / Start another App after event
No, check line 1 of your script and you will see that you have a improper indentation of your code.GBWebmaster wrote:Is it a problem, that I work with the PowerDVDCinema10.exe under "C:\Program Files (x86)\CyberLink\PowerDVD10\PowerDVD Cinema\PowerDVDCinema10.exe"?Code: Select all
15:09:25 IndentationError: unexpected indent (1, line 1)
Pako
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
Sorry, my mistake. Copy & Paste was no good idea ... 
Now it works.
I have a favor to ask you. Could you tell me, what the script does?
Now it works.
I have a favor to ask you. Could you tell me, what the script does?
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Stop App / Start another App after event
Of course I can.GBWebmaster wrote:I have a favor to ask you. Could you tell me, what the script does?
The script tries (every 100ms), if it can find a window of PowerDVD.
Once the window is found, the script sends (to the found window) the command Play and ends.
If the window is not found within 20 seconds, the script ends.
Pako
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
Thank you, Pako.
I have a bit of a problem with PowerDVDCinema. With your script, every movie resume playback from the last scene.
What must be changed to play movies always from the beginning? Is this possible?
GBWebmaster
I have a bit of a problem with PowerDVDCinema. With your script, every movie resume playback from the last scene.
What must be changed to play movies always from the beginning? Is this possible?
GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Stop App / Start another App after event
I do not know.
I do not use PowerDVD.
Perhaps this modification could help:
Note: 's' is PowerDVD command Stop.
It may also be that your PowerDVD program uses a different keypresses to control.
Pako
I do not use PowerDVD.
Perhaps this modification could help:
Code: Select all
from time import sleep
findPowerDVD = eg.WindowMatcher('PowerDVD{*}.exe', 'CyberLink PowerDVD{*}')
hwnds = []
i = 0
while not hwnds:
hwnds = findPowerDVD()
sleep(0.1)
i += 1
if i == 200:
break
if i < 200:
eg.SendKeys(hwnds[0], 's')
sleep(0.1)
eg.SendKeys(hwnds[0], '{Return}')
else:
print "Cyberlink PowerDVD not found"It may also be that your PowerDVD program uses a different keypresses to control.
Pako
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
Hello Pako,
the additional scriptcode doesn't change anything.
But when I add the action "CyberLink PowerDVD: Navigation Down" and "CyberLink PowerDVD: Play" after your script, then it works.
Could I add the step "Navigation Down" into the script?
GBWebmaster
the additional scriptcode doesn't change anything.
But when I add the action "CyberLink PowerDVD: Navigation Down" and "CyberLink PowerDVD: Play" after your script, then it works.
Could I add the step "Navigation Down" into the script?
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1534">
<Macro Name="Laden einer ISO-Datei" Expanded="True">
<Event Name="System.DriveMounted.H" />
<Action>
Window.FindWindow(u'dvbviewer.exe', None, None, None, None, None, False, 0.0, 2)
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(1418), 0, True)
</Action>
<Action>
System.Execute(u'C:\\Program Files (x86)\\CyberLink\\PowerDVD10\\PowerDVD Cinema\\PowerDVDCinema10.exe', u'', 0, False, 2, u'')
</Action>
<Action>
EventGhost.PythonScript(u'from time import sleep\nfindPowerDVD = eg.WindowMatcher(\'PowerDVD{*}.exe\', \'CyberLink PowerDVD{*}\')\nhwnds = []\ni = 0\nwhile not hwnds:\n hwnds = findPowerDVD()\n sleep(0.1)\n i += 1\n if i == 200:\n break\nif i < 200:\n eg.SendKeys(hwnds[0], \'{Return}\')\nelse:\n print "Cyberlink PowerDVD not found"')
</Action>
<Action>
PowerDvd.NavigationDown()
</Action>
<Action>
PowerDvd.Play()
</Action>
</Macro>
</EventGhost>F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Stop App / Start another App after event
As I understand it, so now it works as follows:GBWebmaster wrote:Could I add the step "Navigation Down" into the script?
1. The script waits at the window of PowerDVD and then sends a command to Play
2. Then follow action CyberLink PowerDVD: Navigation Down
3. Then follow action CyberLink PowerDVD: Play
If so, then you can modify the Python Script as follows:
Code: Select all
from time import sleep
findPowerDVD = eg.WindowMatcher('PowerDVD{*}.exe', 'CyberLink PowerDVD{*}')
hwnds = []
i = 0
while not hwnds:
hwnds = findPowerDVD()
sleep(0.1)
i += 1
if i == 200:
break
if i < 200:
eg.SendKeys(hwnds[0], '{Return}')
eg.SendKeys(hwnds[0], '{Down}')
eg.SendKeys(hwnds[0], '{Return}')
else:
print "Cyberlink PowerDVD not found"Pako
- GBWebmaster
- Experienced User
- Posts: 115
- Joined: Wed Sep 24, 2008 5:34 am
Re: Stop App / Start another App after event
Hello Pako,
thank you very, very much. Now it works great, really.
thank you very, very much. Now it works great, really.
Yes, it is possible. The first line isn't necessary.Pako wrote:Note: It is possible that you can delete the first command Play (line eg.SendKeys(hwnds[0], '{Return}'))
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
wird sich die Aussicht nicht ändern.