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

clipboard() helper function to copy and paste from clipboard - implemented #559

Closed
kensoh opened this issue Sep 6, 2019 · 5 comments
Closed
Labels

Comments

@kensoh
Copy link
Member

kensoh commented Sep 6, 2019

Raising an issue to implement clipboard() helper function, since this may be something commonly used. In normal user workflows, it would be using keyboard [ctrl]c and keyboard [ctrl]v (or [cmd] for macOS) to copy and paste text from the clipboard.

However, in some situations, getting the value store in clipboard directly to a variable in TagUI for usage, or setting the clipboard directly from a variable in TagUI would be very helpful. For eg, select all and copy to clipboard a PDF document, and then using clipboard() to access the value for data extraction / string-parsing etc.

@kensoh kensoh added the feature label Sep 6, 2019
@kensoh
Copy link
Member Author

kensoh commented Sep 6, 2019

Draft syntax -

  • clipboard('value') to store text value in clipboard
  • result = clipboard() to return text value stored in clipboard

@kensoh
Copy link
Member Author

kensoh commented Sep 6, 2019

This idea was initially considered in #547, however a helper function would be a more intuitive implementation than doing it as a new step which seems clumsy (#547 (comment))

Implementation checkpoints -

  • 1. create a clipboard() helper function with logic below (expand out vision step)
// copy variable to clipboard
vision_step('clipboard = "' + value '"')
vision App.setClipboard(clipboard)

// paste clipboard to variable
vision output_sikuli_text(App.getClipboard())
clipboard = fetch_sikuli_text()
  • 2. ensure that this is detected to trigger SikuliX engine
  • 3. generate and validate new positive test case signature
  • 4. verify to work with \r \n characters, single/double quotes
  • 5. consider including clipboard() in multi-language support
  • 6. enable clipboard() to be invoked in different languages

For 5, yes clipboard() should be enabled in multi-language, for consistency with other helper functions which have support for multi-language. To be implemented later on.

https://github.com/kelaberetiv/TagUI/tree/master/src/languages

@kensoh kensoh changed the title clipboard() helper function to copy and paste from clipboard clipboard() helper function to copy and paste from clipboard - to implement Sep 6, 2019
kensoh added a commit to tebelorg/TagUI that referenced this issue Sep 17, 2019
To get text from clipboard or set text to clipboard. This can be used with keyboard step [ctrl]c [ctrl]v for new use cases possibilities, by programmatically having direct read/write access to clipboard.
kensoh added a commit that referenced this issue Sep 17, 2019
To get text from clipboard or set text to clipboard. This can be used with keyboard step [ctrl]c [ctrl]v for new use cases possibilities, by programmatically having direct read/write access to clipboard.
@kensoh
Copy link
Member Author

kensoh commented Sep 17, 2019

Above commit implements this feature. Documentation to be updated on the next packaged release to avoid confusion. Prior to packaged release, feature available from cutting edge version here -

https://github.com/kelaberetiv/TagUI#set-up

@kensoh
Copy link
Member Author

kensoh commented Sep 17, 2019

Usage in TagUI script -

get clipboard text

echo clipboard()
key_info = clipboard()

put clipboard text

clipboard('123\n456\789');
js clipboard('abc\ndef\ghi')

(without the js step, the ; is required at the end of the JavaScript code, for TagUI to know that this is a JavaScript statement and not throw error on unrecognised statement in script)

@kensoh kensoh changed the title clipboard() helper function to copy and paste from clipboard - to implement clipboard() helper function to copy and paste from clipboard - implemented Sep 17, 2019
@kensoh
Copy link
Member Author

kensoh commented Sep 17, 2019

@ck81 fyi on this new helper function - I think it can open up interesting new use possibilities!

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

No branches or pull requests

1 participant