//今天写了个游戏自动喊话器(功能较少,还在完善):
/************************************************************************/
/* 文件1 :AsktaoApp.h */
/************************************************************************/
#include "wx.h"
class MAPP : public wxApp
{
public:
virtual bool OnInit();
};
/************************************************************************/
/* 文件2 :AsktaoApp.h */
/************************************************************************/
#ifndef __FRAME__
#define __FRAME__
#include <wx/string.h>
#include <wx/menu.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/frame.h>
#include "wx.h"
#define wxID_MENU 1000
class AsktaoFrame : public wxFrame
{
private:
DECLARE_EVENT_TABLE()
protected:
wxMenuBar* m_menubar;
wxPanel* m_panel;
wxButton* m_button_OK;
public:
AsktaoFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,150 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
void OnButtonOK(wxCommandEvent& event);
~AsktaoFrame();
};
#endif
/************************************************************************/
/* 文件3 :wx.h */
/************************************************************************/
#ifndef WX
#define WX
#include <wx/wx.h>
#endif
/************************************************************************/
/* 文件4 :AsktaoApp.cpp */
/************************************************************************/
#include "AsktaoApp.h"
#include "Frame.h"
bool MAPP::OnInit()
{
AsktaoFrame* frame = new AsktaoFrame(NULL, wxID_ANY, wxT("游戏自动喊话器"));
frame->Show(true);
return true;
}
DECLARE_APP(MAPP)
IMPLEMENT_APP(MAPP)
/************************************************************************/
/* 文件5 :Frame.cpp */
/************************************************************************/
#include "Frame.h"
/************************************************************************/
/* EVENT TABLE */
/************************************************************************/
BEGIN_EVENT_TABLE(AsktaoFrame,wxFrame)
EVT_BUTTON(wxID_OK,AsktaoFrame::OnButtonOK)
END_EVENT_TABLE()
/************************************************************************/
AsktaoFrame::AsktaoFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
this->SetExtraStyle( wxFRAME_EX_CONTEXTHELP|wxFRAME_EX_METAL );
m_menubar = new wxMenuBar( 0 );
this->SetMenuBar( m_menubar );
wxBoxSizer* bSizer_Main;
bSizer_Main = new wxBoxSizer( wxVERTICAL );
m_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_button_OK = new wxButton( m_panel, wxID_OK, wxT("开始"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_button_OK, 1, wxALL|wxALIGN_RIGHT|wxEXPAND, 5 );
bSizer3->Add( bSizer4, 1, wxALL|wxEXPAND, 5 );
m_panel->SetSizer( bSizer3 );
m_panel->Layout();
bSizer3->Fit( m_panel );
bSizer_Main->Add( m_panel, 1, wxEXPAND, 5 );
this->SetSizer( bSizer_Main );
this->Layout();
}
void AsktaoFrame::OnButtonOK(wxCommandEvent& event)
{
size_t SleepTime = 0;
srand(time(NULL));
while (true)
{
SleepTime = rand() % 4;
Sleep(SleepTime*1000);
keybd_event(VK_CONTROL, (BYTE)0, 0 ,0);
keybd_event('V',(BYTE)0, 0 ,0); //此处可以用 'A', (BYTE)65, 用'a'不起作用
keybd_event('V', (BYTE)0, KEYEVENTF_KEYUP,0);
keybd_event(VK_CONTROL, (BYTE)0, KEYEVENTF_KEYUP,0);
keybd_event(VK_RETURN,(BYTE)0, 0, 0);
keybd_event(VK_RETURN,(BYTE)0, KEYEVENTF_KEYUP, 0);
}
/*
if (m_textCtrl_Words->IsEmpty())
wxMessageBox(wxT("请输入文本内容!"),wxT("提醒!"));*/
}
AsktaoFrame::~AsktaoFrame()
{
}