Foros del Web » Programación para mayores de 30 ;) » Programación General »

ayuda con aplicacion simple

Estas en el tema de ayuda con aplicacion simple en el foro de Programación General en Foros del Web. Necesito crear una aplicacion o Macro q al apretar una Tecla Ejemplo F8 haga un SendKeys o lo que sea sobre otra: si apreto F8 ...
  #1 (permalink)  
Antiguo 02/02/2004, 02:59
 
Fecha de Ingreso: noviembre-2003
Mensajes: 28
Antigüedad: 20 años, 4 meses
Puntos: 0
Pregunta ayuda con aplicacion simple

Necesito crear una aplicacion o Macro q al apretar una Tecla Ejemplo F8 haga un SendKeys o lo que sea sobre otra:


si apreto F8 hace:

HOLA!!!
ENTER(Tecla)
Como estas?

PERO OJO!!!!! tiene q funcionar sobre otra aplicacion. EJEMPLO:

ABRO MI programa y luego abro el block de notas, y yo apreto F8 sobre el block y tiene q escribir SOBRE él ( o sino otro programa que contenga un campo de texto)

Hola!!!
ENTER(Tecla)
Como estas?

Probe con miles de cosas y formas y todas me fallan ya q no funcionan sobre otra aplicacion q no sea en la q hice el macro.

Creo q me Exprese Claro desde ya muchisimas gracias y si me responden mil GRACIAS XD

Última edición por Taiku; 02/02/2004 a las 03:01
  #2 (permalink)  
Antiguo 02/02/2004, 10:24
 
Fecha de Ingreso: febrero-2004
Mensajes: 36
Antigüedad: 20 años, 2 meses
Puntos: 0
Creo que yo tengo la solucion, tienes que utilizar un contador para que despues de un tiempo de enter y el mensaje al final.
  #3 (permalink)  
Antiguo 11/02/2004, 10:29
 
Fecha de Ingreso: febrero-2004
Mensajes: 36
Antigüedad: 20 años, 2 meses
Puntos: 0
hay te va

if sendkeys="{f8}" then
sendkeys "HOLA"
end if
  #4 (permalink)  
Antiguo 11/02/2004, 12:26
Avatar de lic_dahool  
Fecha de Ingreso: noviembre-2003
Mensajes: 418
Antigüedad: 20 años, 5 meses
Puntos: 0
el problema que tenes es que la aplicacion solo intercepta si presionas una tecla sobre si misma, pero no intercepta cuando presionas una tecla sobre otra aplicacion, para esto te paso un codigo que puede ser de mucha utilidad (tomado de www.allapi.net y lo transcribo tal cual)

'-------------INICIO-----------------------------------------

'In a module
Public Const DT_CENTER = &H1
Public Const DT_WORDBREAK = &H10
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hDC As Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As Long, ByVal lpDrawTextParams As Any) As Long
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Global Cnt As Long, sSave As String, sOld As String, Ret As String
Dim Tel As Long
Function GetPressedKey() As String
For Cnt = 32 To 128
'Get the keystate of a specified key
If GetAsyncKeyState(Cnt) <> 0 Then
GetPressedKey = Chr$(Cnt)
Exit For
End If
Next Cnt
End Function
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Ret = GetPressedKey
If Ret <> sOld Then
sOld = Ret
sSave = sSave + sOld
End If
End Sub

'In a form
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Me.Caption = "Key Spy"
'Create an API-timer
SetTimer Me.hwnd, 0, 1, AddressOf TimerProc
End Sub
Private Sub Form_Paint()
Dim R As RECT
Const mStr = "Start this project, go to another application, type something, switch back to this application and unload the form. If you unload the form, a messagebox with all the typed keys will be shown."
'Clear the form
Me.Cls
'API uses pixels
Me.ScaleMode = vbPixels
'Set the rectangle's values
SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
'Draw the text on the form
DrawTextEx Me.hDC, mStr, Len(mStr), R, DT_WORDBREAK Or DT_CENTER, ByVal 0&
End Sub
Private Sub Form_Resize()
Form_Paint
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Kill our API-timer
KillTimer Me.hwnd, 0
'Show all the typed keys
MsgBox sSave
End Sub

'-------------- FIN -------------------------

en este caso almacena y muestra en pantalla todas las teclas alfanumericas que se presionan, pero con algunas modificaciones podes lograr tu proposito.

saludos.
__________________
La cantidad total de inteligencia del planeta permanece constante.
La población, sin embargo, sigue aumentando.

COLE


:cool: Los ordenadores no resuelven problemas ... ejecutan soluciones.
Laurent Gasser


Tienes alguna duda :pensando: ? >>> www.google.com :aplauso: <<<
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:12.