Minibug
Nombre de messages : 4566 Age : 57 Localisation : Vienne (86) Date d'inscription : 09/02/2012
| Sujet: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 18:26 | |
| Bonsoir à tous !
Un petite question toute simple : Savez vous comment intercepter les touches du clavier sans se préoccuper de l'objet ayant le focus ? Il y a bien SCANCODE mais il nécessite une boucle sans fin. je ne suis pas trop pour.
En fait je souhaite mettre en œuvre des raccourci clavier comme CTRL+F , CTRL+R , etc... Qui doivent répondre à tous moments et sur n'importe quel objet.
Je souhaite le faire en Panoramic pure sans dll. Avez vous une idée sur la façon de procéder ?
Dernière édition par Minibug le Lun 28 Mai 2018 - 10:22, édité 1 fois | |
|
papydall
Nombre de messages : 6996 Age : 73 Localisation : Moknine (Tunisie) Entre la chaise et le clavier Date d'inscription : 03/03/2012
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 18:40 | |
| Hello Minibug. Etudie ce code , peut-être te sera-t-il utile. - 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 ============================================================================
Ce code a été posté sur ce post | |
|
Marc
Nombre de messages : 2379 Age : 63 Localisation : TOURS (37) Date d'inscription : 17/03/2014
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 19:05 | |
| J'opterais pour le couple ON_KEY_DOWN et KEY_DOWN_SPECIAL voire KEY_DOWN_CODE.
Le ON_KEY_DOWN devant être assigné à un LABEL et à tous les objets où tu souhaites qu'il soit actif.
Si tu as 5 objets, il faudra déclarer 5 fois ON_KEY_DOWN.
Mais tout ça tu le sais déjà.
La même chose existe avec le UP. L'action se fait alors quand on lâche la touche.
| |
|
Minibug
Nombre de messages : 4566 Age : 57 Localisation : Vienne (86) Date d'inscription : 09/02/2012
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 19:12 | |
| Merci à tous les 2 !
Le problème du ON_KEY_DOWN et compagnie c'est qu'il faut le déclarer sur tous les objets. Et là c'est compliqué... il faut prendre en compte les EDIT, BOUTON, PANEL, etc... et encore je ne suis pas sûr que le ON_KEY_DOWN fonctionne sur tous les objets...
Concernant le code de Papydall, il faut que je regarde de plus près... | |
|
Jean Claude
Nombre de messages : 5948 Age : 69 Localisation : 83 Var Date d'inscription : 07/05/2009
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 20:34 | |
| Bonsoir,
@Minibug,
Tu trouveras sur mon Webdav un ZIP nommé "Minimal_Editor_Panoramic". Charge le fichier.bas et lance une recherche sur le label "touche:"
Vois si tu peux en tirer quelque-chose. Bon, ce système utilise un TIMER, cela t'obligera à désactiver ce TIMER à chaque sous programmes et à le réactiver. Il y a aussi une gestion des touches de fonction (F1, F3, F4, F9, F11) avec ce même timer.
A toi de voir....
A+ | |
|
silverman
Nombre de messages : 968 Age : 51 Localisation : Picardie Date d'inscription : 18/03/2015
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 20:36 | |
| - Minibug a écrit:
- Le problème du ON_KEY_DOWN et compagnie c'est qu'il faut le déclarer sur tous les objets.
En pur panoramic, il n'y a pas d'autres solution, c'est comme ça que je fais dans mon editeur. | |
|
Jean Claude
Nombre de messages : 5948 Age : 69 Localisation : 83 Var Date d'inscription : 07/05/2009
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 20:55 | |
| Oui et à y regarder de près, il n'y a pas tant d'objet que ça dans un éditeur comme PanExpress où il faut déclarer ON_KEY_DOW.
Le SYNEDIT possède déjà les raccourcis claviers en natif. Il reste certain SUB_MENU à traiter, mais pas tous. Si on prend PanoramicEditor il y en a que dans le menu "Edition"
A+ | |
|
Marc
Nombre de messages : 2379 Age : 63 Localisation : TOURS (37) Date d'inscription : 17/03/2014
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Dim 27 Mai 2018 - 21:25 | |
| Je viens de faire quelques essais : les actions devraient être effectives quand on relâche le bouton de la souris.
Il faudrait donc utiliser le UP : - ON_KEY_UP - KEY_UP_CODE - KEY_UP_SPECIAL | |
|
Minibug
Nombre de messages : 4566 Age : 57 Localisation : Vienne (86) Date d'inscription : 09/02/2012
| |
Marc
Nombre de messages : 2379 Age : 63 Localisation : TOURS (37) Date d'inscription : 17/03/2014
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic Lun 28 Mai 2018 - 15:11 | |
| Salut MiniBug ! [résolu] La Force est avec toi ! | |
|
Contenu sponsorisé
| Sujet: Re: [Résolu] Interception touches quel que soit objet Panoramic | |
| |
|