cancel
Showing results for 
Search instead for 
Did you mean: 

How to change cursor to hourglass from a TestComplete Extension

SOLVED
Highlighted
New Contributor

How to change cursor to hourglass from a TestComplete Extension

I wrote a TestComplete extension to update Keyword-Test signature from TestComplete in to an external tool. However, this action takes very long time. That's why I need to change the cursor from arrow to hourglass, and back to arrow after action is done. (Using a try-catch-finaly, of course.)

The module doing the opperation is writen in js. However, my script extension contains vbs modules too and methods, I can successfully call from the js module. 
If I try to use the following code, suggested by TestComplete code completition in the vbs module:
Win32API.SetCursor(Win32API.IDC_WAIT);
I got the error "Object expected". I.e., the TestComplete extension does not know About Win32API object, despite the code completition suggestion, and despite the correct installation and activation of the win32api extension. (checked via File | Install extensions)
Ommiting the Win32API. prefix has similar effect. 

I did not found any aq*.* methods allowing changing the cursor.
SmartBears description on writing extentions seems to contain no hint about changing the cursor in a ScriptExtension. Please appologize, if I overlook it.

(PS: I am using an old TestComplete 10.60x Version; however, I guess, this is not the Point.)
Any suggestions are appreciated.

Thanx in advice for your F1!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: How to change cursor to hourglass from a TestComplete Extension

Hi,

 

The object does not support this property or method:  'dotNET.Cursors'

Proper assembly must be added to dotNET Bridge in TestComplete in order for this or that .Net class to become accessible for dotNET TestComplete's object. Depending on the .Net version/flavor you are using the required assembly might differ. (For example, as per https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.cursors?view=netcore-3.1,

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

6 REPLIES 6
Highlighted
Community Hero

Re: How to change cursor to hourglass from a TestComplete Extension

Hi,

 

Win32API object is not accessible from script extensions and I don't know any other way to change cursor but direct Win32 call that you mentioned.

Two possible options that I can imagine at the moment:

a) Wrap the code that sets cursor and calls a method from your script extension into one regular function in TestComplete and call this wrapping function but not script extension from your test code;

b) Considering that dotNET object is accessible from script extension, check if .Net provides the means to change cursor shape.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
New Contributor

Re: How to change cursor to hourglass from a TestComplete Extension

Hi Alex,

thank you for your response.

Regarding (a)

I am not sure, what you mean with "calls a method from your script extension into one regular function in TestComplete". Actually, I am trying to find adequate code for completing the following vbs sub:

sub setHourglass(b)
   if b then
      ' set hourglass cursor
   else
      ' set arrow cursor
   end if
end sub

All the rest is done. (I mean, the code doing the job calls MyNamespace.setHourglass(true) before time-consuming operation and MyNamespace.setHourglass(false) after the operation in a try-catch-finally block properly.)

Perhaps, you have a hint for me, how to go further in that direction.

Regarding (b)

The dotNet object contains a lot of properties. The only one I found via code completion, that seems to have something with cursor is

dotNet.System.Console.set_CursorTop

I expected some properties / methods for cursor below following namespace

dotNet.System.Window

However, the code completion does not offers it. 

That means: we have still no solution 😞

Perhaps, I overlook something. If you have a code example for me, please do not hesitate to share it with me. Thank you very much!

Highlighted
Community Hero

Re: How to change cursor to hourglass from a TestComplete Extension

Hi,

 

Excuse me for been not clear enough.

For a) I meant this:

-- Create something like this as a regular reusable test code (i.e. the code in your test project, but not in a Script Extension):

Sub CallLongProc

  setHourglass(True)

  MyNamespace.LongProcedureFromScriptExtension

  setHourglass(False)

End Sub

-- Call the above sub where needed.

 

If you just like to implement setHourglass() function as a standalone one within your script extension, then this is not possible because Win32API object is not accessible from within script extensions.

I should have somewhere my ages-old code 😉 that sets cursor to hourglass, but it is implemented with the use of win32 calls and thus cannot be ported to script extension.

 

.Net:

Something like this might help:

https://stackoverflow.com/questions/1568557/how-can-i-make-the-cursor-turn-to-the-wait-cursor

https://www.google.com/search?q=.net+change+cursor+to+hourglass

 

(For the first link I would try something like dotNET.Cursor.Current = dotNET.Cursors.WaitCursor;)

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
New Contributor

Re: How to change cursor to hourglass from a TestComplete Extension

Hi Alex,

Thank you very much for your detailed hints and your time!

I followed your hints. Unfortunately, no one of them was successful.

{For example, the code

    dotNET.Cursor.Current = dotNET.Cursors.WaitCursor

produces the error:

    The object does not support this property or method:  'dotNET.Cursors'

}

However, I think, we have no chance to do so and we should stop trying.

The reason is, following quote, that comes from https://support.smartbear.com/testcomplete/docs/working-with/extending/script/creating/specifics.htm...

"If your design-time action performs actions against the TestComplete main window (for example, minimizes the window, changes the window size and position, and so on), an error will occur. This happens due to specifics of thread organization in TestComplete."

I guess, the "on so on" part includes changing the cursor…

For our special situation is this non-critical: Our customers will know, we do not change the cursor in the script extension, even if the script extension needs more time than normal.

Many thanks for your effort and your help!

Best Regards

RLRE

Highlighted
Community Hero

Re: How to change cursor to hourglass from a TestComplete Extension

Hi,

 

The object does not support this property or method:  'dotNET.Cursors'

Proper assembly must be added to dotNET Bridge in TestComplete in order for this or that .Net class to become accessible for dotNET TestComplete's object. Depending on the .Net version/flavor you are using the required assembly might differ. (For example, as per https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.cursors?view=netcore-3.1,

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
New Contributor

Re: How to change cursor to hourglass from a TestComplete Extension

Hi Alex,

you are right: System.Windows.Forms.dll must be added to CLR-Bridge.

After that, following code does not produce any error:

Sub setHourglassCursor(b)
If b Then
dotNET.System_Windows_Forms.Cursor.Current = dotNET.System_Windows_Forms.Cursors.AppStarting
Else
dotNET.System_Windows_Forms.Cursor.Current = dotNET.System_Windows_Forms.Cursors.Arrow
End If
end Sub

However, the cursor stays unchanged.

At this point, I must really give this up: I must not assume any prerequisite for the project, in order to achieve, that the script extension properly work. (By the way, setting the hourglass is nice, not mandatory needed.)

Regardless of this, I would like to emphasis out, that your posts are the right approach. That's why I accept your last post as answer.

Thanks! 

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors