Anmeldungsdatum: Jul 2014
Beiträge: 12
Benutzer-Bewertung:
|
Hab's. Ich poste mal mein Resultat. Danke für eure Hilfe!
@Knacker, da ich mich nun intensiver mit dem OSHGui beschäftigen werde und sicher Bugs finden werde: hast du inzwischen einen Tracker oder soll das hier ins Forum? (nutze den letzten Trunk)
TEXT Code: void Gui::Toggle() { auto app = Application::Instance(); int width, height; SDK::Engine->GetScreenSize(width, height); POINT result; if (app->IsEnabled()) { hookGetCursorPos_(&mousePosOpen_); result = { width / 2, height / 2 }; ClientToScreen(GetForegroundWindow(), &result); } else { result = mousePosOpen_; } hookSetCursorPos_(result.x, result.y); app->Toggle(); } class ErsteForm : public Form { private: Button *ersterButton; void InitializeComponent() { this->SetText("ErsteForm"); ersterButton = new Button(); ersterButton->SetText("klick mich"); ersterButton->GetClickEvent() += ClickEventHandler(std::bind(&ErsteForm::ersterButton_Click, this, std::placeholders::_1)); this->AddControl(ersterButton); } public: ErsteForm() { InitializeComponent(); } private: void ersterButton_Click(Control *sender) { MessageBox::Show("Ich wurde angeklickt!"); } }; HRESULT WINAPI Gui::EndScene(LPDIRECT3DDEVICE9 pDevice) { Application *app = Application::Instance(); if (!Implode::Gui->initialized_) { Implode::Gui->initialized_ = true; Implode::Gui->messageHookHandle_ = SetWindowsHookExW(WH_GETMESSAGE, MessageHook, 0, GetCurrentThreadId()); app->Create(new Drawing::RendererDX9(pDevice)); int width, height; SDK::Engine->GetScreenSize(width, height); app->GetRenderer()->SetRenderRectangle(Drawing::Rectangle(0, 0, width, height)); app->Run(std::shared_ptr<Form>(new ErsteForm())); } if (SDK::Engine->IsConnected() && SDK::Engine->IsInGame() && !SDK::Engine->Con_IsVisible() && !SDK::Engine->IsLevelMainMenuBackground()) { app->GetRenderer()->Begin(); Implode::ClientHooks->EndScene(pDevice, app->GetRenderer()); app->Render(); app->GetRenderer()->End(); } return Implode::Gui->hookEndScene_(pDevice); } LRESULT CALLBACK Gui::MessageHook(int code, WPARAM wParam, LPARAM lParam) { if (lParam & 0x80000000 || lParam & 0x40000000) { return CallNextHookEx(Implode::Gui->messageHookHandle_, code, wParam, lParam); } if (code == HC_ACTION) { if (reinterpret_cast<LPMSG>(lParam)->message == WM_MOUSEMOVE) { return 0; } if (Implode::Gui->input_.ProcessMessage(reinterpret_cast<LPMSG>(lParam))) { return 1; } } return CallNextHookEx(Implode::Gui->messageHookHandle_, code, wParam, lParam); } BOOL WINAPI Gui::SetCursorPos(int X, int Y) { Implode::Gui->mousePos_ = { X, Y }; if (Application::Instance()->IsEnabled() && SDK::Engine->IsConnected() && SDK::Engine->IsInGame() && !SDK::Engine->Con_IsVisible() && !SDK::Engine->IsLevelMainMenuBackground()) { POINT point; Implode::Gui->hookGetCursorPos_(&point); ScreenToClient(GetForegroundWindow(), &point); Application::Instance()->ProcessMouseMessage(MouseMessage(MouseMessage::Move, MouseButton::None, Drawing::Point(point.x, point.y), 0)); return 0; } return Implode::Gui->hookSetCursorPos_(X, Y); } BOOL WINAPI Gui::GetCursorPos(LPPOINT lpPoint) { auto active = Implode::Gui->hookGetCursorPos_(lpPoint); if (Application::Instance()->IsEnabled() && SDK::Engine->IsConnected() && SDK::Engine->IsInGame() && !SDK::Engine->Con_IsVisible() && !SDK::Engine->IsLevelMainMenuBackground()) { lpPoint->x = Implode::Gui->mousePos_.x; lpPoint->y = Implode::Gui->mousePos_.y; } return active; } int __fastcall ClientHooks::IN_KeyEvent(void *pThis, int edx, int eventcode, ButtonCode_t keynum, const char *pszCurrentBinding) { if (keynum == ButtonCode_t::KEY_INSERT && eventcode) { Implode::Gui->Toggle(); } if (OSHGui::Application::Instance()->IsEnabled()) { return 0; } return Implode::ClientHooks->vmtManager_->GetMethod<IN_KeyEvent_t>(OffsetIN_KeyEvent)(pThis, eventcode, keynum, pszCurrentBinding); }
|