Forum de Programmation en langage PANORAMIC


Rejoignez le forum, c’est rapide et facile

Forum de Programmation en langage PANORAMIC
Forum de Programmation en langage PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Rechercher
 
 

Résultats par :
 


Rechercher Recherche avancée

Derniers sujets
» Bonne année 2024
 Simuler l’appui d'une touche ou combinaison de touches EmptyLun 1 Jan - 0:25 par Papydall-Admin

» A ceux qui célèbre Noël, bonnes fêtes
 Simuler l’appui d'une touche ou combinaison de touches EmptyDim 24 Déc - 10:49 par Papydall-Admin

» Joyeux Noël et Bonne Année
 Simuler l’appui d'une touche ou combinaison de touches EmptyVen 8 Déc - 1:34 par Papydall-Admin

» Planets of the Solar System : Tilts and Spins
 Simuler l’appui d'une touche ou combinaison de touches EmptyLun 20 Mar - 15:43 par Papydall-Admin

» Bonne Année 2023
 Simuler l’appui d'une touche ou combinaison de touches EmptySam 31 Déc - 1:39 par Papydall-Admin

» Fractals - Mandelbrot
 Simuler l’appui d'une touche ou combinaison de touches EmptyVen 21 Aoû - 22:51 par Papydall-Admin

» Convertisseur Décimal ---> Binaire, Octal, Hexadécimal, ...
 Simuler l’appui d'une touche ou combinaison de touches EmptyMer 21 Nov - 1:08 par Papydall-Admin

» Balises {USER...}
 Simuler l’appui d'une touche ou combinaison de touches EmptyLun 19 Nov - 22:12 par Papydall-Admin

» Useful Dog
 Simuler l’appui d'une touche ou combinaison de touches EmptyVen 6 Avr - 14:25 par Papydall-Admin

Avril 2024
LunMarMerJeuVenSamDim
1234567
891011121314
15161718192021
22232425262728
2930     

Calendrier Calendrier

-40%
Le deal à ne pas rater :
-40% sur le Pack Gaming Mario PDP Manette filaire + Casque filaire ...
29.99 € 49.99 €
Voir le deal

Simuler l’appui d'une touche ou combinaison de touches

Aller en bas

 Simuler l’appui d'une touche ou combinaison de touches Empty Simuler l’appui d'une touche ou combinaison de touches

Message par Papydall-Admin Lun 28 Aoû - 0:38

Code:
rem ============================================================================
rem           Keyboard Events Simulation using keybd_event() function
rem                            By  Papydall
rem                            27 / 08 2017
rem ============================================================================
rem Syntax :
rem             Keybd(bVk%, bScan%, dwFlags%, dwExtraInfo%)
rem Parameters :
rem bVK%         : Virtual Keycode of keys. E.g., VK_RETURN, VK_TAB…
rem bScan%       : Scan Code value of keys. E.g., hex("B8") for “Left Alt” key.
rem dwFlag%      : Flag that is set for key state. E.g., KEYEVENTF_KEYUP.
rem dwExtraInfo% : 32-bit extra information about keystroke.
rem ============================================================================

Constantes()

rem ============================================================================
' Exemples d’utilisation
' 1 / Simulation de ALT + TAB
Keybd(VK_MENU,hex("B8"),0,0) : ' ALT Press
Keybd(VK_TAB, hex("8F"),0,0) : ' TAB press
pause 2000 : ' Temporisation pour observer le changement
Keybd(VK_TAB, hex("8F"), KEYEVENTF_KEYUP,0) : ' Tab Release
Keybd(VK_MENU,hex("B8"), KEYEVENTF_KEYUP,0) : ' Alt Release
rem ============================================================================
' 2 / Simulation de CTRL + A  <--- Tout sélectionner
Keybd(VK_CONTROL,hex("9D"),0 , 0)             : ' Ctrl Press
Keybd(VK_A, hex("9E"),0 , 0)                  : ' ‘A’ Press
Keybd(VK_A, hex("9E"), KEYEVENTF_KEYUP,0)     : ' ‘A’ Release
Keybd(VK_CONTROL,hex("9D"),KEYEVENTF_KEYUP,0) : ' Ctrl Release
rem ============================================================================
' 3 / Simulation de CTRL + C <--- Copier la sélection dans le presse-papier
Keybd(VK_CONTROL,hex("9D"),0 , 0)             : ' Ctrl Press
Keybd(VK_C,hex("9E"),0 , 0)                   : ' ‘C’ Press
Keybd(VK_C,hex("9E"), KEYEVENTF_KEYUP,0)      : ' ‘C’ Release
Keybd(VK_CONTROL,hex("9D"),KEYEVENTF_KEYUP,0) : ' Ctrl Release
rem ============================================================================
' 4 / Simulation de CTRL + R <--- Rechercher et Remplacer
Keybd(VK_CONTROL,hex("9D"),0 , 0)             : ' Ctrl Press
Keybd(VK_R,hex("9E"),0 , 0)                   : ' ‘R’ Press
Keybd(VK_R,hex("9E"), KEYEVENTF_KEYUP,0)      : ' ‘R’ Release
Keybd(VK_CONTROL,hex("9D"),KEYEVENTF_KEYUP,0) : ' Ctrl Release

rem ============================================================================
end
rem ============================================================================
' Code virtuel de la touche
SUB Constantes()
' ------------------------------------------------------------------------------
    dim VK_LBUTTON : VK_LBUTTON = hex("01") : ' Left mouse button
    dim VK_RBUTTON : VK_RBUTTON = hex("02") : ' Right mouse button
    dim VK_CANCEL  : VK_CANCEL  = hex("03") : ' Control-break processing
    dim VK_MBUTTON : VK_MBUTTON = hex("04") : ' Middle mouse button (three-button mouse)
' ------------------------------------------------------------------------------
    dim VK_BACK    : VK_BACK    = hex("08") : ' BACKSPACE key
    dim VK_TAB     : VK_TAB     = hex("09") : ' TAB key
    dim VK_CLEAR   : VK_CLEAR   = hex("0C") : ' CLEAR key
    dim VK_RETURN  : VK_RETURN  = hex("0D") : ' ENTER key
    dim VK_SHIFT   : VK_SHIFT   = hex("10") : ' SHIFT key
    dim VK_CONTROL : VK_CONTROL = hex("11") : ' CTRL key
    dim VK_MENU    : VK_MENU    = hex("12") : ' ALT key
    dim VK_PAUSE   : VK_PAUSE   = hex("13") : ' PAUSE key
    dim VK_CAPITAL : VK_CAPITAL = hex("14") : ' CAPS LOCK key
    dim VK_ESCAPE  : VK_ESCAPE  = hex("1B") : ' ESC key
    dim VK_SPACE   : VK_SPACE   = hex("20") : ' SPACEBAR
    dim VK_PRIOR   : VK_PRIOR   = hex("21") : ' PAGE UP key
    dim VK_NEXT    : VK_NEXT    = hex("22") : ' PAGE DOWN key
    dim VK_END     : VK_END     = hex("23") : ' END key
    dim VK_HOME    : VK_HOME    = hex("24") : ' HOME key
    dim VK_LEFT    : VK_LEFT    = hex("25") : ' LEFT ARROW key
    dim VK_UP      : VK_UP      = hex("26") : ' UP ARROW key
    dim VK_RIGHT   : VK_RIGHT   = hex("27") : ' RIGHT ARROW key
    dim VK_DOWN    : VK_DOWN    = hex("28") : ' DOWN ARROW key
    dim VK_SELECT  : VK_SELECT  = hex("29") : ' SELECT key
    dim VK_EXECUTE : VK_EXECUTE = hex("2B") : ' EXECUTE key
    dim VK_SNAPSHOT: VK_SNAPSHOT= hex("2C") : ' PRINT SCREEN key
    dim VK_INSERT  : VK_INSERT  = hex("2D") : ' INS key
    dim VK_DELETE  : VK_DELETE  = hex("2E") : ' DEL key
    dim VK_HELP    : VK_HELP    = hex("2F") : ' HELP key
' ------------------------------------------------------------------------------
    dim VK_0       : VK_0       = hex("30") : ' 0 key
    dim VK_1       : VK_1       = hex("31") : ' 1 key
    dim VK_2       : VK_2       = hex("32") : ' 2 key
    dim VK_3       : VK_3       = hex("33") : ' 3 key
    dim VK_4       : VK_4       = hex("34") : ' 4 key
    dim VK_5       : VK_5       = hex("35") : ' 5 key
    dim VK_6       : VK_6       = hex("36") : ' 6 key
    dim VK_7       : VK_7       = hex("37") : ' 7 key
    dim VK_8       : VK_8       = hex("38") : ' 8 key
    dim VK_9       : VK_9       = hex("39") : ' 9 key
' ------------------------------------------------------------------------------
    dim VK_A       : VK_A       = hex("41") : ' A key
    dim VK_B       : VK_B       = hex("42") : ' B key
    dim VK_C       : VK_C       = hex("43") : ' C key
    dim VK_D       : VK_D       = hex("44") : ' D key
    dim VK_E       : VK_E       = hex("45") : ' E key
    dim VK_F       : VK_F       = hex("46") : ' F key
    dim VK_G       : VK_G       = hex("47") : ' G key
    dim VK_H       : VK_H       = hex("48") : ' H key
    dim VK_I       : VK_I       = hex("49") : ' I key
    dim VK_J       : VK_J       = hex("4A") : ' J key
    dim VK_K       : VK_K       = hex("4B") : ' K key
    dim VK_L       : VK_L       = hex("4C") : ' L key
    dim VK_M       : VK_M       = hex("4D") : ' M key
    dim VK_N       : VK_N       = hex("4E") : ' N key
    dim VK_O       : VK_O       = hex("4F") : ' O key
    dim VK_P       : VK_P       = hex("50") : ' P key
    dim VK_Q       : VK_Q       = hex("51") : ' Q key
    dim VK_R       : VK_R       = hex("52") : ' R key
    dim VK_S       : VK_S       = hex("53") : ' S key
    dim VK_T       : VK_T       = hex("54") : ' T key
    dim VK_U       : VK_U       = hex("55") : ' U key
    dim VK_V       : VK_V       = hex("56") : ' V key
    dim VK_W       : VK_W       = hex("57") : ' W key
    dim VK_X       : VK_X       = hex("58") : ' X key
    dim VK_Y       : VK_Y       = hex("59") : ' Y key
    dim VK_Z       : VK_Z       = hex("5A") : ' Z key
' ------------------------------------------------------------------------------
    dim VK_LWIN    : VK_LWIN    = hex("5B") : ' Left Windows key (Microsoft Natural Keyboard)
    dim VK_RWIN    : VK_RWIN    = hex("5C") : ' Right Windows key (Microsoft Natural Keyboard)
    dim VK_APPS    : VK_APPS    = hex("5D") : ' Applications key (Microsoft Natural Keyboard)
' ------------------------------------------------------------------------------
    dim VK_NUMPAD0 : VK_NUMPAD0 = hex("60") : ' Numeric keypad 0 key
    dim VK_NUMPAD1 : VK_NUMPAD1 = hex("61") : ' Numeric keypad 1 key
    dim VK_NUMPAD2 : VK_NUMPAD2 = hex("62") : ' Numeric keypad 2 key
    dim VK_NUMPAD3 : VK_NUMPAD3 = hex("63") : ' Numeric keypad 3 key
    dim VK_NUMPAD4 : VK_NUMPAD4 = hex("64") : ' Numeric keypad 4 key
    dim VK_NUMPAD5 : VK_NUMPAD5 = hex("65") : ' Numeric keypad 5 key
    dim VK_NUMPAD6 : VK_NUMPAD6 = hex("66") : ' Numeric keypad 6 key
    dim VK_NUMPAD7 : VK_NUMPAD7 = hex("67") : ' Numeric keypad 7 key
    dim VK_NUMPAD8 : VK_NUMPAD8 = hex("68") : ' Numeric keypad 8 key
    dim VK_NUMPAD9 : VK_NUMPAD9 = hex("69") : ' Numeric keypad 9 key
' ------------------------------------------------------------------------------
    dim VK_MULTIPLY  : VK_MULTIPLY  = hex("6A") : ' Multiply key
    dim VK_ADD       : VK_ADD       = hex("6B") : ' Add key
    dim VK_SEPARATOR : VK_SEPARATOR = hex("6C") : ' Separator key
    dim VK_SUBTRACT  : VK_SUBTRACT  = hex("6D") : ' Subtract key
    dim VK_DECIMAL   : VK_DECIMAL   = hex("6E") : ' Decimal key
    dim VK_DIVIDE    : VK_DIVIDE    = hex("6F") : ' Divide key
' ------------------------------------------------------------------------------
    dim VK_F1  : VK_F1  = hex("70") : ' F1 key
    dim VK_F2  : VK_F2  = hex("71") : ' F2 key
    dim VK_F3  : VK_F3  = hex("72") : ' F3 key
    dim VK_F4  : VK_F4  = hex("73") : ' F4 key
    dim VK_F5  : VK_F5  = hex("74") : ' F5 key
    dim VK_F6  : VK_F6  = hex("75") : ' F6 key
    dim VK_F7  : VK_F7  = hex("76") : ' F7 key
    dim VK_F8  : VK_F8  = hex("77") : ' F8 key
    dim VK_F9  : VK_F9  = hex("78") : ' F9 key
    dim VK_F10 : VK_F10 = hex("79") : ' F10 key
    dim VK_F11 : VK_F11 = hex("7A") : ' F11 key
    dim VK_F12 : VK_F12 = hex("7B") : ' F12 key
    dim VK_F13 : VK_F13 = hex("7C") : ' F13 key
    dim VK_F14 : VK_F14 = hex("7D") : ' F14 key
    dim VK_F15 : VK_F15 = hex("7E") : ' F15 key
    dim VK_F16 : VK_F16 = hex("7F") : ' F16 key
    dim VK_F17 : VK_F17 = hex("80") : ' F17 key
    dim VK_F18 : VK_F18 = hex("81") : ' F18 key
    dim VK_F19 : VK_F19 = hex("82") : ' F19 key
    dim VK_F20 : VK_F20 = hex("83") : ' F20 key
    dim VK_F21 : VK_F21 = hex("84") : ' F21 key
    dim VK_F22 : VK_F22 = hex("85") : ' F22 key
    dim VK_F23 : VK_F23 = hex("86") : ' F23 key
    dim VK_F24 : VK_F24 = hex("87") : ' F24 key
' ------------------------------------------------------------------------------
    dim VK_NUMLOCK : VK_NUMLOCK = hex("90") : ' NUM LOCK key
    dim VK_SCROLL  : VK_SCROLL  = hex("91") : ' SCROLL LOCK key
' ------------------------------------------------------------------------------
    dim KEYEVENTF_EXTENDEDKEY : KEYEVENTF_EXTENDEDKEY = hex("00") : ' Key down flag    
    dim KEYEVENTF_KEYUP       : KEYEVENTF_KEYUP       = hex("02") : ' Key up flag
    dim VK_LCONTROL           : VK_LCONTROL           = hex("A2") : ' Left Control key code
END_SUB
rem ============================================================================
' Scan code is the hardware key code for the key (make and break codes).
' The following are the available scan codes (break code will be used in this parameter).
' Les codes sont en Hexa
rem Key        Make  Break      Key   Make  Break
rem Backspace   0E    8E        F1     3B    BB
rem Caps Lock   3A    BA        F2     3C    BC
rem Enter       1C    9C        F3     3D    BD
rem ESC         01    81        F4     3E    BE
rem Left Alt    38    B8        F5     3F    BF
rem Left Ctrl   1D    9D        F6     40    C0
rem Left Shift  2A    AA        F7     41    C1
rem Num Lock    45    C5        F8     42    C2
rem Right Shift 36    B6        F9     43    C3
rem Scroll Lock 46    C6        F10    44    C4
rem Space       39    B9        F11    57    D7
rem Tab         0F    8F        F12    58    D8
' ------------------------------------------------------------------------------
rem A           1E    9E        N      31    B1
rem B           30    B0        O      18    98
rem C           2E    AE        P      19    99
rem D           20    A0        Q      10    90
rem E           12    92        R      13    93
rem F           21    A1        S      1F    9F
rem G           22    A2        T      14    94
rem H           23    A3        U      16    96
rem I           17    97        V      2F    AF
rem J           24    A4        W      11    91
rem K           25    A5        X      2D    AD
rem L           26    A6        Y      15    95
rem M           32    B2        Z      2C    AC
' ------------------------------------------------------------------------------
rem 1           02    82        -      0C    8C
rem 2           03    83        =      0D    8D
rem 3           04    84        [      1A    9A
rem 4           05    85        ]      1B    9B
rem 5           06    86        ;      27    A7
rem 6           07    87        '      28    A8
rem 7           08    88        `      29    A9
rem 8           09    89        \      28    A8
rem 9           0A    8A        ,      33    B3
rem 0           0B    8B        /      35    B5
' ------------------------------------------------------------------------------
rem Keypad Keys   Make  Break
rem Pad0(Ins)      52     D2
rem Pad1(End)      4F     CF
rem Pad2(D arrow)  50     D0
rem Pad3(PgDn)     51     D1
rem Pad4(L arrow)  4B     CB
rem Pad5           4C     CC
rem Pad6(R arrow)  4D     CD
rem Pad7(Home)     47     C7
rem Pad8(U arrow)  48     C8
rem Pad9(PgUp)     49     C9
rem Pad.(Del)      53     D3
rem Pad*           37     B7
rem Pad-           4A     CA
rem Pad+           4E     CE
rem ============================================================================
' Paramètres :
' bVK%   : Virtual keycode that has to be send as key input
' bScan% : Scan code is the hardware key code for the key (make and break codes)
' dwFlags% : A set of flag bits that specify various aspects of function operation.
' dwExtraInfo% : 32-bit extra information along with the keyboard input.
SUB Keybd(bVk%,bScan%,dwFlags%,dwExtraInfo%)
   dim_local ret%
   dll_on "user32"                                                        
   ret% = dll_call4("keybd_event",bVk%,bScan%,dwFlags%,dwExtraInfo%)
   dll_off
END_SUB
rem ============================================================================
Papydall-Admin
Papydall-Admin
Admin

Messages : 93
Réputation : 0
Date d'inscription : 08/09/2015
Age : 73
Localisation : MOKNINE (Tunisie)

https://papydall-panoramic.forumarabia.com

Revenir en haut Aller en bas

 Simuler l’appui d'une touche ou combinaison de touches Empty Re: Simuler l’appui d'une touche ou combinaison de touches

Message par Papydall-Admin Sam 16 Sep - 13:58

Code:
rem ============================================================================
rem                  SimulerAppuiTouche
rem                     Par Papydall
rem ============================================================================
REM Simuler l’appui de n’importe quelle touche.
rem Le nombre passé en paramètre correspond au KeyCode de la touche à simuler
rem (par exemple, 44 pour  "imprime écran", 20 pour "capslock")
rem ============================================================================
REM Pour connaitre les codes des touches à envoyer, utilisez le menu "Outils"
rem de Panoramic_Editor, sous-menu "Code des Touches"
rem ============================================================================
Init()
' Simulation de click sur bouton
for i = 97 to 100 : ' code touches 1..4 du panneau numérique
    Appui_touche(i) : pause 1000 : ' Pour simuler l'appui sur les touches 1,2,3,4
next i
pause 1000
Appui_touche(20) : message "Votre PC est en mode capslock"      : ' Pour simuler capslock
Appui_touche(44) : message "La touche impr-ecran a été appuyée" : ' Pour simuler impr-ecran
MESSAGE "Pour vous en convaincre, ouvrez PSPAINT.EXE et faites CRTL + v"
TERMINATE
end
rem ============================================================================
SUB Init()
   label click
   dim i
   for i = 1 to 4
       button i : top i,50 : left i, 10+100*i
       caption i,"Bouton&" + str$(i) : on_click i,click
   next i
END_SUB
rem ============================================================================
Click:
   select number_click
       case 1 : message "Bouton1 cliqué"
       case 2 : message "Bouton2 cliqué"
       case 3 : message "Bouton3 cliqué"
       case 4 : message "Bouton4 cliqué"
   end_select
return  
rem ============================================================================
' bVk% : code de la touche à simuler
' Les autres paramètres (bScan%,dwFlags%,dwExtraInfo%) sont à 0 (zéro)
SUB Keybd(bVk%,bScan%,dwFlags%,dwExtraInfo%)
   dim_local ret%
   dll_on "user32"
   ret% = dll_call4("keybd_event",bVk%,bScan%,dwFlags%,dwExtraInfo%)
   dll_off
END_SUB
rem ============================================================================
SUB Appui_Touche(t%)
   Keybd(t%,0,0,0)
END_SUB
rem ============================================================================
Papydall-Admin
Papydall-Admin
Admin

Messages : 93
Réputation : 0
Date d'inscription : 08/09/2015
Age : 73
Localisation : MOKNINE (Tunisie)

https://papydall-panoramic.forumarabia.com

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum