Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    278

    VB6 muovere il mouse con la tastiera e non solo

    ho capito come muovere il mouse con la tastiera..utillizzando le apposite funzioni api setcursor e getcursor...tuttavia non capisco come posso fargli accettare il click...o meglio il tasto destro e sinistro del mouse....avrei bisogno che questra possibilità funzioni non solo sul proprio programma ma anche su tutto il computer come se fosse un mouse.

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Si puo' usare la API

    SendInput

    passandole una struttura di tipo

    INPUT

    che al suo interno ha definito una apposita struttura di tipo

    MOUSEINPUT

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    278
    scusami ma queste funzioni sono per spedire funzioni mouse alle altre applicazioni oltre il form giusto?

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Sì ... ma non ci sono piu' funzioni ... la funzione e' una sola, la prima, la SendInput ...

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    278
    sì ok quello lo so.....grazie!!!

  6. #6
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Originariamente inviato da stejano
    sì ok quello lo so.....grazie!!!
    Avevi scritto "funzioni" ...

  7. #7
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    278
    ma ascolta in questa maniera il mouse viene accettato da tutte le applicazioni.....ma dovrò indicare un comando per ogni programma..oppure fatto uno va bene per tutti???scusa ma ancora non ho messo giù niente a riguardo perchè mi sto informando un po' per ora per capire meglio...son giunto a questo grazie ad aiuti vari:



    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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

    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 Type POINTAPI
    x As Long
    y As Long
    End Type
    Dim myPos As POINTAPI

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    GetCursorPos myPos
    Select Case KeyCode
    Case 37, vbKeyA: myPos.x = myPos.x - 5 'Left key or A
    Case 38, vbKeyW: myPos.y = myPos.y - 5 'Top key or W
    Case 39, vbKeyD: myPos.x = myPos.x + 5 'Right Key or D
    Case 40, vbKeyS: myPos.y = myPos.y + 5 'Down key or S
    Case vbKeyE: mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, myPos.x, myPos.y, 0&, 0&
    Case vbKeyR: mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, myPos.x, myPos.y, 0&, 0&
    End Select
    SetCursorPos myPos.x, myPos.y
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    Dim frm As Form
    For Each frm In Me
    Unload frm
    Next
    End Sub

  8. #8
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    278
    cmq molto più facile ottenere quello che voglio con un timer .....form1.show, lo si richiama ogni mezzo secondo ed il gioco è fatto...il programma funziona!!!!!!

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.