Skip to content
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

Focus application if open, instead of launching new instance #38

Closed
jonstodle opened this issue Jan 4, 2018 · 4 comments · May be fixed by #49 or #60
Closed

Focus application if open, instead of launching new instance #38

jonstodle opened this issue Jan 4, 2018 · 4 comments · May be fixed by #49 or #60

Comments

@jonstodle
Copy link

jonstodle commented Jan 4, 2018

If there's already an instance open of an application it would be preferable to have that application receive focus instead of launching a new instance. That way Jarvis could be used to quickly to switch between applications in addition to launching them.

A key combination could force a launch of a new instance. Shift+Enter would be in keeping with the Windows default of launching new instances when shift-clicking an application on the taskbar and when using Win+Shift+ to switch application on the taskbar.

@patriksvensson patriksvensson added this to the v0.7.0 milestone Jan 10, 2018
@jonstodle
Copy link
Author

After googling a bit it looks like there's a few ways to activate a window of an external process:

ShowWindow/SetForegroundWindow

This requires importing user32.dll to use the Win32 API. According to this SO answer it might be necessary to call both functions to ensure the window is activated if it's been minimised.

SwitchToThisWindow

This also requires user32.dll, but seems to activate minimised windows too (according to this SO answer, but as a comment mentions, it's "not intended for general use. It may be altered or unavailable in subsequent versions of Windows" according to the MSDN docs

AppActivate

This function is located in the VisualBasic.dll and I'm not sure that would even work from C#.

@patriksvensson
Copy link
Member

@jonstodle I would prefer the ShowWindow/SetForegroundWindow approach here. The API:s in question is commonly used and already available in Jarvis.Core.Interop.Win32.

You want to take a stab at this?

@jonstodle
Copy link
Author

Sure 🙂

@jonstodle
Copy link
Author

Doing some cleanup in my open issues. I'm closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants