public static string GetClipBoardData() { try { string ClipData = null; Exception e = null; Thread staThread = new Thread( delegate() { try { ClipData = Clipboard.GetText(TextDataFormat.Text); } catch (Exception ex) { e = ex; } }); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); staThread.Join(); return(ClipData); } catch (Exception) { return(string.Empty); } }
private void bt__Click(object sender, RoutedEventArgs e) { DataGrid dg = dgDocuments; dg.SelectAllCells(); dg.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader; ApplicationCommands.Copy.Execute(null, dg); dg.UnselectAllCells(); String result = (string)Clipboard.GetData(DataFormats.Text); string a, b; b = "@"; a = (DBConnection.FolderZ.ToString()); StreamWriter sw = new StreamWriter(a); sw.WriteLine(result); sw.Close(); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.ShowDialog(); File.WriteAllText(saveFileDialog.FileName, result); }
/// <exception cref="System.Runtime.InteropServices.ExternalException"></exception> /// <exception cref="System.Threading.ThreadStateException"></exception> private void KeyboardMouseEvents_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if ((usingControl && e.Control == false) || (!usingControl && e.Control == true)) { return; } if ((usingShift && e.Shift == false) || (!usingShift && e.Shift == true)) { return; } if ((usingAlt && e.Alt == false) || (!usingAlt && e.Alt == true)) { return; } if (((char)e.KeyValue) == cbKeys.SelectedItem.ToString()[0]) { if (Clipboard.ContainsText()) { string content = Clipboard.GetText(); content = selectedMockType.MockifyText(content); Clipboard.SetText(content); } } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); AssemblyFileVersionAttribute version = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true). Cast<AssemblyFileVersionAttribute>().FirstOrDefault(); title = "HeuristicLab Optimizer"; if (version != null) title += " " + version.Version; Title = title; ContentManager.Initialize(new PersistenceContentManager()); clipboard = new Clipboard<IItem>(); clipboard.Dock = DockStyle.Left; clipboard.Collapsed = Properties.Settings.Default.CollapseClipboard; if (Properties.Settings.Default.ShowClipboard) { clipboard.Show(); } if (Properties.Settings.Default.ShowOperatorsSidebar) { OperatorsSidebar operatorsSidebar = new OperatorsSidebar(); operatorsSidebar.Dock = DockStyle.Left; operatorsSidebar.Show(); operatorsSidebar.Collapsed = Properties.Settings.Default.CollapseOperatorsSidebar; } if (Properties.Settings.Default.ShowStartPage) { StartPage startPage = new StartPage(); startPage.Show(); } }
protected override void EndProcessing() { ExecuteWrite(delegate { WinFormsClipboard.SetText(_output.ToString()); }); }
public string Classify(string start) { string tempstring = string.Empty; var id = Process.GetProcesses() ?.FirstOrDefault(pr => pr.MainWindowTitle.Contains(@"v2018")).Id; SetForegroundWindow(Process.GetProcessById(id.Value).MainWindowHandle); InputSimulator sim = new InputSimulator(); sim.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.F5 }); //SendKeys.SendWait("{F5}"); //IntPtr hWnd= Process.GetCurrentProcess().MainWindowHandle; //System.Windows.Window wnd = new System.Windows.Window(); //ClipboardMonitor monitor = new ClipboardMonitor(); while (start.Equals(Clipboard.GetText())) { Thread.Sleep(100); } tempstring = Clipboard.GetText(); if (Replace(ref start, tempstring, out var replace)) { return(replace); } return(replace); }
public TreeWindow(Clipboard clip, IFileSystem fs) { _clip = clip; _fs = fs; InitializeComponent(); Text = Text + " - " + fs.TypeName; _tree.BeforeExpand += new TreeViewCancelEventHandler(this._tree_BeforeExpand); _tree.AfterCollapse += new TreeViewEventHandler(this._tree_AfterCollapse); IDirectory dir = fs.RootDirectory; TreeNode node = new TreeNode(); InitNode(node, dir); _tree.Nodes.Add(node); _list.Columns.Add("Name", 300); _list.Columns.Add("Size", 100); _list.Columns.Add("Type", 100); _clip.ClipboardContentChanged += new EventHandler(this.UpdateButtons); // TODO remove when closed _list.SelectedIndexChanged += new EventHandler(this.UpdateButtons); _btCut. Click += new EventHandler(this.OnCut); _btCopy. Click += new EventHandler(this.OnCopy); _btPaste. Click += new EventHandler(this.OnPaste); _btDelete. Click += new EventHandler(this.OnDelete); _btCreateDir.Click += new EventHandler(this.OnCreateDir); UpdateButtons(null, null); }
public override bool IsTypeAvailable(TransferDataType type) { if (type == null) { throw new ArgumentNullException("type"); } return(WindowsClipboard.ContainsData(type.ToSwf())); }
private void GenerateExplorerBackgroundMenuItems(ContextMenu view, ContextMenu mnu, ContextMenu sortMenu, ContextMenu groupMenu) { this.GenerateMenuItem(view, "Thumbstrip", 259, _ShellView.View == ShellViewStyle.Thumbstrip); this.GenerateMenuItem(view, "Content", 258, _ShellView.View == ShellViewStyle.Content); this.GenerateMenuItem(view, "Tiles", 257, _ShellView.View == ShellViewStyle.Tile); this.GenerateMenuItem(view, "Details", 256, _ShellView.View == ShellViewStyle.Details); this.GenerateMenuItem(view, "List", 255, _ShellView.View == ShellViewStyle.List); this.GenerateMenuItem(view, "Small icon", 254, _ShellView.View == ShellViewStyle.SmallIcon); this.GenerateMenuItem(view, "Medium", 253, _ShellView.View == ShellViewStyle.Medium); this.GenerateMenuItem(view, "Large Icon", 252, _ShellView.View == ShellViewStyle.LargeIcon); this.GenerateMenuItem(view, "Extra Large Icon", 251, _ShellView.View == ShellViewStyle.ExtraLargeIcon); if (this._ShellView.CurrentFolder.IsFileSystem && (Clipboard.ContainsData(DataFormats.FileDrop) || Clipboard.ContainsData("Shell IDList Array"))) { this.GenerateSeparator(mnu); this.GenerateMenuItemExecutable(mnu, "Paste", 249); } this.GenerateSeparator(mnu); this.GenerateMenuItemExecutable(mnu, "Refresh", 250); var colID = 261 + this._ShellView.Collumns.Count; var colGroupID = colID + this._ShellView.Collumns.Count + 1; var collist = new List <Collumns>(); collist.AddRange(this._ShellView.Collumns); collist.Reverse(); this.GenerateMenuItem(sortMenu, "Descending", 248, this._ShellView.LastSortOrder == SortOrder.Descending); this.GenerateMenuItem(sortMenu, "Ascending", 247, this._ShellView.LastSortOrder == SortOrder.Ascending); this.GenerateSeparator(sortMenu); foreach (Collumns collumn in collist) { this.GenerateMenuItem(sortMenu, collumn.Name, colID--, collumn == this._ShellView.Collumns.FirstOrDefault(w => w.ID == this._ShellView.LastSortedColumnId)); } this.GenerateMenuItem(groupMenu, "Descending", 246, this._ShellView.LastGroupOrder == SortOrder.Descending); this.GenerateMenuItem(groupMenu, "Ascending", 245, this._ShellView.LastGroupOrder == SortOrder.Ascending); this.GenerateSeparator(groupMenu); foreach (Collumns collumn in collist) { this.GenerateMenuItem(groupMenu, collumn.Name, colGroupID--, collumn == this._ShellView.LastGroupCollumn); } this.GenerateMenuItem(groupMenu, "(None)", 260, this._ShellView.LastGroupCollumn == null); collist.Clear(); collist = null; this.GenerateSubmenu(groupMenu, mnu, "Group by"); this.GenerateSubmenu(sortMenu, mnu, "Sort by"); this.GenerateSubmenu(view, mnu, "View"); }
private void copyFilePathContextMenuItem_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(this.parent.FilePath)) { try { Clipboard.SetText(this.parent.FilePath); } catch (Exception) { } } }
public void writeMessage(string mess, int member, PersonModel p) { String mess2 = mess; string[] words = p.name.Split(new string[] { " " }, StringSplitOptions.None); string name = words[0]; mess2 = mess2.Replace("$name", name); Clipboard.Clear(); Clipboard.SetText(mess2); //ждем немножно Thread.Sleep(getRandom(1000, 1500)); if (member != Persons.Count - 1) //переключаемся { SendKeys.SendWait("^+{TAB}"); } //двигаемся на кнопку Thread.Sleep(getRandom(100, 200)); WebClient client = new WebClient(); Stream stream = client.OpenRead(p.photoUrl200.OriginalString); Bitmap bitmap; bitmap = new Bitmap(stream); int height = 420 + bitmap.Height - 243; System.Windows.Point point1 = new System.Windows.Point(720 + 20 - getRandom(0, 40), height + 5 - getRandom(0, 10)); //+-20 , +-10 MouseSimulator.LinearSmoothMove(point1, new TimeSpan(0, 0, 0, 0, getRandom(400, 500))); Thread.Sleep(getRandom(10, 50)); MouseSimulator.ClickLeftMouseButton(); Thread.Sleep(getRandom(800, 1200)); System.Windows.Point point3 = new System.Windows.Point(770 + 20 - getRandom(0, 40), 470 + 5 - getRandom(0, 10)); //+-20 , +-10 MouseSimulator.LinearSmoothMove(point3, new TimeSpan(0, 0, 0, 0, getRandom(100, 200))); Thread.Sleep(getRandom(100, 200)); //MouseSimulator.ClickLeftMouseButton(); //Thread.Sleep(getRandom(100, 200)); //Console.WriteLine(mess); //SendKeys.SendWait("^+{V}"); Thread.Sleep(getRandom(200, 300)); System.Windows.Point point2 = new System.Windows.Point(1120 + 20 - getRandom(0, 40), 580 + 10 - getRandom(0, 20)); //+-20 , +-10 MouseSimulator.LinearSmoothMove(point2, new TimeSpan(0, 0, 0, 0, getRandom(400, 500))); Thread.Sleep(getRandom(200, 300)); MouseSimulator.ClickLeftMouseButton(); }
//添加图片到richTextBox private void AddPhotoButton_Click(object sender, EventArgs e) { //设置对话框的过滤条件 openPhotoFileDialog.Filter = "png 文件(*.png)|*.png|jpg 文件(*.jpg)|*.jpg|bmp 文件(*.bmp)|*.bmp"; if (openPhotoFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //加载图片到richTextBox Clipboard.SetDataObject(Image.FromFile(openPhotoFileDialog.FileName), false); richTextBox1.Paste(); //图片放在剪贴板中;false:退出程序后不将图片保留在剪贴板中 } else { return; } }
public MainWindow() { _reg = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("ch.ph.FileManager"); _clip = new Clipboard(); InitializeComponent(); FormClosing += new FormClosingEventHandler(this_FormClosing); _localRootDir.Text = _reg.GetValue("LocalRootDir") as string; _awsAccessKeyId.Text = _reg.GetValue("AwsAccessKeyId") as string; _awsSecretAccessKey.Text = _reg.GetValue("AwsSecretAccessKey") as string; _awsBucket.Text = _reg.GetValue("AwsBucket") as string; }
//[Test] public void ChangeEventTest() { var sawChange = new System.Threading.ManualResetEvent(false); Clipboard.ClipboardUpdate += OnUpdate; System.Threading.Thread.SpinWait(1000); WFClipboard.SetText("Hello"); //using var cb = new Clipboard(); //cb.SetText("Hello"); Assert.IsTrue(sawChange.WaitOne(5000)); Clipboard.ClipboardUpdate -= OnUpdate; void OnUpdate(object sender, EventArgs e) => sawChange.Set(); }
public void DumpWFClipboardTest() { TestContext.WriteLine($"ContainsAudio: {WFClipboard.ContainsAudio()}"); TestContext.WriteLine($"ContainsData: {WFClipboard.ContainsData(DataFormats.StringFormat)}"); TestContext.WriteLine($"ContainsFileDropList: {WFClipboard.ContainsFileDropList()}"); TestContext.WriteLine($"ContainsImage: {WFClipboard.ContainsImage()}"); TestContext.WriteLine($"ContainsText: {WFClipboard.ContainsText()}"); TestContext.WriteLine($"GetAudioStream: {WFClipboard.GetAudioStream()}"); TestContext.WriteLine($"GetData: {WFClipboard.GetData(DataFormats.StringFormat)}"); TestContext.WriteLine($"GetDataObject: {WFClipboard.GetDataObject()}"); TestContext.WriteLine($"GetFileDropList: {string.Join("\n", WFClipboard.GetFileDropList().Cast<string>())}"); TestContext.WriteLine($"GetImage: {WFClipboard.GetImage()}"); TestContext.WriteLine($"GetText: {WFClipboard.GetText()}"); }
public override object GetData(TransferDataType type) { if (type == null) { throw new ArgumentNullException("type"); } if (!IsTypeAvailable(type)) { return(null); } return(WindowsClipboard.GetData(type.ToSwf())); }
public void CopyObject() { ListView.SelectedIndexCollection n = listView1.SelectedIndices; if (n.Count != 1 || pcc == null) return; int index = Convert.ToInt32(listView1.Items[n[0]].Name); int link = pcc.Exports[index].idxClassName; Clipboard temp = new Clipboard(); temp.entry = pcc.Exports[index]; temp.Name = pcc.Exports[index].ObjectName; temp.dep = FindLink(link); temp.isFilled = true; clip = temp; Println(temp.Name + " copied!"); }
public override IEnumerable <TransferDataType> GetTypesAvailable() { var dataObject = WindowsClipboard.GetDataObject(); if (dataObject == null) { yield break; } var formats = dataObject.GetFormats(false); foreach (var f in formats) { yield return(TransferDataType.FromId(f)); } }
private void HandleDownloadError(bool cancelled, Exception ex, string url) { if (cancelled) { SetState("Mise à jour interrompue", Colors.Red); } else { var remoteURL = url; MessageBox.Show(string.Format(Resources.Download_File_Error, remoteURL, ex), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); Clipboard.SetText(ex.ToString()); SetState(string.Format("Erreur lors de la mise à jour : {0}", ex.InnerException.Message), Colors.Red); } OnUpdateEnded(false); }
protected override void EndProcessing() { if (_objects.Count == 0) { ExecuteWrite(WinFormsClipboard.Clear); } else { string cmd = "$input | out-string"; if (_width.HasValue) { cmd = String.Format(CultureInfo.InvariantCulture, "$input | out-string -width {0}", _width.Value); } StringBuilder output = new StringBuilder(); Collection <PSObject> results = InvokeCommand.InvokeScript(cmd, false, PipelineResultTypes.None, _objects); foreach (PSObject obj in results) { string text = obj.ToString(); if (!_noTrimEnd) { StringBuilder trimmedOutput = new StringBuilder(); string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string line in lines) { trimmedOutput.AppendLine(line.TrimEnd(null)); } text = trimmedOutput.ToString(); } output.Append(text); } if (this.ParameterSetName == ParameterSetAsText) { ExecuteWrite( () => WinFormsClipboard.SetText(output.ToString())); } else { CopyAsFile(output.ToString()); } } }
void SetTextContents(string value, TextDataFormat format) { if (string.IsNullOrEmpty(value)) { WinFormsClipboard.Clear(); } else { if (format == TextDataFormat.Html) { CopyHtmlToClipboard(value); } else { WinFormsClipboard.SetText(value, format); } } }
public override void SetData(TransferDataType type, Func <object> dataSource) { if (type == null) { throw new ArgumentNullException("type"); } if (dataSource == null) { throw new ArgumentNullException("dataSource"); } if (type == TransferDataType.Html) { WindowsClipboard.SetData(type.ToSwf(), GenerateCFHtml(dataSource().ToString())); } else { WindowsClipboard.SetData(type.ToSwf(), dataSource()); } }
public void LoadMe() { clip = new Clipboard(); clip.isFilled = false; if (ME3Directory.gamePath != null) { pathME3exe = ME3Directory.gamePath + @"Binaries\Win32\MassEffect3.exe"; pathBIOGame = ME3Directory.gamePath + @"BIOGame\"; pathCooked = ME3Directory.cookedPath; Println("Found MassEffect3.exe : " + pathME3exe); Println("Cooked Folder : " + pathCooked); Println("Loading files..."); LoadFileNames(); } else { this.Close(); } }
//Экспортв MS Word private void bt_Eport_Word_Click(object sender, RoutedEventArgs e) { DataGrid dg = dgClient; dg.SelectAllCells(); dg.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader; ApplicationCommands.Copy.Execute(null, dg); dg.UnselectAllCells(); String result = (string)Clipboard.GetData(DataFormats.Text); try { StreamWriter sw = new StreamWriter("export.doc"); sw.WriteLine(result); sw.Close(); Process.Start("export.doc"); } catch (Exception ex) { } }
void _hook_OnMouseActivity(object sender, CustomMouseEventArgs e) { //Console.WriteLine(String.Format(">> {0}{1} - {2}{3}", e.Button, e.Clicks, DateTime.Now.ToString("HH:mm:ss"), Environment.NewLine)); if (e.Button == MouseButton.Left) { Thread.Sleep(100); keybd_event((byte)Keys.ControlKey, 0, 0, 0); //模拟按下ctrl keybd_event((byte)Keys.C, 0, 0, 0); //模拟按下c keybd_event((byte)Keys.ControlKey, 0, 2, 0); //模拟松开ctrl keybd_event((byte)Keys.C, 0, 2, 0); //模拟松开c Thread.Sleep(100); SearchWord(Clipboard.GetText()); //Clipboard.Clear(); } }
protected override void EndProcessing() { ExecuteWrite(delegate { switch (ParameterSetName) { case ParamSetFiles: if (_paths.Count == 0) { WinFormsClipboard.Clear(); } else { WinFormsClipboard.SetFileDropList(_paths); } break; case ParamSetImage: if (_image == null) { WinFormsClipboard.Clear(); } else { WinFormsClipboard.SetImage(_image); } break; case ParamSetRtf: SetTextContents(_rtf, TextDataFormat.Rtf); break; case ParamSetHtml: SetTextContents(_html, TextDataFormat.Html); break; default: SetTextContents(_text, TextDataFormat.UnicodeText); break; } }); }
/// <summary> /// 获取剪切板文本 /// </summary> public static string GetClipboard() { string text = null; Thread th = new Thread(new ThreadStart(delegate() { try { text = Clipboard.GetText(); } catch (Exception ex) { LogUtil.Log(ex); } })); th.TrySetApartmentState(ApartmentState.STA); th.Start(); th.Join(); return(text); }
public void LoadMe() { clip = new Clipboard(); clip.isFilled = false; if (ME3Directory.gamePath != null) { pathME3exe = ME3Directory.gamePath + @"Binaries\Win32\MassEffect3.exe"; pathBIOGame = ME3Directory.gamePath + @"BIOGame\"; pathCooked = ME3Directory.cookedPath; Println("Found MassEffect3.exe : " + pathME3exe); Println("Cooked Folder : " + pathCooked); Println("Loading files..."); LoadFileNames(); } else { MessageBox.Show("This tool requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); this.Close(); } }
/// <summary> /// 复制文本到剪切板 /// </summary> public static bool SetClipboard(string text) { var result = false; var thread = new Thread(new ThreadStart(delegate() { try { Clipboard.SetText(text); result = true; } catch (Exception ex) { LogUtil.Log(ex); } })); thread.TrySetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); return(result); }
/// <summary> /// Handles the KeyUp event of the richTextBoxMessage control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param> void FlexibleMessageBoxForm_KeyUp(object sender, KeyEventArgs e) { //Handle standard key strikes for clipboard copy: "Ctrl + C" and "Ctrl + Insert" if (e.Control && (e.KeyCode == Keys.C || e.KeyCode == Keys.Insert)) { var buttonsTextLine = (this.button1.Visible ? this.button1.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty) + (this.button2.Visible ? this.button2.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty) + (this.button3.Visible ? this.button3.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty); //Build same clipboard text like the standard .Net MessageBox var textForClipboard = STANDARD_MESSAGEBOX_SEPARATOR_LINES + this.Text + Environment.NewLine + STANDARD_MESSAGEBOX_SEPARATOR_LINES + this.richTextBoxMessage.Text + Environment.NewLine + STANDARD_MESSAGEBOX_SEPARATOR_LINES + buttonsTextLine.Replace("&", string.Empty) + Environment.NewLine + STANDARD_MESSAGEBOX_SEPARATOR_LINES; //Set text in clipboard Clipboard.SetText(textForClipboard); } }
public static object GetData(string format) { return(ClipboardProxy.GetData(format)); }
public static Stream GetAudioStream() { return(ClipboardProxy.GetAudioStream()); }
public static bool ContainsText(TextDataFormat format) { return(ClipboardProxy.ContainsText(format)); }
public static bool ContainsText() { return(ClipboardProxy.ContainsText()); }
public static bool ContainsImage() { return(ClipboardProxy.ContainsImage()); }
public static bool ContainsFileDropList() { return(ClipboardProxy.ContainsFileDropList()); }
private void Init() { // add event handlers pbMap.MouseDown += new MouseEventHandler(mapPicBox_MouseDown); pbMap.MouseMove += new MouseEventHandler(mapPicBox_MouseMove); pbMap.MouseUp += new MouseEventHandler(mapPicBox_MouseUp); this.KeyDown += new KeyEventHandler(d2dMapEditor_KeyDown); this.KeyPreview = true; FormClosing += new FormClosingEventHandler(D2DMapEditor_FormClosing); // create tooltips for tools ToolTip toolTips = new ToolTip(); toolTips.AutoPopDelay = 5000; toolTips.InitialDelay = 500; toolTips.ReshowDelay = 500; toolTips.ShowAlways = true; toolTips.SetToolTip(btnToolSelection, "Selection(S)"); toolTips.SetToolTip(btnToolBrush, "Brush(B)"); toolTips.SetToolTip(btnToolEraser, "Eraser(E)"); toolTips.SetToolTip(btnToolFill, "Fill(F)"); toolTips.SetToolTip(btnToolSelectTile, "Select Tile(T)"); toolTips.SetToolTip(btnAddLayer, "Add Layer"); toolTips.SetToolTip(btnDeleteLayer, "Delete Layer"); toolTips.SetToolTip(btnLayerMoveUp, "Move Up"); toolTips.SetToolTip(btnLayerMoveDown, "Move Down"); cbTileType.DataSource = Tile.TileTypeStr; lvTileLibrary.View = View.Tile; _map_info = new MapInfo(); // select brush as default tool SelectTool(ToolType.brush); _history = new History(); undoToolStripMenuItem.Enabled = false; redoToolStripMenuItem.Enabled = false; _clipboard = new Clipboard(); pasteToolStripMenuItem.Enabled = false; saveMapToolStripMenuItem.Enabled = false; _tile_library = new Tile[0]; }