TECLA DE ATALHO EXECUCAO DE FUNCAO EM APLICATIVO

CUNHA75 23/03/2004 11:21:59
#16579
Caros amigos, estou a fazer um aplicativo de conversões de moedas, porém o programa está a rodar no systray, e o que pretendo é por exemplo, estar a trabalhar no word ou outro programa qualquer, e apertando por xemplo CTRL + H, ele assumisse o valor seleccionado e abri-se o meu programa com esse valor para ser convertido. Tipo Babylon.
CAJU 23/03/2004 11:39:21
#16587
Resposta escolhida
'In a module
Public Const WH_KEYBOARD = 2
Public Const VK_Ctrl = &H11
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public hHook As Long
Public Function KeyboardProc(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'if idHook is less than zero, no further processing is required
If idHook 0 Then
'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, ByVal lParam)
Else
'check if SHIFT-S is pressed
If (GetKeyState(VK_Ctrl) And &HF0000000) And wParam = Asc("H") Then
'show the result
Form1.Print "CONTROL+H pressed ..."
End If
'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, ByVal lParam)
End If
End Function

'In a form, called Form1
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'set a keyboard hook
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc, App.hInstance, App.ThreadID)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'remove the windows-hook
UnhookWindowsHookEx hHook
End Sub
CAJU 23/03/2004 20:45:26
#16735
nesse caso vc deve fazer:

quando vc clicar CTRL+H

'vc verifica se existe algo na area de trranferecia... pois vc nao vai querer que o usurario se prejudique...
If Clipboard.GetText DIFERENTE Empty Then
strcli = clipboard.gettext
end if

'ae vc coloca o texto selecionado na area de tranferencia(API)
'e quando seu programa abrir vc cola a area de transferencia e deepois vc devolve o original....

Deu pra clarear?

Tópico encerrado , respostas não são mais permitidas