.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   keybd_event (http://forums.bots-united.com/showthread.php?t=4527)

gavin 27-09-2005 21:54

Re: keybd_event
 
Ya thats basically it man thanks.

Lazy 27-09-2005 22:40

Re: keybd_event
 
Hmm, it doesn't look like quake2 accepts keyboard input using window messages and I'm pretty sure Half-Life will be the same.
Though I could have sworn I did something similar, oh well.

Sorry but other then getting into half-life's address space and doing things from there I cannot figure out how else to do this.

gavin 27-09-2005 22:43

Re: keybd_event
 
Hey np man.
I'll try figure this out , unless i get sick of it.
Thanks anyways .

Austin 05-10-2005 08:34

Re: keybd_event
 
I wrote this hack to monitor my cz dedicated server and restart it.
The part that may interest you is I look for the error message box window and "press" the ok button by sending it a space bar down and space bar up using PostMessage() . You can do the same for any key....

Code:

void CFindNBWindowDlg::OnTimer(UINT nIDEvent)
{   
    HWND nbWindow, buttonWindow;

    nbWindow = ::FindWindow(NULL, "Fatal error - Dedicated server");
    if (::IsWindow(nbWindow))
    {
        buttonWindow = ::FindWindowEx(nbWindow, NULL, "Button", "Ok");
        if (::IsWindow(buttonWindow))
        {
            Log(" Fatal Error window close.\n");
            //::SetForegroundWindow(buttonWindow);
            ::PostMessage(buttonWindow, WM_KEYDOWN, (WPARAM)VK_SPACE, (LPARAM)0);
            ::PostMessage(buttonWindow, WM_KEYUP, (WPARAM)VK_SPACE, (LPARAM)0);
        }
    }
    else
    {
        nbWindow = ::FindWindow(NULL, "Console");
        if (!::IsWindow(nbWindow))
        {
            Log(" Restart.\n");
            Sleep(4000);
            WinExec("C:\\HLServer\\hlds.exe -game czero -noipx -nojoy -console", SW_SHOWMINIMIZED);
        }
    }   
    CDialog::OnTimer(nIDEvent);
}

Hope this helps..


All times are GMT +2. The time now is 14:41.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.