[CF.Skills]Windows Mobile如何编程实现免提功能
摘要:本文阐述了如何在Windows mobile的设备上使用托管代码在来电时触发扬声器,间接实现免提的功能
Keywords
Windows Mobile,.NET CompactFramework,Speaker,keybd_event,C#
相关文章
http://www.cnblogs.com/fox23/archive/2008/02/15/phoneincoming.html
http://www.cnblogs.com/fox23/archive/2008/03/12/phonestate1.html
前提
你的WM设备必须支持扬声器,模拟器自然不行
首先,需要导入用于发送按键消息的本地函数
调用的时候:
论坛上也有相关问题,欢迎来做进一步的讨论:
http://forums.microsoft.com/china/ShowPost.aspx?PostID=3210021&SiteID=15
http://www.winbile.net/bbs/forums/threads/1036681.aspx
Enjoy it!
©Freesc Huang
黄季冬<fox23>@HUST
2008.04.27
Keywords
Windows Mobile,.NET CompactFramework,Speaker,keybd_event,C#
相关文章
http://www.cnblogs.com/fox23/archive/2008/02/15/phoneincoming.html
http://www.cnblogs.com/fox23/archive/2008/03/12/phonestate1.html
前提
你的WM设备必须支持扬声器,模拟器自然不行
首先,需要导入用于发送按键消息的本地函数
class NativeHelper
{
private const int KEYEVENTF_KEYUP = 0x0002;
[DllImport("coredll.dll")]
private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
/// <summary>
/// 模拟按键触发扬声器
/// </summary>
public static void TriggleSpeaker()
{
keybd_event((byte)Keys.F16, 0, 0, 0);
Thread.Sleep(500);
keybd_event((byte)Keys.F16, 0, KEYEVENTF_KEYUP, 0);
}
/// <summary>
/// 模拟按键接电话
/// </summary>
public static void AcceptCall()
{
keybd_event((byte)Keys.F3, 0, 0, 0);
Thread.Sleep(500);
keybd_event((byte)Keys.F3, 0, KEYEVENTF_KEYUP, 0);
}
}
{
private const int KEYEVENTF_KEYUP = 0x0002;
[DllImport("coredll.dll")]
private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
/// <summary>
/// 模拟按键触发扬声器
/// </summary>
public static void TriggleSpeaker()
{
keybd_event((byte)Keys.F16, 0, 0, 0);
Thread.Sleep(500);
keybd_event((byte)Keys.F16, 0, KEYEVENTF_KEYUP, 0);
}
/// <summary>
/// 模拟按键接电话
/// </summary>
public static void AcceptCall()
{
keybd_event((byte)Keys.F3, 0, 0, 0);
Thread.Sleep(500);
keybd_event((byte)Keys.F3, 0, KEYEVENTF_KEYUP, 0);
}
}
调用的时候:
SystemState phonestate = new SystemState(SystemProperty.PhoneIncomingCall);
phonestate.Changed += new ChangeEventHandler(phonestate_Changed);
void phonestate_Changed(object sender, ChangeEventArgs args)
{
NativeHelper.AcceptCall();
NativeHelper.TriggleSpeaker();
}
phonestate.Changed += new ChangeEventHandler(phonestate_Changed);
void phonestate_Changed(object sender, ChangeEventArgs args)
{
NativeHelper.AcceptCall();
NativeHelper.TriggleSpeaker();
}
论坛上也有相关问题,欢迎来做进一步的讨论:
http://forums.microsoft.com/china/ShowPost.aspx?PostID=3210021&SiteID=15
http://www.winbile.net/bbs/forums/threads/1036681.aspx
Enjoy it!
©Freesc Huang
黄季冬<fox23>@HUST
2008.04.27
posted on 2008-04-27 12:26 J.D Huang 阅读(3463) 评论(6) 编辑 收藏 举报