How can I perform hotkeys operations in uiPath in a C# code?

I am working in coded sequence workflow where i have to copy the data displayed on a grid and then paste it to an excel spreadsheet. For this I need to perform CTRL+c to copy and CTRL+v to paste.

var orderIds = uiAutomation.Attach(Descriptors.MyTool.MyWindow);
orderIds.TypeInto(“myWindowsElement”, “my hotkey operation” );

I know TypeInto wont work this way to send hotkeys. Is there any other method to perform the same?

I see there is a KeyboardShortcut(“myWindowsElement” ,KeyboardShortcutOptions ) method present.

But how to use KeyboardShortcutOptions?

Hey @Priyesh_Tuli
you can try use:

also you can try:

using WindowsInput;
using WindowsInput.Native;

var inputSimulator = new InputSimulator();

inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);

inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);

seems like this method is not there in the UiPath studio. I tried including
using WindowsInput;

but its not able to resolve

This is something generic solution in C#, thanks for it.
Are there any methods available in UiPath that I could play around with?
I know to send a simple text is myScreen.TypeInto(“myelement”, “mytext”) is used. But how can I send CTRL+c or CTRL+v on an object.

I tried exploring myScreen.KeyboardShortcut(“myelement”, KeyboardShortcutOptions);
But unable to figure out further how to utilise this.

I found a solution. One can use TypeInto to pass windows shortcuts.

// this perform Control Key Down + a + Control Key Up
myScreen.TypeInto(“myElement”,“[d(ctrl)]a[u(ctrl)]” );

similarly one can do for Shift keys too:
myScreen.TypeInto(“myElement”,“[d(shift)]a[u(shift)]” );


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.