[AccessD] sending ALT Shift Characters

MartyConnelly martyconnelly at shaw.ca
Thu Dec 2 01:00:19 CST 2004


Here is some code hooked out of a long program


'See also this article It might be of some use

'Unicode and Keyboards on Windows
'http://www.microsoft.com/globaldev/handson/dev/Unicode-KbdsonWindows.pdf

'http://www.microsoft.com/globaldev/nlsweb/default.asp?submitted=40d

'Part of the file Win32api.txt:
'
'   VK_L VK_R - left and right Alt, Ctrl and Shift virtual keys.
'   Used only as parameters to GetAsyncKeyState() and GetKeyState().
'   No other API or message will distinguish left and right keys in this
'way.
'  /
Public Const VK_LSHIFT = &HA0
Public Const VK_RSHIFT = &HA1
Public Const VK_LCONTROL = &HA2
Public Const VK_RCONTROL = &HA3
Public Const VK_LMENU = &HA4
Public Const VK_RMENU = &HA5

'What a weird name for the Alt-key. but it does use the menu



Private Const VK_LWIN = &H5B 'Left window button
Private Const VK_RETURN = &HD  'ENTER key
Private Const VK_SHIFT = &H10 'SHIFT key
Private Const VK_CONTROL = &H11 'CTRL key
Private Const VK_MENU = &H12 'ALT key
Private Const VK_PAUSE = &H13 'PAUSE key
Private Const VK_CAPITAL = &H14 'CAPS LOCK key
Private Const VK_SNAPSHOT = &H2C  'Print Screen
Private Const VK_APPS = &H5D
         'Applications key on a Microsoft Natural Keyboard
'from http://support.microsoft.com/view/dev.asp?kb=242971

Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Private Const KEYEVENTF_KEYUP = &H2

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    ByVal bScan As Byte, ByVal dwflags As Long, ByVal dwExtraInfo As Long)

Sub ShiftToLanguage()
'use the following code inside form or focused window or textbox
'to simulate the Alt RightShift = key combination:

     ' then press and then release the AltRight RightShift key
     'order of pressing important
     keybd_event VK_RSHIFT, 0, 0, 0
      keybd_event VK_RMENU, 0, 0, 0
     
      
    keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0
'weird things happen if you don't up the shiftkey looks like capslock
'has been left on
   keybd_event VK_RSHIFT, 0, KEYEVENTF_KEYUP, 0
   'line below needed for Access97
 '  keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0
  
  Debug.Print "Right Shift"
  DoEvents

End Sub

Sub ShiftToLanguageBack()
'use the following code inside form or focused window or textbox
'to simulate the Alt RightShift = key combination:

     ' then press and then release the AltRight RightShift key
     'order of pressing important
     keybd_event VK_LSHIFT, 0, 0, 0
      keybd_event VK_LMENU, 0, 0, 0
     
      
    keybd_event VK_LMENU, 0, KEYEVENTF_KEYUP, 0
'weird things happen if you don't up the shiftkey looks like capslock
'has been left on
   keybd_event VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0
    'line below needed for Access97
  ' keybd_event VK_LMENU, 0, KEYEVENTF_KEYUP, 0
  Debug.Print "Left Shift"
  DoEvents

End Sub

handyman at actcom.co.il wrote:

> Hi All,
>
> When I enter data in a certain textbox, I need to do a "Left Alt + 
> Shift" in order to change the language from English to another 
> language.  Is there a way I can send this via code when entering the 
> textbox, and then  again when exiting the textbox.  I would imagine I 
> need to do it in the On Enter event, but how do I send the "Left Alt + 
> Shift"?
>
> Thanks
>
> Gershon Markowitz
> mailto:Handyman at actcom.co.il
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list