hallo leute
habs mal versucht mit sendkeys über winapi bloß da kommt immer blöder fehler wenn ich compilieren will
hier ma code
vielleicht könnt ihr mir ja helfen
gr33tz coderX
habs mal versucht mit sendkeys über winapi bloß da kommt immer blöder fehler wenn ich compilieren will
hier ma code
Code:
// sendkeys.h
BOOL WINAPI SendKeys( UINT FAR *lpKeys, UINT nKeys );
#define SK_KEYDOWN 0x8000
#define SK_SYSKEY 0x4000
// end of file
Listing for sendkeys.c:
// sendkeys.c
#define STRICT
#include <windows.h>
#include "sendkeys.h"
HINSTANCE hInst;
UINT FAR *_lpKeys;
UINT _iKey;
UINT _nKeys;
volatile HHOOK _hHook;
LRESULT CALLBACK _export PlaybackHook( int nCode, WPARAM wParam,
LPARAM lParam )
{
LPEVENTMSG lpEM;
switch(nCode) {
case HC_SKIP:
if( _iKey == _nKeys ) { // no more keys?
// remove hook
UnhookWindowsHookEx(_hHook);
_hHook = NULL;
}
return 0;
case HC_GETNEXT:
lpEM = (LPEVENTMSG)lParam;
if( _lpKeys[_iKey] & SK_KEYDOWN )
lpEM->message = _lpKeys[_iKey] & SK_SYSKEY
? WM_SYSKEYDOWN : WM_KEYDOWN;
else
lpEM->message = _lpKeys[_iKey] & SK_SYSKEY
? WM_SYSKEYUP : WM_KEYUP;
lpEM->paramL = LOBYTE(_lpKeys[_iKey])
| (MapVirtualKey(LOBYTE(_lpKeys[_iKey]),0)<<8);
lpEM->paramH = 1;
lpEM->time = GetCurrentTime();
_iKey++;
return 0;
default:
return CallNextHookEx(_hHook,nCode,wParam,lParam);
}
}
#define KeyDown( uKey ) ( GetAsyncKeyState(uKey) & 0x8000 )
BOOL WINAPI _export SendKeys( UINT FAR *lpKeys, UINT nKeys )
{
_lpKeys = lpKeys;
_iKey = 0;
_nKeys = nKeys;
if( _hHook )
return FALSE;
while( KeyDown(VK_MENU) || KeyDown(VK_SHIFT)
|| KeyDown(VK_CONTROL) ) {
MSG msg;
if( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) {
if( msg.message == WM_QUIT ) {
PostMessage(msg.hwnd,msg.message,msg.wParam,msg.lParam);
return FALSE;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
_hHook = SetWindowsHookEx(WH_JOURNALPLAYBACK,
PlaybackHook,hInst,NULL);
if(!_hHook) return FALSE;
// while hook is installed, pump messages
while(_hHook) {
MSG msg;
if( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) {
if( msg.message == WM_QUIT ) {
if( _hHook )
UnhookWindowsHookEx(_hHook);
PostMessage(msg.hwnd,msg.message,msg.wParam,msg.lParam);
return FALSE;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return TRUE;
}
#pragma argsused
int FAR PASCAL LibMain( HINSTANCE hInstance, WORD wDataSeg,
WORD cbHeapSize, LPSTR lpCmdLine)
{
hInst = hInstance;
return 1;
}
#pragma argsused
int CALLBACK _export WEP( int n )
{
if( _hHook ) {
UnhookWindowsHookEx(_hHook);
_hHook = NULL;
}
return 1;
}
vielleicht könnt ihr mir ja helfen
gr33tz coderX