Need to verify cursor state on disabled button

Originally posted by vladd1 on July 09, 2025

Thank you for whoever helps to start,

The issue I am seeing is running a disabled check on a button in my application. Unfortunately our team believes the best way to check the code we have to work with is to check the pointer-event, which remains: none. I am struggling to locate the cursor object whether inside Sys.Browser, Sys.Window, WndObjcect.

I have found the cursor documentation but I am unsure how to get the ‘*componentObj’*needed for the property check. I also see tObjectPicker and have name mapped the object I hover the mouse over, but the properties pickedObjectName and cursor return failures in my script.

I am working in circles it seems, please help.

Originally posted by JDR2500 on July 09, 2025

First, I’m not 100% sure what you are trying to accomplish, so sorry if my response is off target.

Years ago I dabbled with identifying the current cursor type (e.g. Arrow, Move, Etc.) and ended up using the Win32API. I was semi-successful accomplishing what I had in mind, but eventually took a different approach.
The below code (VBScript) shows what I did to get the cursor object. I passed this Function the application window object and got back the cursor object.

I can’t recall if that ended up working as I intended. I think I was on the right path with the Win32API though.

Function getCurrentCursor(wndObj)
  Dim pid, tid, crsr     
  pid = Win32API.GetWindowThreadProcessId(wndObj.Handle, Nothing)
  tid = Win32API.GetCurrentThreadId
  Call Win32API.AttachThreadInput(pid, tid, True)
  crsr = Win32API.GetCursor
  Call Win32API.AttachThreadInput(pid, tid, False)
  getCurrentCursor = crsr
End Function

Originally posted by scot1967 on July 09, 2025

Hello vladd1,

I think I know what you are struggling with.

You may have this doc which explains settings the various cursor states…
https://support.smartbear.com/testcomplete/docs/reference/user-forms/properties/cursor.html

The button likely has a .cursor property however.

var form = UserForms.SampleForm;
var button = form.buttonOK;

// Moves the cursor to the button center
button.MouseMove();

//Returns the cursor type
var currentCursor = button.Cursor;
Log.Message("Cursor type: " + currentCursor);

This code reads the current cursor type and logs it. The value returned will be one of the cr* constants (like crDefault, crHandPoint, etc.).

… If you find my posts helpful drop me a like! :+1: Be sure to mark or post the solution to help others out and/or to credit the one who helped you. :smiling_face_with_sunglasses:

Originally posted by Hassan_Ballan on July 09, 2025

I assume you are trying to validate the cursor as a work around to finding button state. If I understand it correctly your goal is to check if your application button is disabled and I suggest you have a read https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/onscreen/enabled-property-onscreen-object.html

:speech_balloon: If a response helped you out, don’t forget to Like it! And if it answered your question, mark it as the solution so others can benefit too.

Originally posted by rraghvani on July 10, 2025

What test are you trying to perform - verifying that the button is disabled? Or verifying that the cursor has changed upon hovering over the disabled button? Or verifying that the button can not be moved?

You mentioned “TObjectPicker”, is your application developed using Delphi?

Originally posted by Hassan_Ballan on July 13, 2025

TestComplete provides access to the cursor object via Sys.Desktop.Cursor, which allows you to identify the current mouse cursor shape by analyzing the cursor handle.

function GetCursorHandle() {
  var cursor = Sys.Desktop.Cursor;
  Log.Message("Cursor Handle: " + cursor.Handle);
}

You may also need to run Cursor.ToString() to save those handle values.

:speech_balloon: If a response helped you out, don’t forget to Like it! And if it answered your question, mark it as the solution so others can benefit too.

Originally posted by scot1967 on July 14, 2025

Yeah, this could likely be be found at the app level as well. Simpler if that action isn’t specially tied to the button object. Nice.

Originally posted by sean4311 on July 14, 2025

Hi vladd1​!

Do any of the solutions, provided by everyone here, help with what you are trying to build? If not, could you further elaborate on the scenario you are trying to accomplish with TestComplete?

Thanks!