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.

Bring Window to Front (results in nothing, or memory error)

If you have a question or need help, this is the place to be.
Post Reply
variable
Posts: 2
Joined: Tue Jan 24, 2017 2:51 pm

Bring Window to Front (results in nothing, or memory error)

Post by variable »

EventGhot: 0.4.1.r1722
Python 2.6.5 final 0
Windows 10 x64 pro

See file attached for the sequence of commands, but I am trying to bring a window to the front when it is minimized to the tray. In this case mediamonkey. I have tried targeting different aspects of "Mediamonkey.exe" (different classes) but depending on the class targeted, either nothing happens (no window is opened) or a window is opened that is unresponsive and quickly results in a memory exception. I *think* this is a problem of me targeting the proper window component of mediamonkey, but I do not know. I am seeking advice from anyone that has done this before?

Thank you for any help at all!
-Eric
eventghost_mediamonkey.PNG
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Bring Window to Front (results in nothing, or memory err

Post by kgschlosser »

I would have to install media monkey and run an inspection on it's GUI to find the actual frame because that should be the one to hit...

BUT if media monkey is made like EG is and when it is minimized to a tray icon destroys it's GUI then there would be no frame to force to be displayed.. and everything you are trying to target is actually from the tray icon it's self...

and if that is the case then in the tray icons menu there should be a menu option to "show mediamonkey" and we should be able to target that menu optionsend an enter key press to it which would make mediamonkey show...


let me poke about it a bit and run my inspection tool on the bugger to see what kind of objects it's making and what we would be able to target in order to for it to be displayed.

This could very well end up being a python script instead of a simple action.. just wanted to let ya know that.
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Bring Window to Front (results in nothing, or memory err

Post by kgschlosser »

ok so here is a question...

is mediamonkey minimized to tray? or is it closed to tray?


because it's working fine for me if it's minimized to tray. all you have to do is in the application field enter

mediamonkey.exe

and that's all there is to it...

now if it's closed to tray that is a different animal because it does in fact destroy the frame. so we will have to come up with a way to interact with the tray icon. which does not have a menu option to show media monkey you have to double click the tray icon. which makes it a little more complex.

but what you can do as an alternative is if it doesn't find the window you can have it launch the application. which would cause medial monkey to open it the state it should be... but this has it;s own set of goofs. if you only wanted this to take place if media monkey was running previously then you would have to set up a way to monitor status of media monkey. using something like the process plugin. which would notify you if mediamonkey was running or not... again i do not know if a task kill takes place when the frame gets closed and the icon is shown...

I will have to play around with it
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Bring Window to Front (results in nothing, or memory err

Post by kgschlosser »

i was just looking at the image of your setup.. you are performing a find window. and then another find window for the same thing.. if it can't find it the first time then it won't be able to locate it the second. there for the bring to front is going to run and cause a problem.


so what you would want to do is this...


2 macros

1st macro "Minimize Media Monkey"
event - Keyboard Alt + A
action - Find Window MediaMonkey.exe
action - If Unsuccessful Jump To Start Media Monkey
action - Bring To Front
action - Minimize To Tray

2nd macro "Start Media Monkey"
action - Run Application MediaMonkey.exe
action - If Successful Jump To Minimize Media Monkey

on the jumps DO NOT have the return checked. this is due to the jump back because the find window has not located the window yet and still needs to in order for it to properly minimize it. so we add a jump back to the Minimize so it can run find window again and locate it then minimize it.


You had all the right bits.. just in the wrong order... hopefully by doing the above it will work properly

and also Ignore the last post. because this will deal with the minimize to tray on close option in Media Monkey.. so no worries there as well.
If you like the work I have been doing then feel free to Image
variable
Posts: 2
Joined: Tue Jan 24, 2017 2:51 pm

Re: Bring Window to Front (results in nothing, or memory err

Post by variable »

Thanks for the help!

I wasn't able to get that to work, it seems it is a loop?

Also, the reason I had the double lookup was because the first was a normal, and the second was a lookup with invisible windows included. So the first wouldn't find it if it was 'closed to taskbar'
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Bring Window to Front (results in nothing, or memory err

Post by kgschlosser »

this has some quirks. and it requires you to have to press the key combo 2 times if you manually minimized the window. but it is what it is

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-beta2">
    <Folder Name="MediaMonkey" Expanded="True">
        <Macro Name="MediaMonkey - Check If Visible" id="51" Expanded="True">
            <Event Name="Keyboard.Ctrl+A" />
            <Action>
                Window.FindWindow(u'MediaMonkey.exe', u'MediaMonkey', u'TFMainWindow', None, None, None, True, 0.5, 2)
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(65), 1, False)
            </Action>
            <Action>
                Window.Minimize()
            </Action>
            <Action>
                Window.MinimizeToTray()
            </Action>
            <Action>
                EventGhost.DisableItem(XmlIdLink(51))
            </Action>
            <Action>
                EventGhost.EnableItem(XmlIdLink(1658))
            </Action>
        </Macro>
        <Macro Name="MediaMonkey - Start" id="65" Expanded="True">
            <Action>
                System.Execute(u'C:\\Program Files (x86)\\MediaMonkey\\MediaMonkey.exe', u'', 0, True, 2, u'', False, False, u'', False, False, False, False)
            </Action>
            <Action>
                EventGhost.DisableItem(XmlIdLink(1658))
            </Action>
            <Action>
                EventGhost.EnableItem(XmlIdLink(51))
            </Action>
        </Macro>
        <Macro Name="MediaMonkey - Restore" id="1658" Enabled="False" Expanded="True">
            <Event Name="Keyboard.Ctrl+A" />
            <Action>
                Window.FindWindow(u'MediaMonkey.exe', u'MediaMonkey', u'TFMainWindow', None, None, None, True, 0.5, 2)
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(65), 1, False)
            </Action>
            <Action>
                Window.Restore()
            </Action>
            <Action>
                EventGhost.EnableItem(XmlIdLink(51))
            </Action>
            <Action>
                EventGhost.DisableItem(XmlIdLink(1658))
            </Action>
        </Macro>
    </Folder>
</EventGhost>

just copy and paste that that code right into your tree if you have a problem let me know
If you like the work I have been doing then feel free to Image
Post Reply