Hack Forums
[.NET] Mouse Click, Center Of Form Or Webbrowser? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Mouse Click, Center Of Form Or Webbrowser? (/showthread.php?tid=5006897)



Mouse Click, Center Of Form Or Webbrowser? - Lexxi. - Oct 1, 2015

Hello HF
i tried many ways of mouse click but no luck, tried searching but only found giving coords.
i want a mouse click to happen in the middle of the form so no matter where the form is (top screen, bottom) it will click in the center of the form


* - Odus - Oct 1, 2015

If you placed whatever is in the middle of the forum, call its click event instead.


* - Lexxi. - Oct 1, 2015

(Oct 1, 2015 08:29 AM)Odus Wrote:  If you placed whatever is in the middle of the forum, call its click event instead.

not sure? i dont mean like when mouse clicks, like i need the mouse to click in center of browser or form(same thing)


* - Odus - Oct 1, 2015

(Oct 1, 2015 08:32 AM)Chronicle L33T Wrote:  not sure? i dont mean like when mouse clicks, like i need the mouse to click in center of browser or form(same thing)

There was no mention of a browser in the OP. Instead of clicking the control, get the button or whatever on the web page it is' ID then invoke a click on it.


* - Lexxi. - Oct 1, 2015

(Oct 1, 2015 08:34 AM)Odus Wrote:  There was no mention of a browser in the OP. Instead of clicking the control, get the button or whatever on the web page it is' ID then invoke a click on it.

haha, thats what i use for buttons but this one doesnt have a button, its a game, when i inspect element outside it (the page) it gives element id but not for game only gives java options


* - ⁠Cammy - Oct 1, 2015

Make a new Point and divide the form width and height by 2, then invoke a mouseclick on that Point


* - bho007 - Oct 1, 2015

Code
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
    Sub MouseClickCenter()
        Dim x As Integer = CInt(Me.Left + (Me.Width / 2))
        Dim y As Integer = CInt(Me.Top + (Me.Height / 2))
        Cursor.Position = New Point(x, y)
        mouse_event(&H2, 0, 0, 0, 0)
        mouse_event(&H4, 0, 0, 0, 0)
    End Sub
i have made you this code try it 🤝


* - Lexxi. - Oct 1, 2015

(Oct 1, 2015 08:48 AM)bho007 Wrote:  
Code
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
    Sub MouseClickCenter()
        Dim x As Integer = CInt(Me.Left + (Me.Width / 2))
        Dim y As Integer = CInt(Me.Top + (Me.Height / 2))
        Cursor.Position = New Point(x, y)
        mouse_event(&H2, 0, 0, 0, 0)
        mouse_event(&H4, 0, 0, 0, 0)
    End Sub
i have made you this code try it 🤝

thanks alot, i had this code, my bad should of just use the me.width/2)) at end of it, thanks though


Thread closed- thanks for the code again :)