Keyboard

Keyboard

Postby saviotti » Mon Apr 09, 2007 7:40 pm

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

Re: Keyboard

Postby Manuel Aranda » Mon Apr 09, 2007 8:05 pm

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.
User avatar
Manuel Aranda
 
Posts: 604
Joined: Wed Oct 19, 2005 8:20 pm
Location: España

Keyboard

Postby saviotti » Mon Apr 09, 2007 10:03 pm

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.
saviotti
 
Posts: 43
Joined: Thu Feb 15, 2007 7:45 pm
Location: Brasil

Postby Carlos Mora » Tue Apr 10, 2007 2:14 pm

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
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Keyboard

Postby Maurilio Viana » Tue Apr 10, 2007 2:18 pm

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

Code: Select all  Expand view  RUN
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  Expand view  RUN
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
User avatar
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil

Keyboard

Postby saviotti » Tue Apr 10, 2007 3:54 pm

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
saviotti
 
Posts: 43
Joined: Thu Feb 15, 2007 7:45 pm
Location: Brasil

Re: Keyboard

Postby Maurilio Viana » Tue Apr 10, 2007 5:09 pm

Beleza, Mário!!!

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


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 20 guests