#region 录制
public int RecordProcedure(int nCode, IntPtr wParam, IntPtr lParam)
{
switch (nCode)
{
case HC_ACTION:
EVENTMSG curMSG = null;
try
{
curMSG = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG));
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
msgList.Add(curMSG);
break;
default:
break;
}
return CallNextHookEx(hHook, nCode, wParam, lParam); }
#endregion #region 播放
public int PlayBackProcedure(int nCode, IntPtr wParam, IntPtr lParam)
{
int preTime = 0, nowTime = 0;
switch (nCode)
{
case HC_SKIP:
bFlag = true;
pos++;
return 0; case HC_GETNEXT:
#region
if (pos >= (msgList.Count - 2))
{
bool ret = UnhookWindowsHookEx(hHook);
if (ret == true)
{
MessageBox.Show("回放完毕!"); }
pos = 0;
hHook = 0;
return 0;
}
#endregion
#region EVENTMSG currentMSG = (EVENTMSG)msgList[pos];
try
{
Marshal.StructureToPtr(currentMSG, lParam, true);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
#endregion #region
if ((pos > 0) && (bFlag == true))
{
bFlag = false;
EVENTMSG preMSG = (EVENTMSG)msgList[pos - 1];
preTime = preMSG.time;
nowTime = currentMSG.time;
return nowTime - preTime;
}
else
{
return 0;
}
#endregion
default:
break;
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
这是我做的一个录制键盘鼠标操作的小程序中的两个主要函数。RecordProcedure和PlayBackProcedure,在播放的时候nCode参数一直等于0,导致没法正常回放,录制应该可以成功录下来了。求指导,新人,谢谢
public int RecordProcedure(int nCode, IntPtr wParam, IntPtr lParam)
{
switch (nCode)
{
case HC_ACTION:
EVENTMSG curMSG = null;
try
{
curMSG = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG));
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
msgList.Add(curMSG);
break;
default:
break;
}
return CallNextHookEx(hHook, nCode, wParam, lParam); }
#endregion #region 播放
public int PlayBackProcedure(int nCode, IntPtr wParam, IntPtr lParam)
{
int preTime = 0, nowTime = 0;
switch (nCode)
{
case HC_SKIP:
bFlag = true;
pos++;
return 0; case HC_GETNEXT:
#region
if (pos >= (msgList.Count - 2))
{
bool ret = UnhookWindowsHookEx(hHook);
if (ret == true)
{
MessageBox.Show("回放完毕!"); }
pos = 0;
hHook = 0;
return 0;
}
#endregion
#region EVENTMSG currentMSG = (EVENTMSG)msgList[pos];
try
{
Marshal.StructureToPtr(currentMSG, lParam, true);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
#endregion #region
if ((pos > 0) && (bFlag == true))
{
bFlag = false;
EVENTMSG preMSG = (EVENTMSG)msgList[pos - 1];
preTime = preMSG.time;
nowTime = currentMSG.time;
return nowTime - preTime;
}
else
{
return 0;
}
#endregion
default:
break;
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
这是我做的一个录制键盘鼠标操作的小程序中的两个主要函数。RecordProcedure和PlayBackProcedure,在播放的时候nCode参数一直等于0,导致没法正常回放,录制应该可以成功录下来了。求指导,新人,谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货