IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Access Discussion :

Activation et désactivation de la touche MAJ [AC-2003]


Sujet :

VBA Access

  1. #1
    Membre habitué Avatar de taz devil
    Homme Profil pro
    Responsable d'un système d'information métier
    Inscrit en
    Avril 2012
    Messages
    298
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : Responsable d'un système d'information métier
    Secteur : Alimentation

    Informations forums :
    Inscription : Avril 2012
    Messages : 298
    Points : 141
    Points
    141
    Par défaut Activation et désactivation de la touche MAJ
    Bonjour
    J ai créer une application access 2003 ou l on utilise une douchette a code barre
    mais le soucis il arrive que la touche MAJ soit activé et cela change la lecture de la douchette. D ou ma question je voudrais savoir comment je peux faire pour désactivé la touche maj lors du chargement d un formulaire merci

  2. #2
    Membre expérimenté
    Avatar de mumen
    Homme Profil pro
    Développement à façon multisecteur.
    Inscrit en
    Mars 2004
    Messages
    566
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 63
    Localisation : France

    Informations professionnelles :
    Activité : Développement à façon multisecteur.

    Informations forums :
    Inscription : Mars 2004
    Messages : 566
    Points : 1 381
    Points
    1 381
    Par défaut
    Bonjour

    Quand tu dis la touche MAJ, tu veux dire Caps lock ?

    Quelle est la différence produite par cette touche lors la lecture de code barres ?

    Je ne sais pas comment inverser la touche, mais il est possible de savoir à la lecture l'état de cette touche et de rectifier ce qui entre avec une traduction du style :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Select case strTouche
    Case "&" :strTouche= "1"
    Case "é" :strTouche= "2"
    Case """" :strTouche= "3"
    etc.

  3. #3
    Expert éminent sénior
    Avatar de Dolphy35
    Homme Profil pro
    Responsable Systemes d'Information
    Inscrit en
    Octobre 2004
    Messages
    4 373
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable Systemes d'Information
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 373
    Points : 11 218
    Points
    11 218
    Par défaut
    Bonjour,

    voici un code qui fonctionne très bien et simple d'utilisation.
    1-Mettre ce code dans un module :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    Option Explicit
     
    ''''********************************************************************************''''
    '   Procédure utilisée pour simuler l'appuie des touches CapsLock, Numlock et ScrollLock
    ''''********************************************************************************''''
     
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As _
        Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) _
        As Long
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As _
        Integer
    Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" _
        (ByVal wCode As Long, ByVal wMapType As Long) As Long
     
    Public Const VK_NUMLOCK = &H90
    Public Const VK_SCROLL = &H91
    Public Const VK_CAPITAL = &H14
    Private Const KEYEVENTF_EXTENDEDKEY = &H1
    Private Const KEYEVENTF_KEYUP = &H2
     
    Public Sub SetKeyState(ByVal Key As Long, ByVal State As Boolean)
     
      keybd_event Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or 0, 0
      keybd_event Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
      If Key = 20 And State = False Then
          keybd_event 16, 0, 0, 0
        keybd_event 16, 0, 2, 0
      End If
     
    End Sub
     
    Public Property Get CapsLock() As Boolean
      CapsLock = GetKeyState(VK_CAPITAL) = 1
    End Property
     
    Public Property Let CapsLock(ByVal Value As Boolean)
      SetKeyState VK_CAPITAL, Value
    End Property
     
    Public Property Get NumLock() As Boolean
      NumLock = GetKeyState(VK_NUMLOCK) = 1
    End Property
     
    Public Property Let NumLock(ByVal Value As Boolean)
      SetKeyState VK_NUMLOCK, Value
    End Property
     
    Public Property Get ScrollLock() As Boolean
      ScrollLock = GetKeyState(VK_SCROLL) = 1
    End Property
     
    Public Property Let ScrollLock(ByVal Value As Boolean)
      SetKeyState VK_SCROLL, Value
    End Property
    2-utilisation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If CapsLock Then CapsLock = False
    source du code http://www.developpez.net/forums/d65...age-majuscule/

    @+

  4. #4
    Membre habitué Avatar de taz devil
    Homme Profil pro
    Responsable d'un système d'information métier
    Inscrit en
    Avril 2012
    Messages
    298
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : Responsable d'un système d'information métier
    Secteur : Alimentation

    Informations forums :
    Inscription : Avril 2012
    Messages : 298
    Points : 141
    Points
    141
    Par défaut Merci sa passe
    Citation Envoyé par Dolphy35 Voir le message
    Bonjour,

    voici un code qui fonctionne très bien et simple d'utilisation.
    1-Mettre ce code dans un module :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    Option Explicit
     
    ''''********************************************************************************''''
    '   Procédure utilisée pour simuler l'appuie des touches CapsLock, Numlock et ScrollLock
    ''''********************************************************************************''''
     
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As _
        Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) _
        As Long
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As _
        Integer
    Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" _
        (ByVal wCode As Long, ByVal wMapType As Long) As Long
     
    Public Const VK_NUMLOCK = &H90
    Public Const VK_SCROLL = &H91
    Public Const VK_CAPITAL = &H14
    Private Const KEYEVENTF_EXTENDEDKEY = &H1
    Private Const KEYEVENTF_KEYUP = &H2
     
    Public Sub SetKeyState(ByVal Key As Long, ByVal State As Boolean)
     
      keybd_event Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or 0, 0
      keybd_event Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
      If Key = 20 And State = False Then
          keybd_event 16, 0, 0, 0
        keybd_event 16, 0, 2, 0
      End If
     
    End Sub
     
    Public Property Get CapsLock() As Boolean
      CapsLock = GetKeyState(VK_CAPITAL) = 1
    End Property
     
    Public Property Let CapsLock(ByVal Value As Boolean)
      SetKeyState VK_CAPITAL, Value
    End Property
     
    Public Property Get NumLock() As Boolean
      NumLock = GetKeyState(VK_NUMLOCK) = 1
    End Property
     
    Public Property Let NumLock(ByVal Value As Boolean)
      SetKeyState VK_NUMLOCK, Value
    End Property
     
    Public Property Get ScrollLock() As Boolean
      ScrollLock = GetKeyState(VK_SCROLL) = 1
    End Property
     
    Public Property Let ScrollLock(ByVal Value As Boolean)
      SetKeyState VK_SCROLL, Value
    End Property
    2-utilisation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If CapsLock Then CapsLock = False
    source du code http://www.developpez.net/forums/d65...age-majuscule/

    @+

  5. #5
    Membre habitué Avatar de taz devil
    Homme Profil pro
    Responsable d'un système d'information métier
    Inscrit en
    Avril 2012
    Messages
    298
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : Responsable d'un système d'information métier
    Secteur : Alimentation

    Informations forums :
    Inscription : Avril 2012
    Messages : 298
    Points : 141
    Points
    141
    Par défaut Merci dolphy35
    le code marche mais si je veux activer le num lock en ajoutant le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If numlock Then numlock  = true
    le code marche pas merci

  6. #6
    Expert éminent sénior
    Avatar de Dolphy35
    Homme Profil pro
    Responsable Systemes d'Information
    Inscrit en
    Octobre 2004
    Messages
    4 373
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable Systemes d'Information
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 373
    Points : 11 218
    Points
    11 218
    Par défaut
    Bonsoir,

    Ceci est normal, en gros ton code test si NumLock est activé et si c'est le cas tu l'active. Donc en fait rien ne se passe.
    Si tu veux tester le fait qu'il ne soit pas activé pour l'activer, utilise ce code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If Not (NumLock) Then NumLock = True
    @++

  7. #7
    Membre habitué Avatar de taz devil
    Homme Profil pro
    Responsable d'un système d'information métier
    Inscrit en
    Avril 2012
    Messages
    298
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : Responsable d'un système d'information métier
    Secteur : Alimentation

    Informations forums :
    Inscription : Avril 2012
    Messages : 298
    Points : 141
    Points
    141
    Par défaut Bonjour marche toujours pas
    J ai remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If numlock Then numlock  = true
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If Not (NumLock) Then NumLock = True
    sa passe pas

  8. #8
    Membre habitué Avatar de taz devil
    Homme Profil pro
    Responsable d'un système d'information métier
    Inscrit en
    Avril 2012
    Messages
    298
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : Responsable d'un système d'information métier
    Secteur : Alimentation

    Informations forums :
    Inscription : Avril 2012
    Messages : 298
    Points : 141
    Points
    141
    Par défaut Une précision
    le code marche pour le caps lock sans problème même lorsque je met
    If Not (NumLock) Then NumLock = True le code marche pour capslock
    mais le numlock ne marche pas
    en gros
    le formulaire doit avoir par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
         capslock = false
         numlock = true
    merci encore Dolphy35

  9. #9
    Expert éminent sénior
    Avatar de Dolphy35
    Homme Profil pro
    Responsable Systemes d'Information
    Inscrit en
    Octobre 2004
    Messages
    4 373
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable Systemes d'Information
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 373
    Points : 11 218
    Points
    11 218
    Par défaut
    salut

    étonnant cela fonctionne bien chez moi avec le code plus haut

  10. #10
    Membre habitué Avatar de taz devil
    Homme Profil pro
    Responsable d'un système d'information métier
    Inscrit en
    Avril 2012
    Messages
    298
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : Responsable d'un système d'information métier
    Secteur : Alimentation

    Informations forums :
    Inscription : Avril 2012
    Messages : 298
    Points : 141
    Points
    141
    Par défaut erreur de code
    Oui sa marche j avais pas mis le bon code merci encore

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [A-03]Actication/Désactivation de la touche MAJ
    Par lucienkany dans le forum Sécurité
    Réponses: 1
    Dernier message: 28/09/2008, 18h42
  2. activer / desactiver la touche MAJ
    Par pimousse_on_ice dans le forum Langage
    Réponses: 2
    Dernier message: 14/12/2006, 20h55
  3. Réponses: 8
    Dernier message: 18/07/2006, 10h57
  4. Désactiver la touche MAJ au démarrage
    Par crapouye dans le forum Access
    Réponses: 6
    Dernier message: 06/12/2005, 13h49
  5. Réponses: 2
    Dernier message: 12/02/2004, 13h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo