Faire croire à un programme qu'on appui sur le clavier
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
Faire croire à un programme qu'on appui sur le clavier
Salut,
Comment faire pour faire croire à un programe que l'on appui sur une touches ?
Merci
Comment faire pour faire croire à un programe que l'on appui sur une touches ?
Merci
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
bon, la solution :
Code : Tout sélectionner
Procedure Clavier(WindowID, Touche)
SetForeGroundWindow_(WindowID)
UpdateWindow_(WindowID)
If OpenLibrary(0, "user32.dll")
CallFunction(0, "keybd_event", Touche, 0, 0, 0)
CallFunction(0, "keybd_event", Touche, 0, #KEYEVENTF_KEYUP, 0)
CloseLibrary(0)
EndIf
EndProcedure
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
mince et zut zut et zut.
ça marche pas avec les boutons control et alt
normalement, j'envoie la touche Ctrl + N donc j'ouvre un nouveau fichier mais ça écrit simplement N dans le code.
ça marche pas avec les boutons control et alt
Code : Tout sélectionner
Procedure Clavier(WindowID, Touche)
SetForeGroundWindow_(WindowID)
UpdateWindow_(WindowID)
If OpenLibrary(0, "user32.dll")
If Touche & #PB_Shortcut_Control
CallFunction(0, "keybd_event", #PB_Shortcut_Control, 0, #KEYEVENTF_EXTENDEDKEY, 0)
Touche = Touche ! #PB_Shortcut_Control
CallFunction(0, "keybd_event", Touche, 0, 0, 0)
CallFunction(0, "keybd_event", Touche, 0, #KEYEVENTF_KEYUP, 0)
CallFunction(0, "keybd_event", #PB_Shortcut_Control, 0, #KEYEVENTF_EXTENDEDKEY | #KEYEVENTF_KEYUP, 0)
ElseIf Touche & #PB_Shortcut_Alt
CallFunction(0, "keybd_event", #PB_Shortcut_Alt, 0, #KEYEVENTF_EXTENDEDKEY, 0)
Touche = Touche ! #PB_Shortcut_Alt
CallFunction(0, "keybd_event", Touche, 0, 0, 0)
CallFunction(0, "keybd_event", Touche, 0, #KEYEVENTF_KEYUP, 0)
CallFunction(0, "keybd_event", #PB_Shortcut_Alt, 0, #KEYEVENTF_EXTENDEDKEY | #KEYEVENTF_KEYUP, 0)
Else
CallFunction(0, "keybd_event", Touche, 0, 0, 0)
CallFunction(0, "keybd_event", Touche, 0, #KEYEVENTF_KEYUP, 0)
EndIf
CloseLibrary(0)
EndIf
EndProcedure
; Procedure Clavier(WindowID, Touche)
; SetForeGroundWindow_(WindowID)
; UpdateWindow_(WindowID)
; If OpenLibrary(0, "user32.dll")
; CallFunction(0, "keybd_event", Touche, 0, , 0)
; CallFunction(0, "keybd_event", Touche, 0, #KEYEVENTF_KEYUP, 0)
; CloseLibrary(0)
; EndIf
; EndProcedure
Delay(1000)
WindowE = GetForegroundWindow_()
OpenWindow(0, 200, 200, 500, 500, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, "Options")
; PostMessage_(WindowE, #WM_KEYDOWN, #PB_Shortcut_N, 0)
clavier(WindowE, #PB_Shortcut_Control | #PB_Shortcut_N)
Repeat
Event = WaitWindowEvent()
Until Event = #WM_CLOSE
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
bon, j'ai trouvé la fonction
le problème est le suivant, j'ai pas la valuer des constantes et j'ai pas la librairie qui contient cette fonction. ouin, j'arrive à rien
j'ai fait ce code et je peux pas le tester :
http://msdn.microsoft.com/library/defau ... eydown.aspPostKeybdMessage
This function posts a keyboard message to the specified window.
BOOL PostKeybdMessage(
HWND hwnd,
UINT VKey,
KEY_STATE_FLAGS KeyStateFlags,
UINT cCharacters,
UINT *pShiftStateBuffer,
UINT *pCharacterBuffer );
Parameters
hwnd
[in] Handle to the window that receives the message. It must identify a window owned by the calling thread. If hwnd is NULL, then the keyboard message is sent to the active window or window with the focus of the calling thread. If hwnd is –1, then the keyboard message is sent to the active window or window with the focus of the system foreground thread.
VKey
[in] Virtual key code. This parameter can be set to 0.
KeyStateFlags
[in] State of the key. The key states are described in the following table. Flag Description
KeyStateToggledFlag Key is toggled.
KeyStatePrevDownFlag Key was previously down.
KeyStateDownFlag Key is currently down.
KeyShiftAnyCtrlFlag Left or right CTRL key is down.
KeyShiftAnyShiftFlag Left or right SHIFT key is down.
KeyShiftAnyAltFlag Left or right ALT key is down.
KeyShiftCapitalFlag VK_CAPITAL is toggled.
KeyShiftLeftCtrlFlag Left CTRL key is down.
KeyShiftLeftShiftFlag Left SHIFT key is down.
KeyShiftLeftAltFlag Left ALT key is down.
KeyShiftLeftWinFlag Left Windows logo key is down.
KeyShiftRightCtrlFlag Right CTRL key is down.
KeyShiftRightShiftFlag Right SHIFT key is down.
KeyShiftRightAltFlag Right ALT key is down.
KeyShiftRightWinFlag Right Windows logo key is down
KeyShiftDeadFlag Corresponding character is dead character.
KeyShiftNoCharacterFlag No characters in pCharacterBuffer to translate.
cCharacters
[in] Number of characters in the pCharacterBuffer array.
pCharacterBuffer
[in] Pointer to a buffer that contains the characters to send. This parameter cannot be NULL.
pShiftStateBuffer
[in] Pointer to a buffer that contains a corresponding shift state entry for each character in the pCharacterBuffer array. The shift state for each character must be the same as the KeyStateFlags parameter. This parameter cannot be NULL.
le problème est le suivant, j'ai pas la valuer des constantes et j'ai pas la librairie qui contient cette fonction. ouin, j'arrive à rien

j'ai fait ce code et je peux pas le tester :
Code : Tout sélectionner
Procedure Clavier(WindowID, Touche)
If OpenLibrary(0, "user32.dll")
KeyState = #KeyStateDownFlag
If Touche & #PB_Shortcut_Control
Touche = Touche & #PB_Shortcut_Control
KeyState = KeyState | #KeyShiftAnyCtrlFlag
ElseIf Touche & #PB_Shortcut_Alt
Touche = Touche & #PB_Shortcut_Alt
KeyState = KeyState | #KeyShiftAnyAltFlag
EndIf
CallFunction("PostKeybdMessage", WindowID, 0, KeyState, 1, @Touche, @Touche)
closelibrairy(0)
EndIf
EndProcedure
Delay(1000)
WindowE = GetForegroundWindow_()
; PostMessage_(WindowE, #WM_KEYDOWN, #PB_Shortcut_N, 0)
clavier(WindowE, #PB_Shortcut_Control | #PB_Shortcut_N)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
-
- Messages : 4312
- Inscription : mer. 28/janv./2004 20:58
- Localisation : Clermont ferrand OU Olsztyn
- Contact :
J'ai finit par trouvé, et tout seul comme un grand

Code : Tout sélectionner
Procedure KeyBoardEvent(WindowID, Touche, ToucheSpecial)
; WindowID : fenêtre qui va recevoir la touche
; Touche : Touche appuyée, voir constantes PB dans l'aide de AddKeyboardShortcut()
; ToucheSpecial :
; = 1 si touche Control appuyée
; = 2 si touche Alt appuyée
; = 0 sinon
SetForeGroundWindow_(WindowID)
If OpenLibrary(0, "user32.dll")
Select ToucheSpecial
Case 1
CallFunction(0, "keybd_event", #VK_CONTROL, 0, 0, 0)
Case 2
CallFunction(0, "keybd_event", #VK_MENU, 0, 0, 0)
EndSelect
CallFunction(0, "keybd_event", Touche, 0, 0, 0)
Delay(10)
CallFunction(0, "keybd_event", Touche, 0, #KEYEVENTF_KEYUP, 0)
Select ToucheSpecial
Case 1
CallFunction(0, "keybd_event", #VK_CONTROL, 0, #KEYEVENTF_KEYUP, 0)
Case 2
CallFunction(0, "keybd_event", #VK_MENU, 0, #KEYEVENTF_KEYUP, 0)
EndSelect
CloseLibrary(0)
EndIf
EndProcedure
; Debut du test
Delay(1000)
WindowE = GetForegroundWindow_()
KeyBoardEvent(WindowE, #PB_Shortcut_N, 1)
KeyBoardEvent(WindowE, #PB_Shortcut_Z, 0)
KeyBoardEvent(WindowE, #PB_Shortcut_U, 0)
KeyBoardEvent(WindowE, #PB_Shortcut_T, 0)
KeyBoardEvent(WindowE, #PB_Shortcut_A, 2)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
j'ai bien regardé cet exemple mais je me demande comment
on peut avoir la liste des éléments contenus dans une DLL?
a savoir que moi je veux simuler un appuie sur ENTREE
et que j'ai essayé à taton des paramètres...et qu'il me dit que ça
n'existe pas
y a pas un lexique de la DLL?
sinon quel mot magique je dois lui demander? ...ENTER, ...RETURN...??
on peut avoir la liste des éléments contenus dans une DLL?
a savoir que moi je veux simuler un appuie sur ENTREE
et que j'ai essayé à taton des paramètres...et qu'il me dit que ça
n'existe pas
y a pas un lexique de la DLL?
sinon quel mot magique je dois lui demander? ...ENTER, ...RETURN...??