Keyboard

Post Reply
saviotti
Posts: 43
Joined: Thu Feb 15, 2007 7:45 pm
Location: Brasil
Contact:

Keyboard

Post by saviotti »

Olá a todos,

Alguém saberia me informar, por favor, como faço para emular as teclas F10,F1,ALT+C, etc..

Já tentei com :
__Keyboard (chr (237) )
__Keyboard (VK_F10)
keyboard (chr (237) )
Keyboard (VK_F10)

e não funcionarm.

Obrigado,

Mário Saviotti Jr.
User avatar
Manuel Aranda
Posts: 561
Joined: Wed Oct 19, 2005 8:20 pm
Location: España

Re: Keyboard

Post by Manuel Aranda »

Hola saviotti:

Algunos ejemplos para orientarte:

SetKey(VK_F1, {|nKey| WinHelp("Ayuda.Hlp")})
SetKey(VK_F9, {|nKey| Calculadora() })

oBtn1:bkeydown:={|nKey|IIF((nKey == Asc( "S" ) .OR. nKey == Asc( "s" ) ) .AND. GetKeyState( VK_CONTROL ),;
( lSalvar := .T. , oDlgCodigo:End(), oLBx:refresh() ),)}

Un saludo,
Manuel
saviotti wrote:Olá a todos,

Alguém saberia me informar, por favor, como faço para emular as teclas F10,F1,ALT+C, etc..

Já tentei com :
__Keyboard (chr (237) )
__Keyboard (VK_F10)
keyboard (chr (237) )
Keyboard (VK_F10)

e não funcionarm.

Obrigado,

Mário Saviotti Jr.
saviotti
Posts: 43
Joined: Thu Feb 15, 2007 7:45 pm
Location: Brasil
Contact:

Keyboard

Post by saviotti »

Gracias por responder, mas o lo que necessito é o seguinte :

function ExecutaScript ()

Local aTexto := memoread ("teclas.txt") ,;
nLinhas ,;
aTeclas ,;
lLinhaSistema := .f. ,;
aLinha ,;
I ,;
nContaCaracter ,;
nPos ,;
nPosFinal ,;
aFuncao ,;
aComando

oTimerScript:Deactivate ()

nLinhas := mlcount (aTexto)

for I := 1 to nLinhas

aLinha := alltrim (memoline (aTexto,254,I))

nPos := at (".EXE",upper (aLinha))

aInicial := substr(aLinha,2,4)

do case

case upper (aLinha) == "ENTER"

* ISTO FUNCIONA
KEYBOARD (chr (13) )
//syswait (.2)

case upper (aLinha) == "TAB"

* ISTO FUNCIONA
KEYBOARD (chr (9) )
syswait (.2)

case upper (aLinha) == "F10"

* ISTO NÃO FUNCIONA
__Keyboard (chr (237) )
__Keyboard (chr (VK_F10) )

case upper (aLinha) == "F3"

* ISTO NÃO FUNCIONA
Keyboard (CHR (VK_F3 ) )
Keyboard (CHR (230 ) )

case upper (aLinha) == "F1"

KEYBOARD (chr (228) )
syswait (.2)

case at ("ALT+",aLinha) > 0

nPos := at ("ALT",aLinha)
nPosFinal := at ("+",aLinha)
aComando := asc (substr (aLinha,nPosFinal+1,len (aLinha)))

SysWait (1)
__Keyboard( Chr( VK_END ))
KEYBOARD (chr (ACC_ALT) + chr (aComando) )
//KEYBOARD (chr (254) + chr (aComando) )
//CC SysWait (1)

case at ("TEMPO(",aLinha) > 0

nPos := at ("(",aLinha)
nPosFinal := at (")",aLinha)
nTempo := val (substr (aLinha,nPos+1,nPosFinal-1))
SysWait (nTempo)

OtherWise

for nContaCaracter := 1 to len (aLinha)
aComando := substr (aLinha,nContaCaracter,1)
aComando := asc (aComando)
aComando := chr (aComando)
KeyBoard (aComando)
next

syswait (.1)

endcase

next

lLoginScript := .f.

return .t.
Carlos Mora
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Post by Carlos Mora »

Keyboard( Chr( nKey) ) no te funcionará con valores de nKey > 255.

Que tal un PostMessage( , WM_KEYDOWN, VK_10, 0 ) ?

Eso si funciona en windows.

Saludos,

Carlos
User avatar
Maurilio Viana
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil
Contact:

Re: Keyboard

Post by Maurilio Viana »

Tente Keybd_Event da API do Win32:
[Intenta Keybd_Event desde la API de Win32:]

Code: Select all

DLL function keybd_event(bVk as _INT,bScan as _INT, dwFlags as LONG, dwExtraInfo as LONG ) PASCAL lib "user32.dll"
Esta declaração pode não ser a correta, pois não testei
[Esta declaracion puede no ser la correcta aunque yo no he testeado]

Exemplo [Ejemplo]:

Code: Select all

keybd_event(VK_F3, 0, 0, 0)   // Press F3 key
keybd_event(VK_F3, 0, 2, 0)   // Release F3 key
URL:
http://eric.aling.tripod.com/PB/tips/pbtip36.htm
http://www.codeproject.com/system/keyboard.asp

Antonio, puedes ayudarnos?

Abraços/Saludos
Maurilio
saviotti
Posts: 43
Joined: Thu Feb 15, 2007 7:45 pm
Location: Brasil
Contact:

Keyboard

Post by saviotti »

Gracias,

A conseguido fazer funcionar com :

DLL32 FUNCTION keybd_event ( bVk as _INT,bScan as _INT, dwFlags as LONG, dwExtraInfo as LONG ) AS LONG ;
PASCAL LIB "user32.dll"

Mário
User avatar
Maurilio Viana
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil
Contact:

Re: Keyboard

Post by Maurilio Viana »

Beleza, Mário!!!

Abraços!
Maurilio
Post Reply