New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nw.js window.on() not registered if app started as hidden #5013
Comments
Hi, any updates on this bug? |
What do you mean by 'try the start menu shortcut'? |
Just create a exe which brings the running nw to focus. using System; namespace Sample
} |
@anjanapaulose I haven't tested your C# app. But I think |
@anjanapaulose Does my suggestions work for you? |
Sorry for the delay, tried as per your suggestion. Didn't work. |
Could you upload the entire project of your C# testing app so that I can test with? |
I was unable to upload the whole project as zip, it was failing. Please see the attached txt file, rename it to Program.cs. I used a Visual Studio project with output as exe. Please go though the comments added to know which case is working for what scenarios. |
This should be the limitation of Windows API. See http://stackoverflow.com/questions/16185217/c-sharp-process-mainwindowhandle-always-returns-intptr-zero.
|
Thanks, I am not so familiar with windows processes, just a doubt "The value is also zero for processes that have been hidden, that is, processes that are not visible in the taskbar. " So if the process is in task bar, it should come up, right?. So in this case, it will always come once its clicked. Whats the difference if tray icon is once clicked and not. |
@anjanapaulose I'm confused. Here is following you addressed previously.
I assume it means the window is hidden on start since "the app has never come into view" and the title of this issue is "... if app started as hidden". In this case, there will not be a taskbar icon, and you will not get the window's handle or title. |
Ohh, yes, that is one case. If the app itself is started as hidden, it will never come into view. I have also seen the below scenario. |
@anjanapaulose If it's hidden and only shown in tray, you will not get the window handle and get it shown. That's the limit of Windows API. If it's minimized as icon in the task bar, then your shortcut will work. |
Ok, thanks for the clarification. |
I am using nw 0.14.5 version.
I have to start the nw app in tray mode. I have defined the "on" function for "focus" as
var win= nw.Window.get();
win.on("focus", function(){
win.show();
});
and for tray click,
tray.on('click', function() {
win.show();
win.focus();
});
Now when I click on tray, the app comes into view as normal. I also have a shortcut to this app in start menu.
The issue is as follows:
The app is started as tray. I clicked atleast once on tray and app has came into view atleast once. Minimize will reduce the app to tray.
After this, if i try the startmenu shortcut, app comes into view as expected.
But if the app is started as tray, and I have never clicked tray, which means the app has never come into view.
In this case, if I try the start menu shortcut, the win.on("focus") code is never getting triggered, failing the app to show up.
If the app is already displayed atleast once, this issue is not seen. The window object itself is not defined unless the app is shown once.
Is there any condition like the win.on("focus") or such events are registered only when app is shown.
Please suggest a solution to this.
The text was updated successfully, but these errors were encountered: