Is there a way to edit the System.Drawing.Rectangle variable ? For example, I have a variable position1 of type Rectangle. How can I change the value of position1.Left ?
I cannot simply assign position1.Left = 150 which gives Compiler Error.
I tried to assign position1 = position1.Value.Left +80 but it gives the following error:
Compile error(s) encountered processing expression “position1.value.Left + 80”. ‘value’ is not a member of ‘System.Drawing.Rectangle’.
I also tried position1.offset(80,0) but it gives error:
Expression does not produce a value.
Just found a work around. Instead of trying to edit the rectangle, I create and use the new instance with the desire values by: new Rectangle(Left,Top,Width,Depth)
You are right, I missed those arguments. It gives no error now. But it seems do nothing. May I ask if Offset change the values of rectangle.Left and rectangle.Top ? These two values does not change after the Invoke method.
Offset() should change the position of the rectangle. I believe the reason Offset() doesn’t work with Invoke Method is because Rectangle is a struct instead of a class. Classes are sent by reference while primitive types like struct are sent by value. UiPath sends a copy of your rectangle to Invoke Method. Invoke Method calls Offset() which modifies the copy of your rectangle. You won’t see any difference because Invoke Method was never able to access your original rectangle.
If you just want to change the position of your rectangle, you can modify the X and Y properties instead. (X is for Left and Y is for Top)
Hi Peter, it works, and thanks for all your time checking out the answer.
Dear Peter andptrobot,
I learnt a lot from you both. A brief summary:
To edit the rectangle for further use, can simply edit directly the X, Y, Width, Height. I was caught by using the Top and Left, of which could NOT be edited directly by Assign activity.