AndersMalmgren / FreePIE

Programmable Input Emulator
645 stars 144 forks source link

Minimize to tray #98

Closed tyler211 closed 7 years ago

tyler211 commented 7 years ago

Please add the ability to minimize to tray FreePIE

MarijnS95 commented 7 years ago

And what, besides not seeing the application on the task bar or in the application switcher (alt/windows+tab), would be the advantage of having this functionality? I'd like to know before spending time to implement it, as I've never needed this functionality myself.

tyler211 commented 7 years ago

FreePIE works on my computer almost always, but this app does not require constant intervention, but it is located on the taskbar. It is not convenient when you switch between apps require intervention. It would be good to FreePIE minimized to tray by close button in the upper right corner, and closed via the menu of the right mouse button in the tray. Thank you.

AndersMalmgren commented 7 years ago

Hi MarijnS95, if you look into it please make sure it's a MVVM solution that works with Caliburn Micro etc

MarijnS95 commented 7 years ago

Hence why I was wondering about the importance, because I've never worked with Caliburn Micro. It would take some time investment to figure out how FreePIEs core works (up till now I've only been working on plugins). I'll see what I can do, but it'll not be until after next week that I can actually take a go at it.

tyler211 commented 7 years ago

Thanks guys!

drowhunter commented 7 years ago

Hey, i noticed this thread, and i realized that i had done a tray icon using caliburn micro using Hardcodet.NotifiyIcon.Wpf nuget package in a completely MVVM way

i have coded it and created a pull request for your review

added new function diagnostics.notify(string title, string message, format args) so you can pop up notifications in the taskbar via python script!

added command line option /t or /tray to start minimized example usage freepie.exe /tray "myscript.py" /run will autorun the script in the tray

diagnostics.notify example usage: if starting: diagnostics.notify("Starting Script ...")

will show a notification in your task bar

AndersMalmgren commented 7 years ago

Good work! It's such a big change so it will take me some time to verify this, sorry. Will this change the behavior of the application? Like will it default to start minimized? We do not want to change default behavior for existing users. Maybe add a checkbox "Minimize to tray"?

tyler211 commented 7 years ago

"Maybe add a checkbox "Minimize to tray"" - it would be good I think!

drowhunter commented 7 years ago

I does not affect the default behaviour of Freepie, if no /tray commandline is passed it will open up as usual.

I was thinking that when passing [/t or /tray] and a scriptname that [/r or /run] is implied

so the command line if you want to autorun a script should just be

freepie.exe /tray "myscript.py"

no /run should be required

adding a setting to run in tray would only be useful if a script was set to run so im not sure that's useful

the tray menu is customizable so i could make it so that right clicking the icon could bring up a menu of scripts to change on the fly, maybe it points to a folder where you keep scripts on you computer

that could be a setting

also what would be the point of /tray if no script is passed.. perhaps it should pop up a dialog if /tray is passed without a file name

AndersMalmgren commented 7 years ago

Sorry I have been so busy with work latly, I just tested the code change. If I just minimize the window but not to tray double click on tray does nothing, if I minimize to tray it does show when double clicking, maybe make it show even if not minimized so we get a bit more unified behavior there.

Maybe minimize to tray on Close window should be opt in, and the opt in option is presented in the Tray menu. It can be added to the settings model and persisted that way

AndersMalmgren commented 7 years ago

Also when trying to build installer I get,

Views\Main\TrayIconViewModel.cs(54,35): error CS1002: ; expected [C:\git\FreePIE\FreePIE.GUI\jvnbzu4g.tmp_proj] Views\Main\TrayIconViewModel.cs(54,63): error CS1519: Invalid token ')' in class, struct, or interface member declarati on [C:\git\FreePIE\FreePIE.GUI\jvnbzu4g.tmp_proj]

AndersMalmgren commented 7 years ago

Ah, msbuild needs to be updated to support C# 6

TaskbarTrayIcon?.ShowBalloonTip(message.Title, message.message, BalloonIcon.Info);

If someone can take alook at that I would really appreciate it

AndersMalmgren commented 7 years ago

I tried updating build_installer.bat with but it did not help

set PATH=%PATH%;%PROGRAMFILES(x86)%\MSBuild\14.0\Bin

MarijnS95 commented 7 years ago

I assume you want to prepend the C#6 compiler path, otherwise it'll keep using the older compiler that's listed earlier in the PATH variable.

drowhunter commented 7 years ago

No problem I didn't even think of that double click should open the window regardless.. I'll update it.

not sure about the compiler thing ill try and find where its breaking.. i could also just write the code the old way instead of c#6.

On Jan 17, 2017 7:04 AM, "Anders Malmgren" notifications@github.com wrote:

Sorry I have been so busy with work latly, I just tested the code change. If I just minimize the window but not to tray double click on tray does nothing, if I minimize to tray it does show when double clicking, maybe make it show even if not minimized so we get a bit more unified behavior there.

Maybe minimize to tray on Close window should be opt in, and the opt in option is presented in the Tray menu. It can be added to the settings model and persisted that way

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AndersMalmgren/FreePIE/issues/98#issuecomment-273121514, or mute the thread https://github.com/notifications/unsubscribe-auth/ACr90E9bJFdraRevRczmMDBfFKmmxxLNks5rTK5EgaJpZM4Lblwp .

drowhunter commented 7 years ago

I just realized that the last version i pushed was riddled with bugs. I will be pushing a new version shortly

drowhunter commented 7 years ago

sorry for the delay, was swamped with work. I have pushed a new version of the trayicon. changes .

i had to change the way it worked before because it turns out that destroying and recreating the window had a bad bug with the editor, multiple instances seemed to be created causing the caret position to constantly reset to 0. .. this new solution is faster and has less impact on the way freepie worked originally anyway.

Only issue im having is the tray icon context menu only seems to update the first time you open it, after tha the guards for runscript and stop script no longer refresh despite having called the notification property change

i think it has something to do with the fact that the context menu isnt really a ui element its actually a resource, maybe someone can help figure that one out

i havent looked atthe installer will try that later...

P.S i also removed all of the c#6 code,.. but would be greate if one day we could upgrade.. some nice language features there.

drowhunter commented 7 years ago

by the way heres a sample script to show the new functionality

if starting:
    diagnostics.notify("Starting","starting script")
if stopping:
    diagnostics.notify("Stopping","stopping script")
drowhunter commented 7 years ago

anyone have a chance to look at this yet?

AndersMalmgren commented 7 years ago

Sorry been super busy lately, I'm on parental leave so can only work with the game in the evenings, so not much time besides Virtual Warfighter latly

drowhunter commented 7 years ago

hah no worries I'm a new parent myself I know what you mean. sorry I posted the update to the a new issue #99 by accident .. (you can erase that )

I made some changes to how the tray icon behaves the close button will now close as expected at all times. and a new setting is added to the icon to opt in to it.

"minimize to tray" is the new behavior... the way I had it working before was causing issues with the texteditor. This is also faster since the window doesn't get destroyed each time.

I also added options to the tray to start and stop the script...I'm sure the layout may need some feed back so I look forward to you guys

I still haven't had a chance to look at the installer

I also removed the c#6 for now no need to stir the pot :)

zelmon64 commented 7 years ago

@drowhunter I've been looking through this and think it'll be quite nice to include in the next release. I managed to get the context menu to update appropriately. I've also added a "Hide Window" option and more mouse click actions.

What I'm currently stuck on is the "Exist FreePIE" option because it does not handle script.IsDirty correctly. The message box appears but then it immediately disappears and FreePIE closes. Would you happen to know anything about this?

I also tried to add an "Open File" option but this similarly closed the popup immediately after it appears.

My changes are on this branch; https://github.com/zelmon64/FreePIE/tree/drowhunter-TrayIcon.

drowhunter commented 7 years ago

i can take a look at it and let you know if i find anything

On Oct 17, 2017 6:45 AM, "William" notifications@github.com wrote:

@drowhunter https://github.com/drowhunter I've been looking through this and think it'll be quite nice to include in the next release. I managed to get the context menu to update appropriately. I've also added a "Hide Window" option and more mouse click actions.

What I'm currently stuck on is the "Exist FreePIE" option because it does not handle script.IsDirty correctly. The message box appears but then it immediately disappears and FreePIE closes. Would you happen to know anything about this?

I also tried to add an "Open File" option but this similarly closed the popup immediately after it appears.

My changes are on this branch; https://github.com/zelmon64/ FreePIE/tree/drowhunter-TrayIcon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AndersMalmgren/FreePIE/issues/98#issuecomment-337192551, or mute the thread https://github.com/notifications/unsubscribe-auth/ACr90GSaHr4pqv2Ucq8rvY_asreBaVIPks5stIVUgaJpZM4Lblwp .

AndersMalmgren commented 7 years ago

@zelmon64 I took a super quick look so i can be wrong. You use CloseApp correct? Its a hard command, will close appdomain right off the bat doing Application.Current.Shutdown();

You want to use Close instead which let the main window do its thing. But Close tries to determin which window to close, I dont know if it will work from the Tray viwmodel

namespace FreePIE.GUI.Result
{
    public class CloseResult : Result
    {
        public override void Execute(CoroutineExecutionContext context)
        {
            var window = Window.GetWindow(context.View as DependencyObject);
            window.Close();

            base.Execute(context);
        }
    }
}
AndersMalmgren commented 7 years ago

Interesting CloseApp does trigger MainShellViewModel.CanClose but it does not let its Coroutine finnish (its becasue coroutines is async and not blocking)

zelmon64 commented 7 years ago

I tried using Process.CloseMainWindow to close FreePIE but couldn't get it to work. I decided to remove the close option for now so that it can be merged since the rest works quite nicely.