Simuler la combinaison de touche ALT + D

Signaler
Messages postés
216
Date d'inscription
mercredi 5 février 2003
Statut
Membre
Dernière intervention
15 décembre 2010
-
Messages postés
216
Date d'inscription
mercredi 5 février 2003
Statut
Membre
Dernière intervention
15 décembre 2010
-
Bonjour à tous,

Je cherche le moyen de simuler la combinaison ALT + D afin d'ouvrir la fenêtre d'Administration du logiciel DSLMON.exe pour les modems sagem fast800.

J'ai essayé pas mal de code avec des SendMessage mais rien ne fonctionne.

Si vous pouviez m'aider, merci par avance.


Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long



Public Const WM_KEYDOWN As Integer = &H100
Public Const WM_KEYUP As Integer = &H101
Public Const WM_SYSKEYDOWN As Integer = &H104
Public Const WM_SYSKEYUP  As Integer = &H105
Public Const WM_SYSCHAR = &H106

Public Const VK_ALT As Integer = 18
Public Const VK_D As Long = &H444


----------------
Dim handle As Long, hwnd As Long


' Handle de la fenetre SAGEM
handle = FindWindow(vbNullString, "SAGEM F@st 800-840")
If handle > 0 Then
        SetForegroundWindow handle
        hwnd = FindWindow(vbNullString, "Administration")
        
    If hwnd > 0 Then
        MsgBox "OUVERT"
    Else
       MsgBox "ouvre"
        'Actionne touche ALT + D
        Call SendMessage(handle, WM_KEYDOWN, VK_ALT, 0) '0 to 1.. also no effect
        Call SendMessage(handle, WM_KEYDOWN, VK_D, 0) '0 to 1.. also no effect
        Call SendMessage(handle, WM_KEYUP, VK_D, 0)
        Call SendMessage(handle, WM_KEYUP, VK_ALT, 0)

    End If
Else
MsgBox "shell"
ShellExecute Me.hwnd, "open", "dslmon.exe", "-f", App.Path, 1
End If

1 réponse

Messages postés
216
Date d'inscription
mercredi 5 février 2003
Statut
Membre
Dernière intervention
15 décembre 2010

Ok trouvé moi même, plusieur erreurs

1) La constante VK_ALT n'existe pas, il faut utiliser VK_MENU
2) La constante VK_D est fausse (ci-dessus)


Soit le code ci-dessous qui fonctionne

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long



Public Const VK_MENU = &H12
Public Const VK_D = &H44

Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Const KEYEVENTF_EXTENDEDKEY = &H1
Public Const KEYEVENTF_KEYUP = &H2

----------------
Dim handle As Long, hwnd As Long


' Handle de la fenetre SAGEM
handle = FindWindow(vbNullString, "SAGEM F@st 800-840")
If handle > 0 Then
        SetForegroundWindow handle
        hwnd = FindWindow(vbNullString, "Administration")
        
    If hwnd > 0 Then
        MsgBox "OUVERT"
    Else
        'Actionne touche ALT + D
  keybd_event VK_MENU, 0, 0, 0
  keybd_event VK_D, 0, 0, 0
  keybd_event VK_D, 0, KEYEVENTF_KEYUP, 0
  keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0

    End If
Else
MsgBox "shell"
ShellExecute Me.hwnd, "open", "dslmon.exe", "-f", App.Path, 1
End If