Checkbox status

I want to change checked/unchecked a checkbox with a mouse positioned above it. Could you help me with an example?
cosminmAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
men xinConnect With a Mentor CEOCommented:
Hi,cosminm :

try this:

SendMessage(WindowFromPoint(Mouse.CursorPos), BM_SETCHECK, BST_CHECKED, 0);


menxin
0
 
rwilson032697Commented:
Try this:

var
  CPos : TPoint;
begin
  GetCursorPos(CPos);
  if ControlAtPos(CPos) is TComboBox then
    with (ControlAtPos(CPos) as TComboBox) do
      Checked := Not Checked;
end;

Cheers,

Raymond.
0
 
men xinCEOCommented:
Oh cosminm,you are in here!
this is my answer:

var pt:tpoint;
begin
....
  pt:=Form1.ClienttoScreen(point(CheckBox1.Left,CheckBox1.Top));
  SetCursorPos(pt.x+4,pt.y+4);
....
end;

menxin

0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
cosminmAuthor Commented:
The problem is that the checkbox is not in my program (is somewhere on the screen)... :(
I posted the q. here because I'm in a hurry and I offer points. :)
0
 
Roadrunner100598Commented:
Principally you should do something like...

- try to find the window handle of the check-box
  (and that's the tough part of the job)

- send it a message
  State:=SendMessage(HWnd, BM_GETCHECK, 0, 0)
  SendMessage(HWnd, BM_SETCHECK, State, 0)

I have no idea how to get the handle (maybe WindowFromPoint helps)

So long, Roadrunner

0
 
cosminmAuthor Commented:
Cool, worked.
I have one more (not burning)...
What are the API for get a string from a button.caption and a edit.text?

In fact I want to made an automation with clicks of a program outside mine...
Is there a component for this propose?
It would be much helpful...
0
 
men xinCEOCommented:
clickbutton?try this

SendMessage(WindowFromPoint(Mouse.CursorPos), wm_lbuttondown, 0, 0);
SendMessage(WindowFromPoint(Mouse.CursorPos), wm_lbuttonup, 0, 0);

and you can send a WM_GETTEXT message to a edit.

menxin

0
All Courses

From novice to tech pro — start learning today.