Sendkeys

jo456 -  
lativ Posted messages 148 Status Member -
Hello,

I am currently making a program (VB) under VB6 and for now I’m progressing quite quickly thanks to the satisfying answers on this forum... however for the next step I will have to simulate pressing several keyboard keys in sequence... I will use "SendKeys" to do this. I know some keys such as:

Alt ... %
Shift ... +
F1... {F1}

but I need to know others, more specifically the keys "Win", "Up", "Down", "Left", "Right", "Enter" and "Tab"

thank you in advance for your help... I’ve been looking but can’t find!!!
Configuration: Windows XP Internet Explorer 7.0

4 answers

  1. scriptiz Posted messages 1494 Status Member 425
     
    On this page: "To specify a key combination with SHIFT, CTRL and ALT, precede the normal key code with one or more codes among the following:
    SHIFT + CTRL ^ ALT %
    " so for ALT+TAB, for example, to switch windows. There is also this: "For specifying that the SHIFT, CTRL and ALT keys must be held down while other keys are used, place the codes for these keys in parentheses. For example, to specify that the SHIFT key must be held down while you press the E and C keys, use "+(EC)". To specify that the SHIFT key must be held down while you press the E key, then release the SHIFT key while you press the C key, use "+EC". To specify key repetition, use the form {key number}. Be sure to put a space between the key and the number of times that key should be pressed. For example, {LEFT 42} means the LEFT key is pressed 42 times. {h 10} indicates that the H key should be pressed 10 times." Then for the Windows key (the Super key), it’s simply the CTRL+ESC combination. So you can do it with ^ and {ESC} in your SendKeys. There you go. Good luck.
    2
    1. lativ Posted messages 148 Status Member 4
       
      If the Escape key is damaged, you just need to press Alt 027 (hold Alt down while typing 027)
      0
  2. michel_m Posted messages 18903 Registration date   Status Contributor Last intervention   3 320
     
    Hello

    ... the longest part was finding this outline in my b... which I still name the hard drive...

     Trigger a procedure via a keyboard shortcut ... We will make sure not to define single keys but rather a key combination ... like CTRL + f which for VBA code would give: Application.OnKey "{^f}", "NomDeLaMacro" AIDE {HELP} ARRÊT DÉFIL. {SCROLLLOCK} DOWN {DOWN} From F1 to F15 {F1} to {F15} START {HOME} RIGHT {RIGHT} ESCAPE {ESCAPE} or {ESC} ERASE {CLEAR} ENTER (numpad) {ENTER} END {END} LEFT {LEFT} UP {UP} INSERT {INSERT} PAUSE {BREAK} PAGE.PREV {PGUP} PAGE.NEXT {PGDN} RET.ARR {BACKSPACE} or {BS} RETURN {RETURN} DELETE or DEL {DELETE} or {DEL} TABULATION {TAB} SHIFT LOCK {CAPSLOCK} NUM LOCK {NUMLOCK} To combine keys place the character below before the key code ALT % (percent sign) CTRL ^ (caret) SHIFT + (plus sign) Option Explicit 'Assign a shortcut to the ESC key "Essai" = name of the macro to run Sub Affectation() Application.OnKey "{ESCAPE}", "Essai" End Sub

    --
    Best regards,
    Michel
    0
  3. scriptiz Posted messages 1494 Status Member 425
     
    0
    1. jo456
       
      the most important thing for me is the "winwows" key to access the start menu do you know what the shortcut is?
      thank you for all that you have already brought me
      0
      1. jo456 > jo456
         
        I’d also like to know if it’s possible to simulate holding down a key...
        example.... ALT (hold down) then tab...tab

        this would allow me to display another window if several are open at the bottom.
        0
      2. kris > jo456
         
        Yes, it has been given thousands of times (!) among professionals
        See on news://fr.comp.os.ms-windows.programmation
        0
  4. michel_m Posted messages 18903 Registration date   Status Contributor Last intervention   3 320
     
    Unfortunately not! I will try to "win" at every turn, but...
    --
    Kind regards,
    Michel
    0