-
Notifications
You must be signed in to change notification settings - Fork 53
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
Move focus to main window of process if it's already running (using ProcessAddin) #60
base: develop
Are you sure you want to change the base?
Move focus to main window of process if it's already running (using ProcessAddin) #60
Conversation
{ | ||
var results = Process.GetProcesses() | ||
.Where(process => process.MainWindowTitle.IndexOf(query.Raw, StringComparison.OrdinalIgnoreCase) >= 0) | ||
.Select(process => (IQueryResult) new ProcessResult(process.Id, process.MainWindowTitle, process.ProcessName, LevenshteinScorer.Score(process.MainWindowTitle, query.Raw, false), LevenshteinScorer.Score(process.MainWindowTitle, query.Raw))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should break line in the middle
.Select(process => (IQueryResult) new ProcessResult(process.Id, process.MainWindowTitle, process.ProcessName, LevenshteinScorer.Score(process.MainWindowTitle, query.Raw, false), LevenshteinScorer.Score(process.MainWindowTitle, query.Raw))) | ||
.ToList(); | ||
|
||
return results.AsEnumerable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can simplify by removing results variable
|
||
var rect = new Win32.W32Rect(); | ||
Win32.Window.GetWindowRect(process.MainWindowHandle, ref rect); | ||
if (rect.Top < 0 && rect.Right < 0 && rect.Bottom < 0 && rect.Left < 0) // Window is minimized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be replaced with https://msdn.microsoft.com/en-us/library/windows/desktop/ms633527(v=vs.85).aspx
return Task.FromResult(null as ImageSource); | ||
} | ||
|
||
public override Task<IEnumerable<IQueryResult>> QueryAsync(Query query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the speed using C# Process class, when I was testing it got pretty slow
|
After having difficulty getting #49 to work i propose this alternative solution. Using an addin to query the currently running processes and provide them as query results.
This still needs some work regarding UWP processes, as it currently includes the background processes of UWP apps.
This closes #38, #49