WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Mouse and Cursor Topics

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

MouseMove versus MouseInfo Discrepancies

Keywords: 	  mousemove mouseinfo

Question:

I'm trying to write a routine to calibrate the mouse to a click button on the screen. I need to determine where this button is on the screen to handle differenct screen resolutions. I've written code (revised code at the end of this article) to have the user point to the button in the application then I grab the mouse position and write it to an INI file. But when I test it, the mouse moves to a position above where the click button is at.

If I record the position of mouse on the screen and don't move anything why doesn't the mouse move back to the coordinates that it gets from the INI file?

Answer:

I've been thoughroughly berated by the developers. The claim is that this is not a bug.

Basically MouseInfo and MouseMove do not use the same system.

MouseInfo(5) gives a result based on the upper left corner of the Client Area, whileas MouseMove uses the upper left corner of the entire window.

To make them compatible you have to add stuff like title bar height to the MouseInfo return value.

Ummm, WinMetrics(4) (I think) gives you the title bar height.

Try...

DB_WIN="Winbatch Studio"
:start_cal
Pause("AutoImporter - Mouse Calibration","Click ""OK"" to calibrate yourmouse.")
lval=10
BoxOpen("Mouse Calibrator","Move mouse to IMPORT BUTTON")

for xx=5 to 1 by -1
BoxText(strcat("Move Mouse to import button",@crlf,"then wait ",xx," seconds"))
TimeDelay(1)
next

MousePos=MouseInfo(5)
;debug(1)
titleheight=WinMetrics(4)
menuheight=WinMetrics(15)
buttonbarheight=32
X_pos=ItemExtract(1,MousePos," ")
Y_pos=ItemExtract(2,MousePos," ")
y_Pos=Y_pos+titleheight +menuheight+buttonbarheight
Delay(1)
MouseMove(0,0,"%DB_Win%","")
Delay(2)
MouseMove(X_pos,Y_pos,"%DB_Win%","")

; *** debug test
m5a=mouseinfo(5)
m6a=mouseinfo(6)
message("M5","%m5% %m5a%")
message("M6","%m6% %m6a%")
message("X/Y","%X_pos% %Y_pos%")
; * NOTE M5 or M6 do not equal X/X ?????

val=AskYesNo("AutoImporter - Mouse Calibration","Is the mouse pointing at the
""Import"" button?")
if val==@NO then start_cal


Article ID:   W13298
Filename:   MoveMove and MouseInfo Discrepancies.txt
File Created: 2001:01:08:12:13:24
Last Updated: 2001:01:08:12:13:24