cGetWndCursor

Determines an application window’s current mouse cursor.

Syntax:

cGetWndCursor (window-handle, request)

 

Parameters:

(i) window-handle Windows handle of window of interest.

(i) request  Specifies the operation mode: 1, 2 or 3. (see below)

 

Returns:

(i) true/false/cursor-id

@TRUE, if the window-handle will display a wait cursor and request is set to 3.

@FALSE, if the window-handle will not display a wait cursor and request is set to 3

Cursor-id, The identifier of window-handle’s current cursor,
if request is set to 1 or 2.

 

You can use this function to determine an application window’s current mouse cursor. The mouse cursor is the small image displayed when the mouse pointer is positioned over the window.

cGetWndCursor has three modes of operation. You can indicate your preferred mode by specifying 1, 2 or 3 as the request parameter to the function.

If you pass 1 or 2 as the request parameter to cGetWndCursor, the function returns an identifier indicating which system cursor the window will display. Use mode 2 to get the cursor that will display when the mouse pointer is over the center of the target window. If you want to position the mouse pointer over a particular place on the target window and then retrieve the cursor, use mode 1. Mode 1 will get the window center cursor, like mode 2, if the mouse pointer is positioned outside the target window’s border.

If you pass in 3 as the second parameter, the function returns @TRUE or @FALSE. When the displayed cursor is the wait (usually an hourglass) or the starting app (usually an hourglass with an arrow) cursor, @TRUE is returned. If the window displays any other cursor type, @FALSE is returned.

Any Windows application can change the cursor’s images. cGetWndCursor can recognize changed cursor graphic as long as the target application associates the cursor with one of the Windows cursor identifiers.

The table below shows the Control Manager cursor identifiers associated with each Windows system cursor identifier:

 

Cursor Identifier

Windows System Identifier

1

IDC_ARROW

2

IDC_IBEAM

3

IDC_WAIT

4

IDC_CROSS

5

IDC_UPARROW

6

IDC_SIZE*

7

IDC_ICON*

8

IDC_SIZENWSE

9

IDC_SIZENESW

10

IDC_SIZEWE

11

IDC_SIZENS

12

IDC_SIZEALL

13

IDC_NO

14

IDC_HAND

15

IDC_APPSTARTING

16

IDC_HELP

0

No cursor or unknown cursor

 

 

* Obsolete identifiers

Words of warning: not all applications are well behaved. An application may be busy, i.e. not accepting input, but not display a wait cursor. In this case the function will not help you determine the application’s state. Also, select the window handle to pass to the function carefully. In most cases it is best to give cGetWndCursor the handle to the target application’s main window.

Example:

AddExtender("wwctl44i.dll",0,"wwctl64i.dll")
Cursor0 = "No cursor or Unknown cursor"
Cursor1 = "IDC_ARROW"
Cursor2 = "IDC_IBEAM"
Cursor3 = "IDC_WAIT"
Cursor4 = "IDC_CROSS"
Cursor5 = "IDC_UPARROW"
Cursor6 = "IDC_SIZE"
Cursor7 = "IDC_ICON"
Cursor8 = "IDC_SIZENWSE"
Cursor9 = "IDC_SIZENESW"
Cursor10 = "IDC_SIZEWE"
Cursor11 = "IDC_SIZENS"
Cursor12 = "IDC_SIZEALL"
Cursor13 = "IDC_NO"
Cursor14 = "IDC_HAND"
Cursor15 = "IDC_APPSTARTING"
Cursor16 = "IDC_HELP"
; Start up an application
WindowName = "~Notepad"
TestApp = "notepad.exe"
Params = ""
If !ShellExecute(TestApp, Params, "", @NORMAL, "")
   Return
EndIf
TimeDelay(2) ; Need a little time to get a window handle.
; Get a Windows handle
hwnd = DllHwnd(WindowName)
; Get the current cursor
AppCursorId = cGetWndCursor(hwnd, 2)
; Hourglass or arrow-hourglass?
If cGetWndCursor(hwnd, 3)
   MessageTitle = "%WindowName% is busy"
Else
   MessageTitle = "%WindowName% is not busy"
EndIf
WndCursor = Cursor%AppCursorId%
Message(MessageTitle, "Its cursor is %WndCursor%.")
WinClose(WindowName)
Exit

See Also:

cWndInfo, MouseMove (WIL help file)