Test accessing the Copy and Paste function

Best practices, code snippets for common functionality, examples, and guidelines.
Lightning
Posts: 4
Joined: Mon Jan 14, 2013 2:31 pm

Test accessing the Copy and Paste function

Post by Lightning » Wed Jan 16, 2013 4:25 pm

Hey,

The AUT I am using has some cool hotkey functionality where I can press the keyboard shortcut to copy and the build number of the AUT I am working on will be placed in the clipboard so that I can then easily paste the build number when executing test cases.

I would like to incorporate this in to a test, so that I can copy this build number in to ranorex as a variable and append this variable to file names generated by my test scripts - in order to keep them unique, the copy function should be as simple as :

Keyboard.Press("{LControlKey down}{Ckey down}");

Can someone suggest the best means for getting the contents from the 'paste' functionality, I would prefer not to have to paste this information to a notepad then getting the text from there but that is the current solution I am considering.

Cheers.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Test accessing the Copy and Paste function

Post by Ciege » Wed Jan 16, 2013 4:45 pm

Once you have the version copied on the "clipboard" you can use this to assign it to a variable...

Code: Select all

string strMyVariable = System.Windows.Forms.Clipboard.GetText();
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Lightning
Posts: 4
Joined: Mon Jan 14, 2013 2:31 pm

Re: Test accessing the Copy and Paste function

Post by Lightning » Wed Jan 16, 2013 4:48 pm

Thanks very much.