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

Move focus to main window of process if it's already running (using ProcessAddin) #60

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

jonstodle
Copy link

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

{
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)))

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();

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Task.FromResult(null as ImageSource);
}

public override Task<IEnumerable<IQueryResult>> QueryAsync(Query query)

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

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

Focus application if open, instead of launching new instance
3 participants