c# 录屏软件


在网上找的基本用不了,后来自己结合别人的代码弄出来了,vs2013 + win7 sp1测试可以使用
资源截图
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace ScreenRecoder
{
    public class KeyboardHook
    {
        int hHook;
        Win32Api.HookProc KeyboardHookDelegate;
        public event KeyEventHandler onkeydownEvent;
        public event KeyEventHandler onkeyupEvent;
        public event KeyPressEventHandler onkeypressEvent;
        public KeyboardHook() { }
        public void SetHook()
        {
            KeyboardHookDelegate = new Win32Api.HookProc(KeyboardHookProc);
            Process cProcess = Process.GetCurrentProcess();
            ProcessModule cModule = cProcess.MainModule;
            var mh = Win32Api.GetModuleHandle(cModule.ModuleName);
            hHook = Win32Api.SetWindowsHookEx(Win32Api.WH_KEYBOARD_LL KeyboardHookDelegate mh 0);
        }
        public void UnHook()
        {
            Win32Api.UnhookWindowsHookEx(hHook);
        }
        private List preKeysList = new List();//存放被按下的控制键,用来生成具体的键

        private int KeyboardHookProc(int nCode Int32 wParam IntPtr lParam)
        {
            //如果该消息被丢弃(nCode<0)或者没有事件绑定处理程序则不会触发事件
            if ((nCode >= 0) && (onkeydownEvent != null || onkeyupEvent != null || onkeypressEvent != null))
            {
                Win32Api.KeyboardHookStruct KeyDataFromHook = (Win32Api.KeyboardHookStruct)Marshal.PtrToStructure(lParam typeof(Win32Api.KeyboardHookStruct));
                Keys keyData = (Keys)KeyDataFromHook.vkCode;
                //按下控制键
                if ((onkeydownEvent != null || onkeypressEvent != null) && (wParam == Win32Api.WM_KEYDOWN || wParam == Win32Api.WM_SYSKEYDOWN))
                {
                    if (IsCtrlAltShiftKeys(keyData) && preKeysList.IndexOf(keyData) == -1)
                    {
                        preKeysList.Add(keyData);
                    }
                }
                //WM_KEYDOWN和WM_SYSKEYDOWN消息,将会引发onkeydownEvent事件
                if (onkeydownEvent != null && (wParam == Win32Api.WM_KEYDOWN || wParam == Win32Api.WM_SYSKEYDOWN))
                {
                    KeyEventArgs e = new KeyEventArgs(GetDownKeys(keyData));
                    onkeydownEvent(this e);
                }
                //WM_KEYDOWN消息将引发onkeypressEvent 
                if (onkeypressEvent != null && wParam == Win32Api.WM_KEYDOWN)
                {
                    byte[] keyState = new byte[256];
                    Win32Api.GetKeyboardState(keyState);
                    byte[] inBuffer = new byte[2];
                    if (Win32Api.ToAscii(KeyDataFromHook.vkCode KeyDataFromHook.scanCode keyState inBuffer KeyDataFromHook.flags) == 1)
                    {
                        KeyPressEventArgs e = new KeyPressEventArgs((char)inBuffer[0]);
                        onkeypressEvent(this e);
                    }
                }
                //松开控制键

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      29184  2015-07-20 11:32  ScreenRecoder.vsScreenRecoderv14.suo

     文件      98304  2016-02-25 09:32  ScreenRecoderScreenRecoderinDebugInterop.WMEncoderLib.dll

     文件    2677382  2016-02-24 16:58  ScreenRecoderScreenRecoderinDebugScreen20160224-165607.wmv

     文件     349606  2016-02-24 17:08  ScreenRecoderScreenRecoderinDebugScreen20160224-170746.wmv

     文件    2253720  2016-02-24 17:10  ScreenRecoderScreenRecoderinDebugScreen20160224-171022.wmv

     文件     493618  2016-02-25 09:45  ScreenRecoderScreenRecoderinDebugScreen20160225-093814.wmv

     文件     349594  2016-03-09 11:44  ScreenRecoderScreenRecoderinDebugScreen20160309-114421.wmv

     文件    1381714  2016-03-09 14:28  ScreenRecoderScreenRecoderinDebugScreen20160309-142817.wmv

     文件     333876  2016-03-09 14:34  ScreenRecoderScreenRecoderinDebugScreen20160309-143420.wmv

     文件      85606  2016-03-09 14:36  ScreenRecoderScreenRecoderinDebugScreen20160309-143615.wmv

     文件     701624  2016-03-09 14:46  ScreenRecoderScreenRecoderinDebugScreen20160309-144631.wmv

     文件     325612  2016-03-09 14:47  ScreenRecoderScreenRecoderinDebugScreen20160309-144712.wmv

     文件     317642  2016-03-09 14:48  ScreenRecoderScreenRecoderinDebugScreen20160309-144747.wmv

     文件     301600  2016-03-09 14:48  ScreenRecoderScreenRecoderinDebugScreen20160309-144822.wmv

     文件     669630  2016-03-09 14:49  ScreenRecoderScreenRecoderinDebugScreen20160309-144900.wmv

     文件       5388  2016-03-09 14:58  ScreenRecoderScreenRecoderinDebugScreen20160309-145814.wmv

     文件       5388  2016-03-09 14:58  ScreenRecoderScreenRecoderinDebugScreen20160309-145825.wmv

     文件     717648  2016-03-09 15:04  ScreenRecoderScreenRecoderinDebugScreen20160309-150424.wmv

     文件     973630  2016-03-09 15:06  ScreenRecoderScreenRecoderinDebugScreen20160309-150556.wmv

     文件    1013624  2016-03-09 15:10  ScreenRecoderScreenRecoderinDebugScreen20160309-151012.wmv

     文件       5388  2016-03-09 15:11  ScreenRecoderScreenRecoderinDebugScreen20160309-151059.wmv

     文件       5388  2016-03-09 15:12  ScreenRecoderScreenRecoderinDebugScreen20160309-151208.wmv

     文件     405636  2016-03-09 15:20  ScreenRecoderScreenRecoderinDebugScreen20160309-151947.wmv

     文件     789624  2016-03-09 15:25  ScreenRecoderScreenRecoderinDebugScreen20160309-152453.wmv

     文件     805618  2016-03-09 16:07  ScreenRecoderScreenRecoderinDebugScreen20160309-160707.wmv

     文件     629630  2016-03-09 16:19  ScreenRecoderScreenRecoderinDebugScreen20160309-161839.wmv

     文件       5826  2015-07-20 09:45  ScreenRecoderScreenRecoderinDebugscreen.prx

     文件     175104  2016-03-09 16:24  ScreenRecoderScreenRecoderinDebugScreenRecoder.exe

     文件      46592  2016-03-09 16:24  ScreenRecoderScreenRecoderinDebugScreenRecoder.pdb

     文件      22704  2016-03-09 16:24  ScreenRecoderScreenRecoderinDebugScreenRecoder.vshost.exe

............此处省略72个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)