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

[Enhancement] Search everywhere if no matches #16

Open
flexxxxer opened this issue Jan 8, 2024 · 6 comments
Open

[Enhancement] Search everywhere if no matches #16

flexxxxer opened this issue Jan 8, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@flexxxxer
Copy link

Summary

At the moment, if auto-type has occurred, but there are no records in the database, then searching (filtering) from the Advanced Auto Type menu does not result in anything. I suggest adding a "Search everywhere" option, which will work if you enter a string starting with "!!!" in the TextBox for filtering, e.g. "!!github".

Example: auto-type was executed in a browser window on the GitHub tab, but the entry "github" was not found among the records matched. In this case, a search in the TextBox to filter "!!github" will find all records containing github in the record name or username field of the record.

I can do it myself and put it in the form of a pull request. If there are hints and ideas how to implement it in detail, I will be grateful.

Added value

In case of using KeePass Password Safe 2 on Linux under Wayland, search is the only option, because under Wayland there is currently no way to get the window header, but you don't want to search and copy manually from keepass search at main window, this change will be an option and soften the transition to Linux for many users. For Windows users, the benefit is that they don't have to waste time leaving the Auto Type window and searching the database, they will be able to search directly from the Auto Type window.

Example

TODO.

@flexxxxer flexxxxer added the enhancement New feature or request label Jan 8, 2024
@Rookiestyle
Copy link
Owner

I suggest you try the AutoTypeSearch plugin, at leeast this would be my preference compared to adding something similar to my plugin.

Of course feel free to add a pull request and I'll review it.
My filtering is implemented in method OnFilterSearchResults in file AdvancedAutoType.cs.
It will filter the list of relevant entries which itself is created by KeePass, it does not actually check wheter an enry / an entry's auto-type sequence needs to be shown

If you want to implement "search everywhere" like you described, you should

  • check all entries's username and title field
  • in all groups that are enabled for search
  • in all open databases
  • for the search text

Up to you: If an entry is found, which auto-type sequences should be shown? The default one for the found entry? All existing?

For all found entries, you need to read all fields that correspond to the columns shown in the Auto-Type window and rebuild the list that KeePass shows for potential grouping..
Rebuilding is implemented in method AdjustGroups

m_host.MainWindow.DocumentManager.GetOpenDatabases returns a list of open databases.
every database has a root group which should be the starting point to do a search;

SearchParameters sp = new SearchParameters();
sp.SearchInTitles = true;
sp.SearchInUserNames = true;
sp.ExcludeExpired = true;
sp.RespectEntrySearchingDisabled = true;
sp.searchstring = "whatever string entered by the user";
<db>.RootGroup.SearchEntries(sp, List of PwEntry objects matching the search params)

m_host is an attribute in my plugin, the rest is provided by KeePass, see also https://keepass.info/help/v2_dev/plg_index.html

@flexxxxer
Copy link
Author

@Rookiestyle thanks for the feedback. I have already checked out the source code of your plugin and would like to thank you for pointing out where code changes are needed.

I know about AutoTypeSearch plugin, and I am using it, but in the case of future use of Linux + Wayland I will not be able to use both extensions for convenient autocomplete, and choosing between adding functionality to AutoTypeSearch and adding functionality to AdvancedAutoType I chose the second one.

Up to you: If an entry is found, which auto-type sequences should be shown? The default one for the found entry? All existing?

I'm not really sure what you're talking about. I already have two GitHub accounts and both in your plugin are mapped separately from each other using whatever AutoTypeSequence they have been assigned. I think the answer is "The default one for the for each found entry", but I am open to discuss this part of the implementation.

@flexxxxer
Copy link
Author

I've come to think that searching via "!!" would be awkward and implicit for most users. My suggestion is to refine the added UI/UX so that there are no misunderstandings, and it is clearer to users, specifically:

  • add an option (checkbox) in the settings saying, "Search Everywhere on filtering."
  • if auto type happened AND 0 entries were found AND the option was enabled (checkbox in settings was checked) THEN display a block of text "to search everywhere just type in text field behind".
  • if auto type happened AND >0 entries were found AND the option was enabled (checkbox in settings was checked) THEN display a button with the text "turn on search everywhere".
  • in other cases, the additional button "turn on search everywhere" AND the text block "to search everywhere just type in text field behind" are hidden.

After clicking on the button with the text "turn on search everywhere" will change the search logic, spreading the search to all bases open bases in KeePass, the button itself will be hidden after clicking.

Is my idea clear? My first language is not English, and I am ready for clarification or revision of the implementation.

@Rookiestyle
Copy link
Owner

I will not be able to use both extensions for convenient autocomplete

Why not, just asking out of curiosity?

Up to you: If an entry is found, which auto-type sequences should be shown? The default one for the found entry? All existing?

I'm not really sure what you're talking about.

When you edit an entry you'll see a tab named Auto-Type. Here you can add additional sequences that will be shown as well if the criteria is met.

In you're use case, the entry is not found at all.
If you search everywhere and find the entry by e.g. username, would you show all sequences per entry or only the default one?

Is my idea clear

Yes and I'll happily accept a pull request that implements that.

@Rookiestyle
Copy link
Owner

I had a look at AutoTypeSearch and I like it's implementation, especially the threading approach because searching all databases will take time. If references need to be resolved, this becomes even more important.

From what I understand the following is possible already today

Scenario 1
Value of "Always show global auto type entry selection dialog": off
The search box will appear automatically if you perform an auto-type and there is no match.
The Entry Selection window appears if there are multiple matches.
If there is no match at all or if there is exactly 1 match, the entry selection window is not shown
If you cancel that selection window, it is assumed that none of the matches was correct, and so the search box is shown.

Scenario 2
Value of "Always show global auto type entry selection dialog": on
The Entry Selection window appears always (0 matches, exactly 1 match, multiple matches). If you cancel that selection box, it is assumed that none of the matches was correct, and so the search box is shown.

Scenario 3
If you want to just show the search box regardless of whether there's a match for the current window or not then do not use the Auto Type hotkey, but instead go to Options, AutoTypeSearch and define a hotkey in the "Show when system-wide hot key is pressed". Then use that one when you want to just show the search box.

Wouldn't this be sufficient?

image

@flexxxxer
Copy link
Author

Wouldn't this be sufficient?

User experience is important to me, and I've been using AdvancedAutoType together with AutoTypeSearch for a long time, and have been experiencing problems in the form of "inconsistent user experience":

  • AutoTypeSearch does not group duplicate named entries, showing only Username as a difference property
  • different UI (windows) for search, different hotkeys
  • it is impossible to close the AutoTypeSearch window except by Esc or Alt+F4.

Responding to a previous message from you:

When you edit an entry, you'll see a tab named Auto-Type. Here you can add additional sequences that will be shown as well if the criteria are met.

I have never used this option either (no kidding :D)
You could add an option "Display a record multiple times if there is more than 1 auto-type sequence for that record". What do you think?

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

No branches or pull requests

2 participants