[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

URGENT - Simulate MouseClick on a specific form

Posted on 2007-07-25
15
Medium Priority
?
558 Views
Last Modified: 2010-04-04
Hi again,

How can I programatically sumulate a mouseclick on a specific form please?



0
Comment
Question by:ST3VO
  • 8
  • 4
  • 3
15 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 19564590
can you please be more specific what you want to achieve?
0
 

Author Comment

by:ST3VO
ID: 19564653
Well...this is what's happening...

I start my application....

Form1:
It loads stuff into memory and I have a Loading Please Wait ... text on it.

Form2:
This Form is a small ToolBar type aligned on the bottom on top of Form1, which is the main form.

All this is fine BUT....The Please Wait ... stays on the form forever and doesn't go to the next level until I Click My mouse on Form1.

Otherwise it would be working fine.

So, for a quick fix if I can just simulate that MouseClick on Form1 ...it would work fine, unless you know another way!

Hope this explaination helps

Thanks

- ST3VO

0
 
LVL 19

Expert Comment

by:MerijnB
ID: 19564674
I assume you create that please-wait-form yourself.

Do you know why the click on the mainform hides this please-wait-form?
What did you try to make the please-wait-form to go away by itself?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ST3VO
ID: 19564736
No....The Please Wait Text is on the Main form itself.

It's 3D Programming....and the text is rendered by the engine.

If Form2 doesn't show up it doesn't have a problem BUT when Form2 Shows, then I need to click on Form1 for the rendered Textures to show up.

I think it's a question of focus BUT Form1.Setfocus does not fix it...only me clicking on Form1 does the trick, so that's why I need to do it by code.

Hope this helps further

0
 
LVL 10

Expert Comment

by:dinilud
ID: 19564756
try

Form1.invalidate
0
 

Author Comment

by:ST3VO
ID: 19564814
I Get an Access Violation Error when I try to use it :o(

Isn't it better to just simulate to MouseClick on form1???

0
 
LVL 19

Accepted Solution

by:
MerijnB earned 2000 total points
ID: 19564828
you'll have to figure out the right mouse pos yourself (is now 100, 100)

procedure TForm13.Button1Click(Sender: TObject);
var Inputs: array of TInput;
begin
 Mouse.CursorPos := Point(100, 100);

 SetLength(Inputs, 2);

 Inputs[0].Itype := INPUT_MOUSE;
 Inputs[0].mi.dwFlags := MOUSEEVENTF_LEFTDOWN;

 Inputs[1].Itype := INPUT_MOUSE;
 Inputs[1].mi.dwFlags := MOUSEEVENTF_LEFTUP;

 SendInput(2, Inputs[0], SizeOf(TInput));
end;
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19564907
if don't mind,

    Can you show some code?
0
 

Author Comment

by:ST3VO
ID: 19564928
I'm still getting an access violation error so I suppose that I need to find where to put the code.

I've create a procedure because I didn't want a Buttonclick...

So this is what i've done:

procedure TForm1.SimMouseClick;
var Inputs: array of TInput;
begin
 Mouse.CursorPos := Point(100, 100);

 SetLength(Inputs, 2);

 Inputs[0].Itype := INPUT_MOUSE;
 Inputs[0].mi.dwFlags := MOUSEEVENTF_LEFTDOWN;

 Inputs[1].Itype := INPUT_MOUSE;
 Inputs[1].mi.dwFlags := MOUSEEVENTF_LEFTUP;

 SendInput(2, Inputs[0], SizeOf(TInput));
end;

Then on the Form2...OnShow...I use:  Form1.SimMouseClick;

But I ge an Access Violation Error

Hmmm



0
 
LVL 10

Expert Comment

by:dinilud
ID: 19564967
Check your form creation order. Is Form1 is your mainform(first creating form)
0
 

Author Comment

by:ST3VO
ID: 19565075
Yes it is!

2nd is form2
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 19565082
set a breakpoint, try to figure out what causes the AV
0
 

Author Comment

by:ST3VO
ID: 19565113
OK..I'll give it a shot!!!
0
 

Author Comment

by:ST3VO
ID: 19565713
The problem seems to be that I need to wait until Form2 is fully loaded until I can call the SimMouseClick procedure.

The question now is .....Got an Idea!!!!!!!!!!!!   I'll get back to you!
0
 

Author Comment

by:ST3VO
ID: 19565750
GREAT!!!!!

Got it to work!!!! :o)

The Old Good Try...Finally...

procedure TForm2.FormShow(Sender: TObject);
Var f1H, f1w: Integer;
begin
try
blah...blah...blah
finally
Form1.SimMouseClick;
end;

And it works perfectly now!!!

Great!!!

Thanks guys!!!!

- ST3VO
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month17 days, 21 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question