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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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
men xinCEOCommented:
Hi,cosminm :

try this:

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


menxin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.