Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    6

    vb6. Come abbinare un tasto a un bottone

    Ragazzi sono nei guai sto facendo un auto clik e volevo abbinare ai bottoni start e stop due tasti tipo F2 per inizio e F3 per fine ma non so come fare aiutatemi per favore
    ps: per adesso sono arrivato fino qui

    Option Explicit
    Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

    Private Const MOUSELEFTDOWN = &H2
    Private Const MOUSELEFTUP = &H4

    Private Sub Command1_Click()
    Timer1.Interval = Text1.Text
    Timer1.Enabled = True

    End Sub

    Private Sub Command2_Click()
    Timer1.Enabled = False
    End Sub


    Private Sub Form_Load()

    End Sub

    Private Sub Timer1_Timer()
    mouse_event MOUSELEFTDOWN, 0, 0, 0, 0
    mouse_event MOUSELEFTUP, 0, 0, 0, 0
    End Sub

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    6

    vb6. Come abbinare un tasto a un bottone

    Ragazzi sono nei guai sto facendo un auto clik e volevo abbinare ai bottoni start e stop due tasti tipo F2 per inizio e F3 per fine ma non so come fare aiutatemi per favore
    ps: per adesso sono arrivato fino qui
    codice:
    Option Explicit Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Private Const MOUSELEFTDOWN = &H2 Private Const MOUSELEFTUP = &H4 Private Sub Command1_Click() Timer1.Interval = Text1.Text Timer1.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False End Sub Private Sub Form_Load() End Sub Private Sub Timer1_Timer() mouse_event MOUSELEFTDOWN, 0, 0, 0, 0 mouse_event MOUSELEFTUP, 0, 0, 0, 0 End Sub

  3. #3
    Utente di HTML.it L'avatar di gibra
    Registrato dal
    Apr 2008
    residenza
    Italy
    Messaggi
    4,244
    Ma sei sicuro che ti serva davvero questa funzione?

    A me non sembra proprio.
    mouse_event si usa per il mouse, non per la tastiera, e tu parli di tasti.

    Secondo me:
    - imposta KeyPreview del Form a True
    - nella routine KeyDown() del Form metti il seguente codice:

    codice:
    If KeyCode = vbKeyF2 Then
        cmdStart.Value = True
    ElseIf KeyCode = vbKeyF3 Then
        cmdStop.Value = True
    End If

  4. #4
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    6
    emm scs non ho capito bene dove inserire
    poi il problema è che quando faccio start è praticamente impossibile fermare un auto clik cosi con i tasti facevo prima

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.