Mousedown button (without clicking)
I have code that has been working using api to perform a clickbutton (sendmessage) (without actually using mouse to click), but now I switched the code to mousedown (because the button needs to repeat, and I have a timer enabled to repeat the command when mouse down, stop on mouseup). If I add a clickbutton event also, it messes with the mousedown and can send too many (an extra command) commands when the mouse button is released. Soo, how can I simulate a mousedown (and mouseup), so that I don't have to click. This is for a joystick to "click" a button. An alternative idea would be, how do I add a clickbutton event, but dont have it fire when the button is clicked, lol, just have it fire when SendMessage API says to :) Thanks!
Re: Mousedown button (without clicking)
BootKing I could really use your code example when you get a chance.
Thanks
Re: Mousedown button (without clicking)
Ever thought about using DirectX's DirectInput to pull this off? With DirectInput, you have complete control over your input devices, and it reads/writes input directly from any input device rather than through windows messaging, which means it will not matter whether your form has focus or not. This can be any input device. Keyboard, Joystick, Mouse, Flight Stick, etc. Here is a mouse example:
http://externalweb.exhedra.com/Direc...N_Lesson02.asp
and I'm pretty sure in the DXCallback Sub, where you have control over the mouse, you should be able to make your mouse click without having to click it with no problem. :bigyello:
Re: Mousedown button (without clicking)
If I understand your question, you want to click a button from software, but disable the actual clicking that would occur if the user actually moved the mouse over there and clicked it manually.
Also I'm assuming that the program you are trying to click you do not have the source code for.
If these assumptions are true, then you may want to look into hooking the external application. (see example in my signature). If this looks like something you want to do we could discuss further.
Re: Mousedown button (without clicking)
Yes I have the Joystick class all ready to go from Direct X. However that is not the problem. The problem is how do I map the joystick controls to the mouse. Moving the mouse cursor is easy by using Me.Cursor.Position = New Point(x,y). The thing I can't figure out is how to execute mouse commands:
- mousedown
- click
- mouseup
I know there are events, and delegates all relevant to the mouse, but these are for taking action on the event after the fact.
I can do this in unmanaged code with a call to usr32.lib, but I do not want to do this.
One thing I also noticed about SetCursor it is not as smooth or as clean using the mouse. It begins to lagg if the application begins to become more complex. But if I switch back to the mouse everthing is normal. So is there another more direct way.
:eek2:
Re: Mousedown button (without clicking)
Since you mentioned that you know the hWnd of the control you want to click on you can simply send the WM_LBUTTONDOWN followed by the WM_LBUTTONUP messages.
VB Code:
Private Declare Function SendMessage _
Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
Private Const WM_LBUTTONDOWN As Long = &H201
Private Const WM_LBUTTONUP As Long = &H202
Public Sub ClickWindow(ByVal hWnd As Long)
SendMessage hWnd, WM_LBUTTONDOWN, 0, ByVal 0
SendMessage hWnd, WM_LBUTTONUP, 0, ByVal 0
End Sub
Re: Mousedown button (without clicking)
I think your missing the point, I want a Managed code way of doing this. I know user32.lib can do what I want. But it is not good togo from Managed to Unmanged code.
Re: Mousedown button (without clicking)
Quote:
Originally Posted by VbNem
I think your missing the point, I want a Managed code way of doing this. I know user32.lib can do what I want. But it is not good togo from Managed to Unmanged code.
Oh... So you're using VB.Net? In that case you've posted your question in the wrong forum.
Re: Mousedown button (without clicking)
Ahh Oops.. Anyway of Dragging this a .Net forum?