Beispiel #1
0
        //hWnd 窗口句柄  //processDic 目标进程目录  //结点信息
        private void PressShortCutInfoKey(string processExePath, KeyTreeNodeTag taginfo)
        {
            foreach (ShortCutInfo info in taginfo.userShortcutMap)
            {
                string processDic     = System.IO.Path.GetDirectoryName(processExePath).ToLower(); //子进程的目录要比父进程的深吧
                string processexeName = System.IO.Path.GetFileName(processExePath);

                string tempDic = System.IO.Path.GetDirectoryName(ShortCutInfo._computerApps[info.AppShowName]).ToLower();
                string tempExe = info.AppShowName;

                Debug.WriteLine(processDic);
                if (processDic.Contains(tempDic))                                       //最前的进程目录要包含定义的目录
                {
                    string sysDicX86 = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86).ToLower();
                    string sysDic    = Environment.GetFolderPath(Environment.SpecialFolder.System).ToLower();
                    if (processDic.Contains(sysDicX86) || processDic.Contains(sysDic))   //如果是系统进程目录内的目录的EXE则要求EXE名称必须相同
                    {
                        if (tempExe != processexeName)
                        {
                            continue;
                        }
                    }

                    if (info.key0 != 0)  //按键消息
                    {
                        if (info.Control0)
                        {
                            Win32APIs.keybd_event(Win32APIs.VK_CONTROL, 0, 0, 0);
                        }
                        if (info.Shift0)
                        {
                            Win32APIs.keybd_event(Win32APIs.VK_SHIFT, 0, 0, 0);
                        }
                        if (info.Alt0)
                        {
                            Win32APIs.keybd_event(Win32APIs.VK_MENU, 0, 0, 0);
                        }
                        Win32APIs.keybd_event(Convert.ToByte(KeyInterop.VirtualKeyFromKey(info.key0)), 0, 0, 0);
                        Win32APIs.keybd_event(Convert.ToByte(KeyInterop.VirtualKeyFromKey(info.key0)), 0, 2, 0);
                        if (info.Alt0)
                        {
                            Win32APIs.keybd_event(Win32APIs.VK_MENU, 0, 2, 0);
                        }
                        if (info.Shift0)
                        {
                            Win32APIs.keybd_event(Win32APIs.VK_SHIFT, 0, 2, 0);
                        }
                        if (info.Control0)
                        {
                            Win32APIs.keybd_event(Win32APIs.VK_CONTROL, 0, 2, 0);
                        }
                        if (info.key1 != 0)
                        {
                            if (info.Control1)
                            {
                                Win32APIs.keybd_event(Win32APIs.VK_CONTROL, 0, 0, 0);
                            }
                            if (info.Shift1)
                            {
                                Win32APIs.keybd_event(Win32APIs.VK_SHIFT, 0, 0, 0);
                            }
                            if (info.Alt1)
                            {
                                Win32APIs.keybd_event(Win32APIs.VK_MENU, 0, 0, 0);
                            }
                            Win32APIs.keybd_event(Convert.ToByte(KeyInterop.VirtualKeyFromKey(info.key1)), 0, 0, 0);
                            Win32APIs.keybd_event(Convert.ToByte(KeyInterop.VirtualKeyFromKey(info.key1)), 0, 2, 0);
                            if (info.Alt1)
                            {
                                Win32APIs.keybd_event(Win32APIs.VK_MENU, 0, 2, 0);
                            }
                            if (info.Shift1)
                            {
                                Win32APIs.keybd_event(Win32APIs.VK_SHIFT, 0, 2, 0);
                            }
                            if (info.Control1)
                            {
                                Win32APIs.keybd_event(Win32APIs.VK_CONTROL, 0, 2, 0);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void _subListView_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            DataGrid dataGrid = sender as DataGrid;
            ObservableCollection <ShortCutInfo> userShortcutMap = dataGrid.ItemsSource as ObservableCollection <ShortCutInfo>;

            //TextBlock textBlock0 = GlobalConfig.GetChildObject<TextBlock>(dataGrid.ContainerFromElement(e.Row), "TextBlock0");//查找第一列的Textbox

            if (e.Row.IsNewItem || e.Row.IsEditing)
            {
                if (_shortCutInfoTemp.AppShowName == null || _shortCutInfoTemp.AppShowName == "" || _shortCutInfoTemp.ShortCutString == null || _shortCutInfoTemp.ShortCutString == "")
                {
                    ShortCutInfo sInfo = e.Row.DataContext as ShortCutInfo;

                    sInfo.Empty();
                    if (e.Row.IsNewItem)
                    {
                        userShortcutMap.Remove(sInfo);
                    }
                    else if (e.Row.IsEditing)
                    {
                        e.Cancel = true;
                    }
                }
                else
                {
//                     if (textBlock0 != null)
//                     {
                    string         str1 = _shortCutInfoTemp.AppShowName;
                    string         str2 = _shortCutInfoTemp.ShortCutString;
                    KeyTreeNodeTag tag  = dataGrid.Tag as KeyTreeNodeTag;

                    string processPath = ShortCutInfo._computerApps[str1];    //应包含应用程序显示名称
                    if (processPath.Length != 0)
                    {
                        _shortCutInfoTemp.AppShowName = str1;
                        ushort appID = 0xffff;
                        foreach (KeyValuePair <ushort, string> kvp in ShortCutInfo._constSuportApps)    //路径中应包含相应的EXE
                        {
                            if (kvp.Value.Length > 0 && processPath.Contains(kvp.Value))
                            {
                                appID = kvp.Key;
                                break;
                            }
                        }

                        if (_CreateSerial80 != null && _WriteDelegate != null)
                        {
                            byte[] data = _CreateSerial80(_shortCutInfoTemp.Control0, _shortCutInfoTemp.Shift0, _shortCutInfoTemp.Alt0, Convert.ToByte(_shortCutInfoTemp.key0),
                                                          _shortCutInfoTemp.Control1, _shortCutInfoTemp.Shift1, _shortCutInfoTemp.Alt1, Convert.ToByte(_shortCutInfoTemp.key1),
                                                          appID, 0, tag.keyType
                                                          );

                            if (_WriteDelegate(data))    //对于记录应用信息只需保存安装目录即可
                            {
                                //textBlock0.Text = " ";
                            }
                            else
                            {
                                ShortCutInfo sInfo = e.Row.DataContext as ShortCutInfo;

                                sInfo.Empty();
                                if (e.Row.IsNewItem)
                                {
                                    userShortcutMap.Remove(sInfo);
                                }
                                else if (e.Row.IsEditing)
                                {
                                    e.Cancel = true;
                                }
                                dataGrid.UpdateLayout();
                            }
                        }
                        /*                       }*/
                    }
                }
            }
        }
Beispiel #3
0
        public void ProcessDataComplete80(object result)
        {
            try
            {
                unsafe
                {
                    byte[] byteAry = result as byte[];

                    fixed(byte *pByte = &(byteAry[0]))
                    {
                        byte   Ctr_Alt_Shift0 = *(pByte + 8);
                        byte   Key0           = *(pByte + 9);
                        byte   Ctr_Alt_Shift1 = *(pByte + 10);
                        byte   Key1           = *(pByte + 11);
                        ushort AppName        = *((ushort *)(pByte + 12));
                        byte   KeyType        = *(pByte + 16);

                        if (ShortCutInfo._constSuportApps.ContainsKey(AppName))//是否包含APPID
                        {
                            foreach (KeyValuePair <string, string> kvp in ShortCutInfo._computerApps)
                            {
                                if (kvp.Value.Contains(ShortCutInfo._constSuportApps[AppName]))//安装路径中是否包含EXE文件名称
                                {
                                    switch (KeyType)
                                    {
                                    case 0x01:    //KEY_TOUCH_LEFT  = 0x01,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[0]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x02:    //KEY_TOUCH_RIGHT = 0x02,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[1]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x03:    //KEY_TOUCH_MID   = 0x03,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[2]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x04:    //KEY_TOUCH_UP    = 0x04,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[3]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x05:    //KEY_TOUCH_DOWN  = 0x05,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[4]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x11:    //KEY_PRESS_LEFT  = 0x11,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[5]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x12:    //KEY_PRESS_RIGHT = 0x12,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[6]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x13:    //KEY_PRESS_MID   = 0x13,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[7]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x14:    //KEY_PRESS_UP    = 0x14,
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[8]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;

                                    case 0x15:    //KEY_PRESS_DOWN  = 0x15
                                    {
                                        KeyTreeNodeTag taginfo = touchCntNode.Children[9]._treeTag as KeyTreeNodeTag;
                                        bool           bFind   = false;
                                        foreach (ShortCutInfo info in taginfo.userShortcutMap)
                                        {
                                            if (info.AppShowName == kvp.Key)
                                            {
                                                bFind = true;
                                                break;
                                            }
                                        }
                                        if (false == bFind)
                                        {
                                            ShortCutInfo shortCutTemp = new ShortCutInfo();
                                            shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0;
                                            shortCutTemp.Shift0   = (Ctr_Alt_Shift0 & 0x02) != 0;
                                            shortCutTemp.Alt0     = (Ctr_Alt_Shift0 & 0x04) != 0;
                                            shortCutTemp.key0     = (Key)Key0;
                                            shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0;
                                            shortCutTemp.Shift1   = (Ctr_Alt_Shift1 & 0x02) != 0;
                                            shortCutTemp.Alt1     = (Ctr_Alt_Shift1 & 0x04) != 0;
                                            shortCutTemp.key1     = (Key)Key1;

                                            shortCutTemp.AppShowName = kvp.Key;
                                            taginfo.userShortcutMap.Add(shortCutTemp);
                                        }
                                    }
                                    break;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                string str = ex.Message;
            }
        }