ST3VO
asked on
URGENT - Simulate MouseClick on a specific form
Hi again,
How can I programatically sumulate a mouseclick on a specific form please?
How can I programatically sumulate a mouseclick on a specific form please?
can you please be more specific what you want to achieve?
ASKER
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
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
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?
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?
ASKER
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
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
try
Form1.invalidate
Form1.invalidate
ASKER
I Get an Access Violation Error when I try to use it :o(
Isn't it better to just simulate to MouseClick on form1???
Isn't it better to just simulate to MouseClick on form1???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if don't mind,
Can you show some code?
Can you show some code?
ASKER
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
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
Check your form creation order. Is Form1 is your mainform(first creating form)
ASKER
Yes it is!
2nd is form2
2nd is form2
set a breakpoint, try to figure out what causes the AV
ASKER
OK..I'll give it a shot!!!
ASKER
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!
The question now is .....Got an Idea!!!!!!!!!!!! I'll get back to you!
ASKER
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
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