InteropServices.COMException error when activating game window

109 views Asked by At

I added to my windows form a hook for shortcut key for the purpose of a pixel search bot. Suddenly it gives an error. Error is in this line:

au3.WinActivate("WarUniverse", "");
                au3.WinSetState("WarUniverse", "", au3.SW_MAXIMIZE);

I can not activate the game window. It probably conflicts with something but I don't know what.

void CheckKeyCombo()
    {
        if (lctrlKeyPressed && f9KeyPressed)
        {
            BaslaBtn.PerformClick();
        }
    }
    public void Checkbox()
    {
        if (BonusCheck.Checked)
        {
            Thread bot = new Thread(KutuToplama) { IsBackground = true };
            if (buttonswitch == false)
            {
                BaslaBtn.Text = "Start";
                kututoplama = false;
                buttonswitch = true;
            }
            else
            {
                BaslaBtn.Text = "Stop";
                kututoplama = true;
                au3.WinActivate("WarUniverse", "");
                au3.WinSetState("WarUniverse", "", au3.SW_MAXIMIZE);
                bot.Start();
            }
        }
        else
        {               
            MessageBox.Show("Please choose a option for bot ", "DolunayBot", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
    private void BaslaBtn_Click(object sender, EventArgs e)
    {
        Checkbox();
    }

Error (Turkish):

System.Runtime.InteropServices.COMException: 'Uygulama, giriş zaman uyumlu bir çağrı gönderdiği için giden bir çağrı yapılamıyor. (0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL))'

1

There are 1 answers

0
Frenchy On

test if window is present to be sure:

au3.WinWait("WarUniverse");
au3.WinSetState("WarUniverse", "", au3.SW_MAXIMIZE);

you dont need to activate it, you could directly to maximize the window