Skip to content

Add auto-type {CLEARFIELD}#427

Merged
droidmonkey merged 11 commits intokeepassxreboot:developfrom
weslly:feature/autotype-clearfield
Apr 9, 2017
Merged

Add auto-type {CLEARFIELD}#427
droidmonkey merged 11 commits intokeepassxreboot:developfrom
weslly:feature/autotype-clearfield

Conversation

@weslly
Copy link
Copy Markdown
Contributor

@weslly weslly commented Mar 23, 2017

closes #426

Description

This PR add support for the auto-type {CLEARFIELD} command.

Progress

  • macOS
  • Linux
  • Windows

Types of changes

  • ✅ New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

@weslly weslly changed the title WIP: Add auto-type {CLEARFIELD} Add auto-type {CLEARFIELD} Mar 25, 2017
@weslly
Copy link
Copy Markdown
Contributor Author

weslly commented Mar 25, 2017

This is ready for review.

@TheZ3ro TheZ3ro added the bug label Mar 26, 2017
@TheZ3ro TheZ3ro added this to the v2.2.0 milestone Mar 26, 2017
@rockihack
Copy link
Copy Markdown
Contributor

Keepass uses Home; Shift+End; Backspace to clear fields.
The character A might depend on the keyboard layout...
I implemented it for windows and mac os:
rockihack/keepassx@1662678
rockihack/keepassx@29bf74f

@weslly
Copy link
Copy Markdown
Contributor Author

weslly commented Mar 27, 2017

@rockihack I'm not sure about windows, but OSX uses ⌘+A as the standard to the "Select all" action in any layout, including non-latin input methods such as japanese or korean. Also, the home and end keys don't work the same way in many apps since they aren't even available in most mac keyboards.

@weslly
Copy link
Copy Markdown
Contributor Author

weslly commented Mar 27, 2017

@rockihack Also, it seems Windows uses the same virtual keycode values for any layout, so it wouldn't make any difference with other layouts, I just tested with AZERTY and it didn't.

But I agree we should probably change it to Home; Shift+End; Backspace on Windows (only) for the sake of compatibility with Keepass 2.x behavior.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Mar 27, 2017

On linux with AZERTY layout I can reproduce @rockihack bug.
Anyway using Home on multi-line input field will place the caret at start of the current line so only the current line will be deleted (instead of all the content with CTRL+A)

@rockihack
Copy link
Copy Markdown
Contributor

rockihack commented Mar 27, 2017

Clears the contents of the edit control that currently has the focus (only single-line edit controls).

http://keepass.info/help/base/autotype.html

To be compatible with keepass you should use Home; Shift+End; Backspace.
Atleast on windows you can use Ctrl+Home; Ctrl+Shift+End; Backspace to clear multiline edits.


m_platform->sendKey(Qt::Key_Control, true, true);
m_platform->sendKey(Qt::Key_A, true, true);
m_platform->sendKey(Qt::Key_Control, false, true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should press and release keys in inverse order.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did in the first commit but it's not how OSX recognizes the key sequence in an unsimulated ⌘+A:

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but look at the event type FlagsChanged.
What does it show for the clear field sequence?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What does it show for the clear field sequence?

image

The example doesn't seem to follow the same sequence of a real keystroke

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually it could be the way I usually type, I release the modifier key before releasing the character key. Not sure if it's how most people do or not...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll change it to be like the example

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Mar 27, 2017

Ctrl+Home; Ctrl+Shift+End; Backspace to clear multiline edits.

I think this is the best alternative

@weslly
Copy link
Copy Markdown
Contributor Author

weslly commented Mar 27, 2017

Unless the goal is 100% compatibility with Keepass 2.x, I think we should support multi-line edits, like <textarea> on HTML forms.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Mar 27, 2017

@weslly @rockihack

Unless the goal is 100% compatibility with Keepass 2.x, I think we should support multi-line edits, like <textarea> on HTML forms.

I agree but also we should support multiple keyboard layout, and Ctrl+Home; Ctrl+Shift+End; Backspace does the job (at least on linux where Ctrl+A doesn't works with an Azerty layout)

@weslly
Copy link
Copy Markdown
Contributor Author

weslly commented Mar 27, 2017

Actually looks like OSX uses ⌘+A but not the same keycodes with Azerty. I'll fix it.
Fixed.

event.keycode = keycode;
SendEvent(&event, KeyPress);
SendEvent(&event, KeyRelease);
if (isKeyDown) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With this change, modifiers will be pressed and released for each key event.
Instead of modifing the code here, you can use SendEvent and SendModifier directly in execClearField.

@TheZ3ro TheZ3ro requested review from droidmonkey and phoerious April 1, 2017 12:17
m_platform->sendKey(Qt::Key_Down, true, Qt::ShiftModifier | Qt::ControlModifier);
m_platform->sendKey(Qt::Key_Down, false, Qt::ShiftModifier | Qt::ControlModifier);
m_platform->sendKey(Qt::Key_Control, false, Qt::ShiftModifier);
m_platform->sendKey(Qt::Key_Shift, false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can someone explain this key sequence to me?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@phoerious

  1. Command Up - Move the cursor to the beginning of the field
  2. Shift Command Down - Select the text between the cursor and the end of the field
  3. Delete - Delete the selection

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok. Looks fine to me then.

@droidmonkey droidmonkey merged commit c0f62e5 into keepassxreboot:develop Apr 9, 2017
@weslly weslly deleted the feature/autotype-clearfield branch April 9, 2017 15:57
droidmonkey added a commit that referenced this pull request Jun 25, 2017
- Added YubiKey 2FA integration for unlocking databases [#127]
- Added TOTP support [#519]
- Added CSV import tool [#146, #490]
- Added KeePassXC CLI tool [#254]
- Added diceware password generator [#373]
- Added support for entry references [#370, #378]
- Added support for Twofish encryption [#167]
- Enabled DEP and ASLR for in-memory protection [#371]
- Enabled single instance mode [#510]
- Enabled portable mode [#645]
- Enabled database lock on screensaver and session lock [#545]
- Redesigned welcome screen with common features and recent databases [#292]
- Multiple updates to search behavior [#168, #213, #374, #471, #603, #654]
- Added auto-type fields {CLEARFIELD}, {SPACE}, {{}, {}} [#267, #427, #480]
- Fixed auto-type errors on Linux [#550]
- Prompt user prior to executing a cmd:// URL [#235]
- Entry attributes can be protected (hidden) [#220]
- Added extended ascii to password generator [#538]
- Added new database icon to toolbar [#289]
- Added context menu entry to empty recycle bin in databases [#520]
- Added "apply" button to entry and group edit windows [#624]
- Added macOS tray icon and enabled minimize on close [#583]
- Fixed issues with unclean shutdowns [#170, #580]
- Changed keyboard shortcut to create new database to CTRL+SHIFT+N [#515]
- Compare window title to entry URLs [#556]
- Implemented inline error messages [#162]
- Ignore group expansion and other minor changes when making database "dirty" [#464]
- Updated license and copyright information on souce files [#632]
- Added contributors list to about dialog [#629]
@phoerious phoerious added pr: bugfix Pull request fixes a bug and removed bug labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: bugfix Pull request fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-Type {CLEARFIELD} not working

5 participants