• Domingo 22 de Diciembre de 2024, 08:21

Autor Tema:  Como Inhabilitar Teclado Mediante Código  (Leído 1558 veces)

VRPG

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Como Inhabilitar Teclado Mediante Código
« en: Jueves 26 de Agosto de 2004, 11:29 »
0
Buenos días a todos bueno la pregunta es la siguiente necesito inhabitar el teclado para que el usuario de la aplicacion una y exclusivamente introduzca datos mediante un lector de códigos de barras, pero solo quiero que este inhabilitado el teclado unicamente cuando este ejecuntadose la aplicacion una vez salga de ella el usuario tendria que tener acceso al teclado.

Teneis idea de como puedo hacerlo he utilizdo el evento KeyPress de la siguiente forma

Private Sub Text1_KeyPress(KeyAscii As Integer)
    KeyAscci = 0
End Sub

cuando pulsa culaquier tecla yo mediante código doy el valor 0 a la variable KeyAscci para que no escriba nada pero cuando leo un código de barras con el lector pasa por el mismo evento dejando tambien inhabiltado el lector.

He visto que se podria inhabilitar el puerto PS/2 del teclado enviando una secuencia por medio de MSDOS al puerto pero en realidad no se como hacerlo podiais ayurdame.

Gracias a todos.

Un saludo.

Cyclop

  • Miembro MUY activo
  • ***
  • Mensajes: 323
    • Ver Perfil
    • http://www.geocities.com/icotext/spanish/
Re: Como Inhabilitar Teclado Mediante Código
« Respuesta #1 en: Sábado 28 de Agosto de 2004, 02:36 »
0
Creo que no es posible ya que el lector convierte el codigo de barras en pulsaciones de teclado, mmm..... pero por que quieres desactivarlo.


Salu2

 :D

Cyclop
Icotext Evolution v0.5 para los amantes del ASCII Art
http]

Warce

  • Miembro activo
  • **
  • Mensajes: 49
    • Ver Perfil
Re: Como Inhabilitar Teclado Mediante Código
« Respuesta #2 en: Sábado 16 de Octubre de 2004, 19:34 »
0
[SIZE=14] Lo que podes haces es crear un archivo que bloquee el teclado estando ejecutando y a la vez poner ese archivo en el registro de windows para que se habilite cuanto windows inicie

'******************************************************************
'para bloquear el teclado:
       
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long

Private Sub Form_Load()
BlockInput True  'o false para activar
End Sub
'******************************************************************

'******************************************************************
'para ponerlo en el registro

'en un modulo

'Declarations required to edit the Windows Registry:
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
ByRef lpType As Long, ByVal szData As String, ByRef lpcbData As Long) As Long
Public Const REG_NONE = (0) 'No value type
Public Const REG_SZ = (1) 'Unicode nul terminated string
Public Const REG_EXPAND_SZ = (2) 'Unicode nul terminated string w/enviornment var
Public Const REG_BINARY = (3) 'Free form binary
Public Const REG_DWORD = (4) '32-bit number
Public Const REG_DWORD_LITTLE_ENDIAN = (4) '32-bit number (same as REG_DWORD)
Public Const REG_DWORD_BIG_ENDIAN = (5) '32-bit number
Public Const REG_LINK = (6) 'Symbolic Link (unicode)
Public Const REG_MULTI_SZ = (7) 'Multiple Unicode strings
Public Const REG_RESOURCE_LIST = (8) 'Resource list in the resource map
Public Const REG_FULL_RESOURCE_DESCRIPTOR = (9) 'Resource list in the hardware description
Public Const REG_RESOURCE_REQUIREMENTS_LIST = (10)
Const READ_CONTROL = &H20000
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type
Type SECURITY_DESCRIPTOR
Revision As Byte
Sbz1 As Byte
Control As Long
Owner As Long
Group As Long
End Type
Type ACL
AclRevision As Byte
Sbz1 As Byte
AclSize As Integer
AceCount As Integer
Sbz2 As Integer
End Type
Declare Function RegReplaceKey Lib "advapi32.dll" Alias "RegReplaceKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpNewFile As String, ByVal lpOldFile As String) As Long
Declare Function RegRestoreKey Lib "advapi32.dll" Alias "RegRestoreKeyA" (ByVal hKey As Long, ByVal lpFile As String, ByVal dwFlags As Long) As Long
Declare Function RegSaveKey Lib "advapi32.dll" Alias "RegSaveKeyA" (ByVal hKey As Long, ByVal lpFile As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Declare Function RegSetKeySecurity Lib "advapi32.dll" (ByVal hKey As Long, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long

Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
ByVal dwType As Long, ByVal szData As String, ByVal cbData As Long) As Long

Declare Function RegUnLoadKey Lib "advapi32.dll" Alias "RegUnLoadKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
"RegOpenKeyExA" (ByVal hKey As Long, _
ByVal lpSubKey As String, ByVal ulOptions As Long, _
ByVal samDesired As Long, phkResult As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Public Const HKEY_LOCAL_MACHINE = &H80000002
Private Const LB_ITEMFROMPOINT = &H1A9

Sub WriteRegistry(hKey As Long, SubKey As String, _
ValueName As String, vNewValue As String)
Dim Result As Long, RetVal As Long

RetVal = RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, Result)
RetVal = RegSetValueEx(Result, ValueName, 0, REG_SZ, vNewValue, CLng(Len(vNewValue) + 1))

RegCloseKey hKey
RegCloseKey Result

End Sub
Function PullValue(hKey As Long, Place As String, SubValue As String)
Dim szBuffer As String, dataBuff As String, ldataBuffSize As Long, phkResult As Long, RetVal As Long, _
Value As String, RegEnumIndex As Long
dataBuff = Space(255)
ldataBuffSize = Len(dataBuff)
szBuffer = Place
RetVal = RegOpenKeyEx(hKey, szBuffer, 0, KEY_ALL_ACCESS, phkResult)
Value = SubValue
RetVal = RegQueryValueEx(phkResult, Value, 0, 0, dataBuff, ldataBuffSize)
If RetVal = ERROR_SUCCESS Then

PullValue = s$
Else
MsgBox "Error in retreiving that value.", 16, "Error"
End If
End Function

'y en el form

Call WriteRegistry(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "aplicacion", "c:\aplicacion.exe")

'******************************************************************

Espero que te sirva... suerte...

RadicalEd

  • Moderador
  • ******
  • Mensajes: 2430
  • Nacionalidad: co
    • Ver Perfil
Re: Como Inhabilitar Teclado Mediante Código
« Respuesta #3 en: Sábado 16 de Octubre de 2004, 20:01 »
0
NO SE SI SOY YO PERO SERA POR QUE TIENES
 <_< KeyAscci=0 :huh:
EN VES DE
KeyAscii=0
NO SE PODRIA SER
El pasado son solo recuerdos, el futuro son solo sueños