private void _active_MenuItem_Click(object sender, EventArgs e) { int index = _app_ListView.SelectedIndices[0]; List <IntPtr> ptrs = _app_ListView.Tag as List <IntPtr>; if (FileIsOpen.ShowWindow(ptrs[index], 9)) { FileIsOpen.SetWindowPos(ptrs[index], 0, 0, 0, 0, 0, 1 | 2); } }
/// <summary> /// 设置是否置顶 /// </summary> /// <param name="value"></param> private void SetWindows(string value) { if (value == "1") { FileIsOpen.SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); } else { FileIsOpen.SetWindowPos(this.Handle, -2, 0, 0, 0, 0, 3); } }
private void OpenFile(ListViewEx list) { int index = list.SelectedIndices[0]; List <IntPtr> ptrs = list.Tag as List <IntPtr>; if (FileIsOpen.ShowWindow(ptrs[index], 9)) { FileIsOpen.SetWindowPos(ptrs[index], 0, 0, 0, 0, 0, 1 | 2); } this.Close(); }
private void _close_MenuItem_Click(object sender, EventArgs e) { int index = _app_ListView.SelectedIndices[0]; List <IntPtr> ptrs = _app_ListView.Tag as List <IntPtr>; FileIsOpen.SendMessage(ptrs[index], 0x10, 0, 0); _app_ListView.Items.RemoveAt(index); if (_app_ListView.Items.Count < 1) { this.Close(); } //MessageBox.Show(_app_ListView.SelectedIndices[0].ToString()); }
/// <summary> /// 全局钩子事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hook_KeyDown(object sender, KeyEventArgs e) { //判断按下的键(Alt + A) if (e.KeyValue == (int)Keys.Q && (int)Control.ModifierKeys == (int)Keys.Control) { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; this.Show(); this.ShowInTaskbar = true; if (_top_Ch.Checked) { //置顶 FileIsOpen.SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); } else { FileIsOpen.SetWindowPos(this.Handle, -2, 0, 0, 0, 0, 1 | 2); } this.notifyIcon.Visible = true; mIsStop = true; } else { if ((anchors & AnchorStyles.Left) == AnchorStyles.Left) { Left = OFFSET; } else if ((anchors & AnchorStyles.Top) == AnchorStyles.Top) { Top = OFFSET; } else if ((anchors & AnchorStyles.Right) == AnchorStyles.Right) { Left = Screen.PrimaryScreen.Bounds.Width - Width - OFFSET; } else if ((anchors & AnchorStyles.Bottom) == AnchorStyles.Bottom) { Top = Screen.PrimaryScreen.Bounds.Height - Height - OFFSET; } timer.Enabled = false; anchors = AnchorStyles.None; } //System.Windows.Forms.MessageBox.Show("按下了指定快捷键组合"); } }
/// <summary> /// 托盘图标双击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; this.Show(); this.ShowInTaskbar = true; if (_top_Ch.Checked) { //置顶 FileIsOpen.SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); } else { FileIsOpen.SetWindowPos(this.Handle, -2, 0, 0, 0, 0, 1 | 2); } this.notifyIcon.Visible = true; } mIsStop = true; }
private void app_Load(object sender, EventArgs e) { FileIsOpen.SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); //_app_ListView.LargeImageList.Images.Clear();/* mImgListOneSelf.Images.Clear();*/ mImgListOneSelf.ImageSize = size; foreach (OpenFileInfo item in _fileInfo) { Icon icon = GetOtherIcon.GetFileIcon(item.Name, GetOtherIcon.IconSize.Large, false); mImgListOneSelf.Images.Add(item.HWND.ToString(), icon); } _app_ListView.LargeImageList = mImgListOneSelf; List <IntPtr> ptrList = new List <IntPtr>(); foreach (OpenFileInfo item in _fileInfo) { _app_ListView.Items.Add(Path.GetFileNameWithoutExtension(item.Name), item.HWND.ToString()); ptrList.Add(item.HWND); } _app_ListView.Tag = ptrList; _app_ListView.View = View.LargeIcon; }
/// <summary> /// 大开文件 /// </summary> /// <param name="item"></param> private void OpenSingleApp(string item) { //判断是从自定义界面打开还是其他界面 if (Global.IsOneSelf && !Global.IsNew && !Global.IsOpenFolder) { //如果是自定义则看是可以直接置顶 int i = FileIsOpen.FileIsOpens(item); if (i == 0) { Thread th = new Thread(() => { object obj = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Policies").OpenSubKey("System").GetValue("EnableLUA"); if (obj != null) { if ((int)obj == 0) { OpenProgram(item); } else { //开启了UAC OpenProgram(item, false); } } else { OpenProgram(item); } }); th.IsBackground = true; th.Start(); } string str = mXMLHelper.GetXmlAttrValue(item, "Count"); str = (int.Parse(str) + 1).ToString(); mXMLHelper.UpdateNode(item, "Count", str); mXMLHelper.UpdateNode(item, "End", DateTime.Now.ToShortDateString()); } else if (Global.IsOneSelf && Global.IsNew && !Global.IsOpenFolder) { Thread th = new Thread(() => { Process pro = Process.Start(item); pro.WaitForInputIdle(); OpenFileInfo op = new OpenFileInfo(); op.ID = pro.Id; op.Name = item; op.ProcessName = pro.ProcessName; op.HWND = pro.MainWindowHandle; op.Time = DateTime.Now.ToString(); Global.FileInfo.Add(op); }); th.IsBackground = true; th.Start(); } else if (Global.IsOneSelf && Global.IsOpenFolder) { string filename = System.IO.Path.GetDirectoryName(item); //MessageBox.Show(filename); Process.Start("explorer.exe", filename); Global.IsOpenFolder = false; } else { string cs = ""; if (item.ToLower() == "shutdown ") { cs = " -s -t 120"; } Process.Start(item, cs); } }
private void easyOpen_Load(object sender, EventArgs e) { if (CheckWindows()) { this.Close(); Application.Exit(); return; } _clear_Ch.Checked = XMLHelper.GetRootValue("Clear") == "1" ? true : false; _close_Ch.Checked = XMLHelper.GetRootValue("Close") == "1" ? true : false; _top_Ch.Checked = XMLHelper.GetRootValue("IsTop") == "1" ? true : false; _startOpen_Ch.Checked = XMLHelper.GetRootValue("AutoRun") == "1" ? true : false; //是否置顶 if (_top_Ch.Checked) { //置顶 FileIsOpen.SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); } else { FileIsOpen.SetWindowPos(this.Handle, -2, 0, 0, 0, 0, 1 | 2);// 1 | 2); } if (_clear_Ch.Checked) { numTxt.Visible = true; numTxt.Value = decimal.Parse(XMLHelper.GetRootValue("DayCount")); ClearApp(); } ExecuteCommon execute = new ExecuteCommon(); /* 获取路径 */ if (!(bool)execute.doMethod(Key_XmlCore.GetFullPath.ToString(), null)) { return; } /* 获取图标 */ if (!(bool)execute.doMethod(Key_XmlCore.GetIcon.ToString())) { return; } /* 绑定数据 */ if (!(bool)execute.doMethod(Key_LogicCore.LoadLvOneSelf.ToString(), new object[] { mImgListOneSelf, XmlCore.listOneSelfPath, XmlCore.listIcon, lvOneSelf })) { return; } //设置图标 if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + @"img\Title.png")) { Bitmap ico = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory + @"img\Title.png"); pictureBox2.Image = ico; } if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + @"img\Superbar.ico")) { Icon ico = new Icon(System.AppDomain.CurrentDomain.BaseDirectory + @"img\Superbar.ico"); notifyIcon.Icon = ico; } Global.IsOneSelf = true; mAddCount++; }