Link to Actions / or only on Find Window

Got a good idea? You can suggest new features here.
User avatar
Neytrino-OnLine
Experienced User
Posts: 97
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Link to Actions / or only on Find Window

Post by Neytrino-OnLine » Wed Sep 06, 2017 6:41 am

Example: I use EG for control (for example) of a software player. I use Find Window and Emulate Keystroke... From time to time - applications gets updates, and sometimes Find Window meeds corrections (so I should change Find Window for each Event)...
If it was possible: to create one Find Window and to add the links to it in all other macroes (that correction of one - corrected all)...
Sin©erely yours, Neytrino.

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: Link to Actions / or only on Find Window

Post by Luca Brasi » Wed Sep 06, 2017 7:32 am

Never tried it myself but have tried to use jump actions for that?
Like...
screen_mmnote_2017-09-06 09 19 17.png
screen_mmnote_2017-09-06 09 19 17.png (8.62 KiB) Viewed 2233 times

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Folder Name="Test Vlc" XML_Guid="{AD57CEE2-3A8F-4FEE-9871-A015C7B00D91}" Expanded="True">
        <Macro Name="Send Keystrokes: {Space}" XML_Guid="{617B1DFD-A362-4290-AFBB-7FCF369709DC}" Expanded="True">
            <Event Name="Main.vlc.pause" XML_Guid="{64AA0BEC-FCC5-45ED-BBD7-14291156F82C}" />
            <Action XML_Guid="{411FB576-B64A-4E20-96AB-1244450B0917}">
                EventGhost.NewJumpIf(XmlIdLink(1215), 2, True)
            </Action>
            <Action XML_Guid="{EC50D27D-BBE8-47C8-9DD7-AE1AB980225F}">
                Window.SendKeys(u'{Space}', False, 2)
            </Action>
        </Macro>
        <Macro Name="Find Window: vlc.exe" id="1215" XML_Guid="{8585722A-2CC2-4B71-BFAB-6E7D0D36ED72}" Expanded="True">
            <Action XML_Guid="{9D0784AB-A576-4942-9C55-1A89D0D8586E}">
                Window.FindWindow(u'vlc.exe', None, None, None, None, None, False, 0.0, 0)
            </Action>
            <Action XML_Guid="{F84CFEBB-AEC5-45E8-8C15-0ACA381DD129}">
                Window.BringToFront()
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Or you could do a script as well.
screen_mmnote_2017-09-06 09 27 09.png
screen_mmnote_2017-09-06 09 27 09.png (3.99 KiB) Viewed 2233 times
the script:

Code: Select all

eg.plugins.Window.FindWindow(u'vlc.exe', None, None, None, None, None, False, 0.0, 0)
eg.plugins.Window.BringToFront()
if 'pause' in eg.event.string:
    eg.plugins.Window.SendKeys(u'{Space}', False, 2)
elif 'fullscreen' in eg.event.string:
    eg.plugins.Window.SendKeys(u'f', False, 2)
For the script you will just have to right click the altered 'find window' action and copy it as python and paste it into the first line of the script.
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

User avatar
Neytrino-OnLine
Experienced User
Posts: 97
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: Link to Actions / or only on Find Window

Post by Neytrino-OnLine » Wed Sep 06, 2017 1:28 pm

Luca Brasi,
Image
Let's look how it works:
After "Main.vlc.pause" Event, We jump to Find Window.
If We have found it - it's Ok, We Bring it to front and then return to the parent macro, We Send key (Space)...
And if We did not found it - We don't bring it to front, but then We still return to the parent macro and Emulate (Space) send it to some window, and it will do what it should not...
Sin©erely yours, Neytrino.

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: Link to Actions / or only on Find Window

Post by Luca Brasi » Wed Sep 06, 2017 7:56 pm

Yes, from your question it seemed like you'd have it always running. But having the fail save in there is always better of course.
I'd use the script in that case but if you prefer having the actions in the tree try it like this:
screen_mmnote_2017-09-06 21 53 27.png
screen_mmnote_2017-09-06 21 53 27.png (11.63 KiB) Viewed 2218 times
You'll have to maintain two find window actions then. Better then one for each command though...
And the first one should look like this:
screen_mmnote_2017-09-06 21 47 17.png
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

User avatar
Neytrino-OnLine
Experienced User
Posts: 97
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: Link to Actions / or only on Find Window

Post by Neytrino-OnLine » Fri Sep 08, 2017 11:55 am

Luca Brasi, thanks for the idea (it will work), I didn't think of this way...
But I hope that my original sugestion(if it could be done) - will be more powerful and useful...
Sin©erely yours, Neytrino.

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: Link to Actions / or only on Find Window

Post by Luca Brasi » Fri Sep 08, 2017 1:28 pm

One of the reasons why Eventghost is so useful is that there are countless ways to fulfill your needs. So if you're looking for the perfect solution I'd like to encourage you to be creative and hunt for it!

One other way would be to bring in just a little bit of python:
screen_mmnote_2017-09-08 15 30 47.png
screen_mmnote_2017-09-08 15 30 47.png (12.13 KiB) Viewed 2202 times

Copy this and paste it into your tree:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Folder Name="3rd solution" XML_Guid="{1A37E6A5-1C44-4849-9458-72E789272EC7}" Expanded="True">
        <Macro Name="Find window" XML_Guid="{617B1DFD-A362-4290-AFBB-7FCF369709DC}" Expanded="True">
            <Event Name="Main.vlc.*" XML_Guid="{64AA0BEC-FCC5-45ED-BBD7-14291156F82C}" />
            <Event Name="Task.Deactivated.firefox" XML_Guid="{D4943D9F-E327-4BB9-ADDE-49D05585D586}" />
            <Action XML_Guid="{9D0784AB-A576-4942-9C55-1A89D0D8586E}">
                Window.FindWindow(u'vlc.exe', None, None, None, None, None, False, 0.0, 0)
            </Action>
            <Action XML_Guid="{FFE52FFE-054B-4E5E-BAAA-572633FD32FA}">
                Window.BringToFront()
            </Action>
            <Action XML_Guid="{808FD0D4-974B-41E8-AD32-3229F9AA644C}">
                EventGhost.TriggerEvent(u"{(eg.event.string).split('.')[2]}", 0.0)
            </Action>
        </Macro>
        <Macro Name="Pause" XML_Guid="{617B1DFD-A362-4290-AFBB-7FCF369709DC}" Expanded="True">
            <Event Name="Main.pause" XML_Guid="{1327E2C9-BCC5-4931-82AE-6A474C3932DC}" />
            <Action XML_Guid="{EC50D27D-BBE8-47C8-9DD7-AE1AB980225F}">
                Window.SendKeys(u'{Space}', False, 2)
            </Action>
        </Macro>
        <Macro Name="Pause" XML_Guid="{617B1DFD-A362-4290-AFBB-7FCF369709DC}" Expanded="True">
            <Event Name="Main.fullscreen" XML_Guid="{1327E2C9-BCC5-4931-82AE-6A474C3932DC}" />
            <Action XML_Guid="{EC50D27D-BBE8-47C8-9DD7-AE1AB980225F}">
                Window.SendKeys(u'f', False, 2)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
You will need to change the events and stuff to your needs. And it might be done even easier but I'd need to know how your events triggering the actions look like.
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

User avatar
Neytrino-OnLine
Experienced User
Posts: 97
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: Link to Actions / or only on Find Window

Post by Neytrino-OnLine » Mon Sep 11, 2017 6:37 am

Luca Brasi, it is very interesting idea too, as I understand: I should place all events in a macro "Find Window", and then (if the window is found) - the TriggerEvent ({(eg.event.string).split('.')[2]}) will generate a new event (using a name of the received event)... I will think of it, but I don't like couple of things:
1st - is too much generation of events (so, when I push the button on the remote - MCE-plugin create an event, Then as reaction to this event - I create an events (to use short and long pressing and to divide events on local and global), And then, when the local management of the application receives the event - it creates one more event, And only then - it does something (perhaps creating more events))...
2nd - In some macroes (for management of the application) - I use jumps from one macro to another and if just to cut out Find Window and use it before command execution, it will break some sequences (which expect on Find Window in right place and time)...

And if We return to the first post, As I understand EG has the system of addressing (which allows to refer to an item, to Jump for example) "XmlIdLink(*)", So maybe it is possible to get contents of this element (as a script), and to insert it in the right place as action.?
If it is possible, I also think that it would be usefull - to use small database to connect community of links (all links targeted to a specific item), and an Items...
Imagine that I have created the link to a Find Window, and then I used 99 copies of it. For some reasons, I have removed Find Window, So how many time I will spend to correct all 100 links to the new target? And if it is only one signing up in DB connecting ID references and XmlIdLink (*) of a target, it will be rather simple to open property one of the links and change the target...
Sin©erely yours, Neytrino.

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: Link to Actions / or only on Find Window

Post by Luca Brasi » Tue Sep 12, 2017 5:50 am

Neytrino-OnLine wrote:Luca Brasi, it is very interesting idea too, as I understand: I should place all events in a macro "Find Window", and then (if the window is found) - the TriggerEvent ({(eg.event.string).split('.')[2]}) will generate a new event (using a name of the received event)...
Yes.
Neytrino-OnLine wrote: 1st - is too much generation of events (so, when I push the button on the remote - MCE-plugin create an event, Then as reaction to this event - I create an events (to use short and long pressing and to divide events on local and global), And then, when the local management of the application receives the event - it creates one more event, And only then - it does something (perhaps creating more events))...
No, in the scenario you described earlier there's gonna be only one more event per button press. If that's too much - I wouldn't care - just go with the script from my second post. Or skip the trigger action and have another script check the results of "find window" and discard the further execution of the event.
Neytrino-OnLine wrote: 2nd - In some macroes (for management of the application) - I use jumps from one macro to another and if just to cut out Find Window and use it before command execution, it will break some sequences (which expect on Find Window in right place and time)...
Sorry, you lost me there. But if I get you right I don't see the problem. You will still be able to do your jumps to the player actions. If you want to jump to the find window an event will be triggered which does nothing.
Neytrino-OnLine wrote: And if We return to the first post, As I understand EG has the system of addressing (which allows to refer to an item, to Jump for example) "XmlIdLink(*)", So maybe it is possible to get contents of this element (as a script), and to insert it in the right place as action.?
If it is possible, I also think that it would be usefull - to use small database to connect community of links (all links targeted to a specific item), and an Items...
Imagine that I have created the link to a Find Window, and then I used 99 copies of it. For some reasons, I have removed Find Window, So how many time I will spend to correct all 100 links to the new target? And if it is only one signing up in DB connecting ID references and XmlIdLink (*) of a target, it will be rather simple to open property one of the links and change the target...
I'm again not sure if I get you right entirely. But if so I guess you're trying to break the logic of eg and the jumps here.
But... If you're willing to script what you would need here was the possibility to call a global function as a replacement for you jumped to action. I was wondering about that quite some times recently as well. One of the devs should give an answer to that. That's above my pay grade.
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Link to Actions / or only on Find Window

Post by kgschlosser » Tue Sep 12, 2017 4:22 pm

what I need to know is what specifically is getting updated that would cause the find window to not work.
If you like the work I have been doing then feel free to Image

User avatar
Neytrino-OnLine
Experienced User
Posts: 97
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: Link to Actions / or only on Find Window

Post by Neytrino-OnLine » Wed Sep 13, 2017 3:54 am

Luca Brasi, I dob't see breaks of eg logic in my suggestion, I only want to make some routine simpler for management...
There is one EG feature called Enable Exclusive, you could do same to spend a lot of time using multiole Disable an item and one Enable, But Enable Exclusive - quicker and more simply... So, what is bad, to replace a multiple identical copies of Find Window (for example) - to one Find Window and multiple links to it? (To make settings management more simply and quicker)

This topic is not about: how to make it some other way, it about: maybe this feature should be added... If it is possible - maybe someone will make it...
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Link to Actions / or only on Find Window

Post by kgschlosser » Wed Sep 13, 2017 4:10 am

there is the check box in the Find Window action that will stop the macro if the window is not found.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Link to Actions / or only on Find Window

Post by kgschlosser » Wed Sep 13, 2017 4:11 am

and also why are you not using the VLC plugin?? why all the sending of keystrokes to a window?
If you like the work I have been doing then feel free to Image

User avatar
Neytrino-OnLine
Experienced User
Posts: 97
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: Link to Actions / or only on Find Window

Post by Neytrino-OnLine » Wed Sep 13, 2017 4:30 am

kgschlosser wrote:there is the check box in the Find Window action that will stop the macro if the window is not found.
I know, but I don't see relation with this topic...
kgschlosser wrote:and also why are you not using the VLC plugin?? why all the sending of keystrokes to a window?
Because I don't use VLC, I use MediaPortal, PowerDVD, PotPlayer and several other applications, plugins for this purpose are absent or work is incomplete...
Sin©erely yours, Neytrino.

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Link to Actions / or only on Find Window

Post by kgschlosser » Wed Sep 13, 2017 4:31 am

and also Find Window never misses a window if all of the proper search parameters are properly added. for example if the window name is something that changes all the time then this is something you would not use to match the window. and also using the program name only is not a good thing either because if the program has more then one window open they will not be found in the same order all the time. and you can run into issues with any actions that run after the find window. it is a good idea to isolate the specific control you wish to send the keystrokes to. this will narrow down the results.


as an example. instead of sending the keystrokes to play the movie. why not use find window to target the play button and send the Enter keystroke to the button. this way it can't make a mistake.

when dealing with Find Window the actual term Window does not mean the program GUI. it means anything that is in the Window class. which can be a button, menu, text entry control, just about everything you see in the GUI is a child of the Window class. Find window works much better as well as any of the actions that use it's results if you target a specific thing not the container it's self.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Link to Actions / or only on Find Window

Post by kgschlosser » Wed Sep 13, 2017 4:33 am

ok well there was a screen shot that had vlc.exe in it so i thought that was what was being used. But the mediaportal plugin works. I use it myself. I have not done any looking into the others. But in my previous post it gives more detail into how to properly use Find Window
If you like the work I have been doing then feel free to Image

Post Reply