How to clear clipboard data for every iteration

Hi All,

I have created a workflow, where it dynamically copy & paste data using clipboard activity.

But the issue am facing is, am not able to clear the clipboard data to capture data for next iteration.

I have passed null value from setToClipboard & System.Windows.Clipboard.Clear() method also. I need help to fix the issue.

Thanks
Baruna K Panda

Hey!

Try like this

Assign strVariable = Nothing

Where strVariable is your clipboard data variable

Regards,
NaNi

Hi,

I have tried though, it is throwing error on GetClipBoard activity where am capturing the values from clipboard to a variable.

Error:

{
“message”: “<?xml version=\"1.0\" encoding=\"utf-16\"?><ClipboardData Version="1.0" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation\” xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities\" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml\“><ClipboardData.Data><scg:List x:TypeArguments="x:Object" Capacity="1"><p:Assign x:Name="__ReferenceID0" VirtualizedContainerService.HintSize="414,62"><p:Assign.To><p:OutArgument x:TypeArguments="x:String">[clipboard]</p:OutArgument></p:Assign.To><p:Assign.Value><p:InArgument x:TypeArguments="x:String">[Nothing]</p:InArgument></p:Assign.Value></p:Assign></scg:List></ClipboardData.Data><ClipboardData.Metadata><scg:List x:TypeArguments="x:Object" Capacity="4"><scg:List x:TypeArguments="x:Object" Capacity="1"><x:Reference>__ReferenceID0</x:Reference></scg:List></scg:List></ClipboardData.Metadata>”,
“level”: “Information”,
“logType”: “User”,
“timeStamp”: “09:31:54”,
“processVersion”: “1.0.0.0”,
“jobId”: “7aced0dc-df03-4dc5-b1f3-03a1da2ea253”,
“robotName”: “DevBot009”,
“machineId”: 2,
“fileName”: “test2”
}

Hello @Panda_Baruna_K
Try this, it may helps you.
image

Hi Gokul,

I have done that also, it is throwing error.

What is the error?

You can also use Invoke Method activity to clear the clipboard.

TargetType = System.Windows.Forms.Clipboard
TargetObject = (leave this blank)
MethodName = Clear

Hi

Error is

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.AggregateException: One or more errors occurred. ----> System.Exception: Empty clipboard
at UiPath.Core.Setup.GetClipboardText()
at UiPath.Core.Activities.ClipboardWrapper.<>c.b__4_0()
at UiPath.Core.Retry.Do[ResultType](Func`1 action, Int32 timeoutMS, Int32 retryCount)
— End of inner ExceptionDetail stack trace —
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

That error occurs because the clipboard is empty when you are trying to use the Get Clipboard activity

You don’t need to clear it. The next time you do a copy to clipboard it overwrites whatever was there.

Hi I had to clear the clipboard end of activity. Because for next iteration, it holding the previous copy data.

The error that you copy + pasted here says you tried to get data from the clipboard, but the clipboard is empty.

Hi,

As I previously mentioned, it holds the previously copied data, so need to flush the clipboard. To capture new data.

Thanks,
Baruna K Panda

I copy the data, by default it stores the data in clipboard. So I capture that data by getclipboard activity into a variable. for other operation in the workflow. And after all activity I flush it. So I could ensure clipboard is empty for next capture, otherwise it is holding previous data.

Thanks

I understand what you’re trying to do. Please do a quick debugging of your workflow or paste it here if it is allowable and simple enough for us to understand.

The error you copy + pasted when replying to me a few minutes ago states that your clipboard is completely empty. So when you use the ‘Get from clipboard’ activity, it will throw the system.AggregateException

test2.xaml (12.1 KB)

please fid the code here, I need your help, to fix the issue.

Thanks,
Baruna K Panda

No, you don’t. When you press CTRL+C on your keyboard, do you worry about clearing out what’s already in the clipboard?

Hi @postwick , I have figured out the issue & it’s been resolved. Thanks for your support.

Regards,
Baruna K Panda

Please share how you fixed it, so that it can help others in the future.

1 Like

Hi @postwick

I attached the window, & worked on hotkey, where the hotkey was functioning unpredictably.

Solution: 1

    Added screenshots for both hotkeys, and made sure selector is universal for all files with is going to operate.

Solution: 2

  For the 1st hotkey(Ctrl + A), where click before typing is selected.

Solution: 3

  Made sure after all operations, the variable holds clipboard data, it is flushed.

Thanks
Baruna K Panda

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