Back

Topic

[KB141]How to retrieve mouse coordinates in SCADA BASIC

Tags: Scada Basic, Scripting

14 years ago
By RM
Options
Print
Applies to:

PcVue all versions.


Summary:

This articles describes how you can retrieve mouse coordinates in a PcVue project.


Details:

This uses the function GetCursorPos from a Windows DLL, USER32.DLL, to call an external API.

Note

You must first copy USER32.DLL from the folder C:\WINDOWS\SYSTEM32 into the TP folder of your project. (Replace C with the Windows drive if different.)

Example

This example shows the mouse co-ordinates in the Results pane of Program Management.

SB_Pgm_Mgmt_dialog_Mouse_Posns

DECLARE SUB GetCursorPos Lib “USER32” (HBF_POSI as long);

‘——– Function main
SUB main()
END sub

‘——– Use of function GetCursorPos
SUB test()
DIM Mouse_Buffer as long;
DIM Mouse_PosX as Integer;
DIM Mouse_PosY as Integer;
Mouse_Buffer = ALLOC_BUFFER(10);
GetCursorPos( Mouse_Buffer );
Mouse_PosX = IGET_BUFFER( Mouse_Buffer , 0); ‘X coordinate is available at offset 0
Mouse_PosY = IGET_BUFFER( Mouse_Buffer,4);   ‘Y coordinate is available at offset 4
PRINT(“Mouse_PosX = “,Mouse_PosX);
PRINT(“Mouse_PosY = “,Mouse_PosY);
PRINT(” “);
Free_buffer(Mouse_Buffer);
END SUB

Coordinates as database variables

You can define Mouse_PosX and Mouse_PosY as PcVue Database variables for checking or display.


Created on: 05 Nov 2010 Last update: 26 Aug 2024