通过蓝牙自动点击按钮?

时间:2015-08-26 20:46:17

标签: c# multithreading bluetooth

当我通过蓝牙从平板电脑接收命令时,我使用以下代码自动点击桌面应用程序上的按钮:

//Auto click record button
if (action_type_received_final == 0)
{
    ButtonAutomationPeer peer2 = new ButtonAutomationPeer(Btn_Record);
    IInvokeProvider invokeProv2 = peer2.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
    //invokeProv2.Invoke();
    Dispatcher.BeginInvoke(new ThreadStart(() => invokeProv2.Invoke()));

    action_type_received_final = 0;
}

在添加调度程序行之前,我曾经遇到过以下异常:

"调用线程无法访问此对象,因为另一个线程拥有它"

现在我不再获得此异常并且代码运行,但桌面上的按钮实际上没有被点击。

我将不胜感激。

0 个答案:

没有答案