Hi guys, i’m trying to set a screenshot to the clipboard so that i can do ctrl+v and paste the image in a word document later on. However, in the Invoke Method activity, it keeps on having an issue when i do “SetImage” to the clipboard.
I have referred to this thread but i still don’t understand what it means. This is also the workflow that i am trying to work on: Clipboard.xaml (8.8 KB)
Just to clarify, the problem i am having is with my company work machine, so i cannot take screenshot from it. However, the workflow is the same as the one i provided above. I am just unclear as to why it is not working.
but the image i am trying to load into the clipboard is of variable type “image” though. Since what i am trying to do is take a screenshot and after that, save/load it into the clipboard so that i can Ctrl+V later on. The take screenshot activity only supports image variables as it outputs to my understanding
Then you need to convert it to BitmapSource first. My recommendation is to use Invoke Code instead of Invoke Method using the following code:
Dim bi As System.Windows.Media.Imaging.BitmapImage = New System.Windows.Media.Imaging.BitmapImage
bi.BeginInit()
bi.StreamSource = New System.IO.MemoryStream(in_Screenshot.ByteArray)
bi.EndInit()
System.Windows.Clipboard.SetImage(bi)
You are welcome! Good to hear that it’s working. With Invoke Method you can only call one method (per activity). With Invoke Code you can call how many methods you want and write other code. Invoke Method can access your workflow variables directly while Invoke Code only can access them via arguments.