|
-
Aug 9th, 2005, 01:31 AM
#1
Thread Starter
Lively Member
[RESOLVED] emulate Mouse Click
Hello All,
Is there a way to code a mouse click. That is provoke the events that happen when you click on a control with out physically clicking on it.
I have a toggle button that can be "toggled" by the user and the button indents when "on" and is proud when "off".
If i code for the button to be pressed "togglebutton1_click()" then code executes but the button doesnt change its physical State.
Thanks everyone
Hojo
Last edited by Hojo; Aug 9th, 2005 at 06:11 PM.
Despite body and mind, my youth will never die!
Everytime I learn something new it pushes some old stuff out of my brain!
-
Aug 9th, 2005, 01:33 AM
#2
Re: emulate Mouse Click
You can use a checkbox, set to graphical mode, that looks like a command button, but can be toggled.
-
Aug 9th, 2005, 01:37 AM
#3
Thread Starter
Lively Member
Re: emulate Mouse Click
David,
I have a toggle button but want it to toggle without clicking on it with the mouse
Hojo
Despite body and mind, my youth will never die!
Everytime I learn something new it pushes some old stuff out of my brain!
-
Aug 9th, 2005, 01:42 AM
#4
Thread Starter
Lively Member
Re: emulate Mouse Click
I'm thinking setting focus to control then somthing LIKE SendKeys but sending the left mouse button.
eg.
VB Code:
Togglebutton1.setFocus
Sendkeys (leftmousebutton) ' Whatever that would be
Does this seem possible to anyone
Hojo
Despite body and mind, my youth will never die!
Everytime I learn something new it pushes some old stuff out of my brain!
-
Aug 9th, 2005, 02:14 AM
#5
Re: emulate Mouse Click
Add a checkbox, and set its style to Graphical. Then add this to where you want to toggle it. (I am using a command button)
VB Code:
Option Explicit
Private Sub Command1_Click()
Check1.Value = 1 - Check1.Value
End Sub
-
Aug 9th, 2005, 02:17 AM
#6
Fanatic Member
Re: emulate Mouse Click
If you really want to emulate a mouse click...
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
See
http://www.mentalis.org/apilist/mouse_event.shtml
For further details and an example.
-
Aug 9th, 2005, 06:10 PM
#7
Thread Starter
Lively Member
Re: emulate Mouse Click
Thankyou David & Steven
Sorry David, I didn't totally get what you were saying the first time but this works like a charm. Except i'll be using
VB Code:
Check1.value = 0 ' for off
'Or
Check1.value = 1 ' for on
Because that works better logically for this specific program.
Thankyou also Steven for the simplicity of this program i won't used your method but its good to know for the future.
Thanks again guys.
Cheers Hojo
Despite body and mind, my youth will never die!
Everytime I learn something new it pushes some old stuff out of my brain!
-
Aug 9th, 2005, 07:34 PM
#8
Re: [RESOLVED] emulate Mouse Click
It's an old formula
1 - 1 = 0
1 - 0 = 1
so
1 - x = NOT X
You can't use NOT Check.value as a checkbox can be -1, 0, or 1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|