Jump to content
spartakos

ClickMouseBox in 3.40?

Recommended Posts

You could simply read the mouse position after calling mousebox and click at that position?

 

procedure ClickMouseBoxEx(const Box: TBox; const MouseSpeed: LongInt);
var
 MousePos: TPoint;
begin
 MoveMouseBoxEx(Box, MouseSpeed);
 GetMousePos(MousePos.X, MousePos.Y);
 ClickMouse(MousePos.X, MousePos.Y, mbLeft);
end;

Link to comment
Share on other sites

Not sure on what you are trying to do.

 

ClickMouseBoxEx would click somewhere in a rectangular area. If you want to click on an exact position ClickMouse will do everything you need. It is difficult to know what you are doing without seeing what you are working with.

 

Often I will randomize the found point a bit (which is what you are trying to do here?) but how much to randomize depends entirely on the item you are clicking on: Too much randomization you'll miss the target. Not enough it looks very bot like. There is no hard and fast rule here.

 

If I wanted to click somewhere within 10 pixels of the found point I would simply do something like this.

 

var
 P: TPoint;
// Left some out here cuz I'm too lazy to type...
begin
 if FindBitmapTol(P.X, P.Y, ... then
 begin
   P := Point(RandomRange(P.X - 10, P.X + 10), RandomRange(P.Y - 10, P.Y + 10));
   MoveMouse(P.X, P.Y);
   ClickMouse(P.X, P.Y, mbLeft);
// more left out here
 end;
// and here
end;

Link to comment
Share on other sites

I was trying to convey you can duplicate the functionality of ClickMouseBox exactly by doing the following:

 

- Use MoveMouseBox (moves mouse to a random location inside the specified box)

- Read the current mouse position using GetMousePos (to find out where MoveMouseBox moved the mouse to)

- Click the mouse at that location using ClickMouse

 

program New;

var
 B: TBox;
 P: TPoint;

begin
 B := Box(100, 100, 200, 200);
 MoveMouseBox(B);
 GetMousePos(P.X, P.Y);
 ClickMouse(P.X, P.Y, mbLeft);
end.

Edited by Bixby Sayz
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...