|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2011-6-29 15:45:49
|
显示全部楼层
继续求助……,期待高人出现
玩WINDOWS游戏,上网全部没问题。
但点击桌面或者WINDOWS文件夹只能响应一次。
代码如下,用空格键模拟鼠标左键。
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "windows.h"
#include "shellapi.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#include <Mmsystem.h>
//---------------------------------------------------------------------------
TForm1 *Form1;
int f;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void WINAPI _timeSetEvent(UINT uTimerID,UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
POINT lpPoint;
GetCursorPos(&lpPoint);
SetCursorPos(lpPoint.x, lpPoint.y);
if(GetAsyncKeyState(VK_SPACE)&0x8000 )
{
if(f==0)
{
f=1;
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
}
}
else
{
if(f==1)
{
f=0;
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
}
}
void __fastcall TForm1::FormShow(TObject *Sender)
{
MMRESULT mr = timeSetEvent( 15,1, _timeSetEvent,0,TIME_PERIODIC); //15MS回调
f=0;
}
//--------------------------------------------------------------------------- |
|