Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [VB NET] Generare evento click

    ciao a tutti.
    vorrei sapere come si faccio a generare un evento click (destro) nelle stesse coordinate dove è il mouse. non mi serve quindi settare nuove coordinate ma solo come generare l'evento click.
    ho provato con:
    codice:
        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
    ma non va :master:

    cosa sbaglio?

  2. #2
    In primo luogo, MOUSEEVENTF_LEFTDOWN è relativo alla pressione del tasto sinistro. Inoltre un click "completo" si compone di pressione e rilascio del pulsante del mouse, per cui dovrai fare:
    codice:
            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 1)
            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 1)
    Amaro C++, il gusto pieno dell'undefined behavior.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.