1

I made a autoclicker.

Now there is one problem. When I run the code it works it starts clicking but when I'm on full-screen (in game).

When I want to stop it I press on the app in the menubalk but it keeps open and closing.

How can I assign a button like F4 to run my code? Instead of clicking the start button I want to press F4.

I could get a higher mark for programming (I'm allowed to use this site for a better mark).

Here is my code:

Public Class Form1
    Declare Sub mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32)
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Start() 
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Label1.Text = Label1.Text + 1
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)
        mouse_event(&H2, 0, 0, 0, 1)
        mouse_event(&H4, 0, 0, 0, 1)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Label1.Text = 0
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)
        mouse_event(&H2, 0, 0, 0, 1)
        mouse_event(&H4, 0, 0, 0, 1)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Label1.Text = 0
    End Sub


End Class
halfer
  • 19,824
  • 17
  • 99
  • 186
G-J GAMES
  • 21
  • 4
  • Are you allowed to use libraries? If so I suggest my [InputHelper library](https://github.com/Visual-Vincent/InputHelper) ([wiki](https://github.com/Visual-Vincent/InputHelper/wiki)), it includes methods for keyboard and mouse detection as well as simulation. Here's a helpful post about how you can use it and view documentation for all its types: https://stackoverflow.com/a/50546165. -- If you can't use libraries, look into P/Invoking [`GetAsyncKeyState()`](https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getasynckeystate). – Visual Vincent Nov 04 '18 at 19:07
  • I can use everything but im a leek(newbie) to programming so. thanks for your comment i go try my best to understand it. – G-J GAMES Nov 04 '18 at 19:36
  • [Control.KeyPress Event](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.keypress?view=netframework-4.7.2) - no external libraries required. – Fabio Nov 04 '18 at 21:23
  • @Fabio : Seeing as the OP made an "autoclicker" and wants it to work with fullscreen apps he/she must use some sort of library _**or**_ Platform Invocation in order to detect the key press when his/her application does not have focus. – Visual Vincent Nov 05 '18 at 06:34

0 Answers0