# Using screenshot in vb Invoke Code

**URL:** <https://forum.uipath.com/t/using-screenshot-in-vb-invoke-code/481629>\
**Category:** Studio\
**Tags:** invoke-code, vbnet, screenshot, system, uiautomation, activities\
**Created:** [October 17, 2022, 6:10am UTC](https://forum.uipath.com/t/using-screenshot-in-vb-invoke-code/481629 "2022-10-17T06:10:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kuki\_Force](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kuki_force/32/344302_2.png) [@Kuki\_Force](https://forum.uipath.com/u/Kuki_Force)\
**Post date:** [October 17, 2022, 6:10am UTC](https://forum.uipath.com/t/using-screenshot-in-vb-invoke-code/481629/1 "2022-10-17T06:10:16Z")

</div>

Hi all,

i need to use take screenshot via v.b invoke code. How can i use it? or write?

- Cannot use activity, write a code (obligation) ☹

Thank you.

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 17, 2022, 6:18am UTC](https://forum.uipath.com/t/using-screenshot-in-vb-invoke-code/481629/2 "2022-10-17T06:18:36Z")

</div>

HI,

How about the following?

```
 img = UiPath.Core.Image.CreateFromScreen(New Rectangle(0,0,1024,768),Nothing,Nothing,Nothing)

```

 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/a/a/5aa8c3715d190f02c4e82b93ad9ecf003d8d40db.png)

[Sequence.xaml](https://forum.uipath.com/uploads/short-url/oCvnuURfflEL2meDtY250G0WLKx.xaml) (5.6 KB)

Regards,

---

<div class="post-metadata">

**Author:** ![Kuki\_Force](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kuki_force/32/344302_2.png) [@Kuki\_Force](https://forum.uipath.com/u/Kuki_Force)\
**Post date:** [October 17, 2022, 7:04am UTC](https://forum.uipath.com/t/using-screenshot-in-vb-invoke-code/481629/3 "2022-10-17T07:04:17Z")

</div>

Hi,

Thanks for response. The code is worked well.

I need to write a note here about this code.

Sometimes usage of rectangle can be conflicting a library that’s why program can give the error.

NOT : if you get this error code : _ **"rectangle is ambiguous imported from the namespaces or types ‘System.Drawing, Microsoft.Office.Interop.Excel’ "** _

You can write this =\> img = UiPath.Core.Image.CreateFromScreen(New System.Drawing.Rectangle(0,0,1024,768),Nothing,Nothing,Nothing)

**or short answer =\> Instead of using rectangle, use this _System.Drawing.Rectangle_**

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 20, 2022, 7:04am UTC](https://forum.uipath.com/t/using-screenshot-in-vb-invoke-code/481629/4 "2022-10-20T07:04:28Z")

</div>

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