Link to home
Start Free TrialLog in
Avatar of S-L-D-
S-L-D-

asked on

Anyone know how to identify a key pressed if my Form isnt Activated???

I think it I want will bo not hard for You :)

Well... i Need a Code or a API that identify a key pressed (for example in MS WORD). I would like that key be showed in my (textbox , for example). Can anyone help me please??? Ill be so much thanks :o)

Cya all

*** Sorry for the bad english.
Avatar of S-L-D-
S-L-D-

ASKER

Thanks
you have to hook another program to get keypresses
if its another thread then the hook provedure must be in a DLL file, so you have to know how to create a DLL
basically all you do is use
SetWindowsHookEx with type WH_KEYBOARD type (you cant alter the keys this way, to alter keys you set a WH_GETMESSAGE hook and change the calues of the keys from wm_char)
first you need to get the process id of the application, you get the hwnd which im asuming you know how to do. FindWindow and FindWindwEx if you dont know..
use
GetWindowThreadProcessID(handle,processID)
process id is passed byref and in vb id say its a long value, its a DWORD in c++
then you use that for the thread id
in the dll you would make a StartHook function to star it
in that function
SetWindowsHookEx(WH_KEYBOARD,addressof MyKeyBoardProc,dllinstance,processID)
you ge tthe dllinstance when the dll loads, you know or you'll see when you learn how to make one :o\
then also in the dll you have to have a keyboard proc
in c++ it's
LRESULT CALLBACK MyKeyBoardProc(int code,WPARAM wParam,LPARAM lParam);
so in VB i would write
function MyKeyBoardProc(code as integer,wParam as long,lparam as long) as long
thats where the data is passed, all keyboard info will go through that function before it goes to the window you hooked.
i forgot you have to also unhook the window with UnhookWindowsHookEx(long value you got from setwindowshook)
hook = SetwindowsHookEx(.....)
then later on
UnhookWindowsHookEx(hook);
Avatar of S-L-D-

ASKER

im so thanks PlanetCpp, but im a newbie yet, i dont know how to do it and i dont know this forum yes... im a little lost in all of that.

Maybe anyone can get some code here??? plz... ill be so thanks
Avatar of S-L-D-

ASKER

im so thanks PlanetCpp, but im a newbie yet, i dont know how to do it and i dont know this forum yes... im a little lost in all of that.

Maybe anyone can get some code here??? plz... ill be so thanks
ASKER CERTIFIED SOLUTION
Avatar of spauljoseph
spauljoseph
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of S-L-D-

ASKER

:)
im so happy now!!! All you in this forum is really cool :)

ill continue trying to know more about vb and about this forum... so much thx for now... and the next time I ll try to know how functions have this "points" in this forum :)

especial thx to who helped me at my first time here

byebye
Cu later