Hello..
Can someone tell me how can I trigger mouse click event whenever I want at any position on the screen where the mouse pointer is?
Thanks
Printable View
Hello..
Can someone tell me how can I trigger mouse click event whenever I want at any position on the screen where the mouse pointer is?
Thanks
On the sceen or on your app's window?
Not on my apps window...On screeen...anywhere on the screen ...startmenu anywhere (that includes apps window too)
You just use the Shared Cursor.Position property.
from all api
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)
change long to integer, and look it up online for examples:D
Forget I said that. D*mn, must read questions properly before posting. :blush:Quote:
Originally Posted by jmcilhinney
I do that all the time:DQuote:
Originally Posted by jmcilhinney
ok,how do I change this c# statement into vb.net?
It gives me an error if I simply put it likeCode:public enum MouseEventFlags
{
LEFTDOWNE = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
I have the c# code sample for that API...im trying to convert it to vb.net..and this enum also is used there for itVB Code:
Public Enum MouseEventFlags LEFTDOWNE = (0x00000002) LEFTUP = 0x00000004 MIDDLEDOWN = 0x00000020 MIDDLEUP = 0x00000040 MOVE = 0x00000001 ABSOLUTE = 0x00008000 RIGHTDOWN = 0x00000008 RIGHTUP = 0x00000010 End Enum
vb.net says it expects end of statement..Thats the error its giving for that enum..What should I do?
oops,I guess u told me to look at allapi.net...i was wondering what u meant by "from all api" first.
now i got it...Ill check there now..I saw this from pinvoke.net :)
Nevermind,I got it...
Thank You Mr.Polite,you did something so so so so Great...You saved my life by letting me know about that API. :)
Thank you Jm too...This method which you told me is the one I was just using...I found it just 2 days back from a code sample...You still tried to help too and have helped me in many things before :) Thanks
Hello people...
here is an example...Hope it helps someone :)
Ive set a timer to keep the mousedown...VB Code:
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer) Private Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move Private Const MOUSEEVENTF_MIDDLEDOWN = &H20 Private Const MOUSEEVENTF_MIDDLEUP = &H40 Private Const MOUSEEVENTF_RIGHTDOWN = &H8 Private Const MOUSEEVENTF_RIGHTUP = &H10 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1) End Sub
but now,Im in need of something else too...capturing the mouse event apart from clicking it...fine,Ill start a new thread for that...I wonder if theres a way to do that without APIs
nicely done:afrog:
remove the extra constants though lol, they don;t seem to be used
umm I'm looking at this page about this on MSDN,
http://msdn.microsoft.com/library/de...ouse_event.asp
it says This function has been superseded. Use SendInput instead.
I don't know what, if any, problems might occur if you stick with this function, but apparently using SendInput is the more correct way
but,this mouse event function works so perrrfecttt..theres no problem at all...but,very easy to make an annoying autoclick program with it by putting it in a timer.. maybe thats why they brought something better...i dont know,but this one works soo perfect and mouse buttons left right and middle can all be controlled smoothly including all their events up,down,etc.I think sendkeys doesnt have so much control over the mouse :)