protected override void EndProcessing() { ExecuteWrite(delegate { WinFormsClipboard.SetText(_output.ToString()); }); }
/// <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); } } }
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(); }
//[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(); }
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); } } }
/// <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); } }
private void metroButton1_Click(object sender, EventArgs e) { Clipboard.SetText(textBoxRecentlySSURL.Text); }
public void MeasurementReceived(BotEngine.Interface.FromProcessMeasurement <IMemoryMeasurement> measurement) { var ListUIElement = measurement?.Value?.EnumerateReferencedUIElementTransitive() ?.GroupBy(uiElement => uiElement.Id) ?.Select(group => group?.FirstOrDefault()) ?.ToArray(); //Classify("K346"); //return; var overview = measurement.Value.WindowOverview.First(); var entry = overview.ListView.Entry.Where(x => x.LabelText.ElementAt(2).Text.Contains("Wormhole")); var work = entry.First().LabelText; string ToSearch = entry.First().LabelText.ElementAt(2).Text.Split(' ')[1]; string Hole = string.Empty; Hole = (ToSearch.Contains("K162")) ? "UNK" : WormLib.Worm.GetHole(ToSearch); var ScanResult = measurement.Value.WindowProbeScanner.First().ScanResultView.Entry.First(); string ID = ScanResult?.LabelText.ElementAt(1).Text.Substring(0, 3); string ClipString = "{0} {1}"; ClipString = string.Format(ClipString, ID, Hole); RunAsStaThread(() => { Clipboard.SetText(ClipString); }); if (Hole.Equals("UNK")) { textBox1.Text = Classify(ClipString); RunAsStaThread(() => { Clipboard.SetText(textBox1.Text); }); } else { textBox1.Text = ClipString; } //{ //var id = Process.GetProcesses() //?.FirstOrDefault(pr => pr.MainWindowTitle.Contains("Sanderling")).Id; //SetForegroundWindow(Process.GetProcessById(id.Value).MainWindowHandle); //SendKeys.SendWait("{F5}"); //while (ClipString.Equals(Clipboard.GetText())) { Thread.Sleep(100); } //ClipboardString.Add(Clipboard.GetText()); //this.textBox1.Lines = ClipboardString.ToArray(); // this.textBox1.Text = ClipString; // string Rgx = ClipboardString.First(); // string sss = string.Empty; // if (System.Text.RegularExpressions.Regex.IsMatch(ClipboardString.Last().ToString(), @"medium")) // sss = Rgx.Replace("UNK", "C1"); // if (System.Text.RegularExpressions.Regex.IsMatch(ClipboardString.Last().ToString(), @"into unknown") && // !sss.Contains("C1")) // sss = Rgx.Replace("UNK", "C23"); // if (System.Text.RegularExpressions.Regex.IsMatch(ClipboardString.Last().ToString(), @"D|dangerous")) // sss = Rgx.Replace("UNK", "C45"); // if (System.Text.RegularExpressions.Regex.IsMatch(ClipboardString.Last().ToString(), @"D|deadly")) // sss = Rgx.Replace("UNK", "C6"); // //if (System.Text.RegularExpressions.Regex.IsMatch(ID, @"[A-Z]00\d") || // if(System.Text.RegularExpressions.Regex.IsMatch(ClipboardString.Last().ToString(), @"O|only the smallest")) // sss += ("F"); // if (System.Text.RegularExpressions.Regex.IsMatch(ClipboardString.Last().ToString(), @"reaching the end")) // sss = Rgx += " eol"; // if (string.IsNullOrEmpty(sss)) sss = ClipString; // RunAsSTAThread(() => { Clipboard.SetText(sss); }); // textBox1.Text = sss; //} //return; }
/// <summary> /// Handles keypresses, determines what element is being highlighted /// and send the selected element to the game window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hoverTimer_Tick(object sender, EventArgs e) { if (!Keyboard.GetKeyStates((Key)_settings.HotKey).HasFlag(KeyStates.Down)) { if (Visibility != Visibility.Hidden) { //Selection has ended. Now acting Visibility = Visibility.Hidden; if (_lastChosenPie == null) { return; } _lastChosenPie.ReactToMouseLeave(); SendKeys.SendWait("{ENTER}"); Clipboard.SetText(_lastChosenPie.FullText); SendKeys.SendWait("^v"); SendKeys.SendWait("{ENTER}"); } return; } if (Visibility == Visibility.Hidden) { Visibility = Visibility.Visible; User32.SetCursorPosition(Left + _chatWheelCenterLocation.X, Top + _chatWheelCenterLocation.Y); } //TODO: Clean up this area var mousePos = User32.GetMousePosition(); var mouseOffseted = mousePos; mouseOffseted.Offset(Left * -1, Top * -1); Console.WriteLine(mouseOffseted); if (_previousValidPos.X == 0) { _previousValidPos = _chatWheelCenterLocation; } //Recenter if too far away var distance = Utils.Distance2D(_chatWheelCenterLocation, mouseOffseted); if (distance > 90) { User32.SetCursorPosition((int)_previousValidPos.X, (int)_previousValidPos.Y); } else { _previousValidPos = mousePos; } //Ignore nodes if mouse is in the center of the circle if (distance < 30) { if (_lastChosenPie != null) { _lastChosenPie.ReactToMouseLeave(); } _lastChosenPie = null; return; } //Todo: optimize by generating a list of piepieces foreach (var obj in chatWheelCanvas.Children) { if ((obj.GetType() != typeof(PiePiece))) { continue; } var pie = obj as PiePiece; if (pie.IsAngleOnControl( Utils.FindAngleBetweenPoints (new Point(_chatWheelCenterLocation.X, 0), _chatWheelCenterLocation, mouseOffseted))) { pie.ReactToMouseEnter(); _lastChosenPie = pie; } else { pie.ReactToMouseLeave(); } } }
//отправляем сообщения всем выделенным чатам private void sendAllMessages(object sender, RoutedEventArgs e) { //открыть всем в VK //List<PersonChat> resevers = new List<PersonChat>(); //foreach (KeyValuePair<string, PersonChat> kvp in personWindows) //{ // PersonChat pc = kvp.Value; // if (!pc.banned) // { // resevers.Add(pc); // } //} //if (resevers.Count == 0) //{ // return; //}\ if (stage != StageEnum.CHOSEN) { return; } string startMessage = ""; OpenPhrase phrase = new OpenPhrase(debug); phrase.ShowDialog(); startMessage = phrase.startMessage; Clipboard.SetText(startMessage); //SendAll(startMessage, true); playedTime = DateTime.Now; //stage = StageEnum.LAUCHED; //баним List <String> bans = new List <string>(); List <String> bansId = new List <string>(); foreach (PersonModel p in Persons) { string domain = p.Domain; bans.Add(domain); bansId.Add(p.id.ToString()); } if (debug == false) { FileParser.setBanList(bansId); } //открываем vkокна int count = bans.Count; System.Diagnostics.Process.Start("http://google.com"); Thread.Sleep(2000); prepareBrouser(); int i = 0; while (i < count) { try { string domain = bans[i]; string url = "https://vk.com/" + domain; System.Diagnostics.Process.Start(url); } catch (Exception ex) { MessageBox.Show(ex.Message); } int stable = 10 * 1000; Random rnd = new Random(); int dice = rnd.Next(1, 1500); Thread.Sleep(stable + dice); i++; } //спим минутку перед написанием; Thread.Sleep(60 * 1000); //for (int k = Persons.Count - 1; k >= 0; k--) //{ // var p = Persons[k]; // if (p == null) // { // continue; // } // int j = Persons.IndexOf(p); // writeMessage(startMessage, j, p); //} //foreach (PersonModel p in Persons) //{ // if (p == null) // { // continue; // } // int j = Persons.IndexOf(p); // writeMessage(startMessage, j, p); //} }
/// <summary> /// Clears the clipboard and copies an HTML fragment to the clipboard, providing additional meta-information. /// </summary> /// <param name="htmlFragment">a html fragment</param> /// <param name="title">optional title of the HTML document (can be null)</param> /// <param name="sourceUrl">optional Source URL of the HTML document, for resolving relative links (can be null)</param> public static void CopyHtmlToClipboard(string htmlFragment, string title, Uri sourceUrl) { StringBuilder sb = new StringBuilder(); if (title == null) { title = "From Clipboard"; } // Builds the CF_HTML header. See format specification here: // http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp // The string contains index references to other spots in the string, so we need placeholders so we can compute the offsets. // The <<<<<<<_ strings are just placeholders. We'll backpatch them actual values afterwards. // The string layout (<<<) also ensures that it can't appear in the body of the html because the < // character must be escaped. string header = @"Format:HTML Format Version:1.0 StartHTML:<<<<<<<1 EndHTML:<<<<<<<2 StartFragment:<<<<<<<3 EndFragment:<<<<<<<4 StartSelection:<<<<<<<3 EndSelection:<<<<<<<3 "; string pre = @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""> <HTML><HEAD><TITLE>" + title + @"</TITLE></HEAD><BODY><!--StartFragment-->"; string post = @"<!--EndFragment--></BODY></HTML>"; sb.Append(header); if (sourceUrl != null) { sb.AppendFormat("SourceURL:{0}", sourceUrl); } int startHTML = sb.Length; sb.Append(pre); int fragmentStart = sb.Length; sb.Append(htmlFragment); int fragmentEnd = sb.Length; sb.Append(post); int endHTML = sb.Length; // Backpatch offsets sb.Replace("<<<<<<<1", To8DigitString(startHTML)); sb.Replace("<<<<<<<2", To8DigitString(endHTML)); sb.Replace("<<<<<<<3", To8DigitString(fragmentStart)); sb.Replace("<<<<<<<4", To8DigitString(fragmentEnd)); // Finally copy to clipboard. string data = sb.ToString(); WinFormsClipboard.Clear(); WinFormsClipboard.SetText(data, TextDataFormat.Html); }
public static void SetText(string text) { ClipboardProxy.SetText(text); }
public static void SetText(string text, TextDataFormat format) { ClipboardProxy.SetText(text, format); }
public void SendCommandToEmulator(String command) { var emulatorNotFound = true; foreach (var p in Process.GetProcesses()) { if (!p.ProcessName.Equals(processName)) { continue; } emulatorNotFound = false; var emulator = p.MainWindowHandle; // Decode the keypresses foreach (var k in command.Split(new[] { ',' })) { var key = k.Trim(); if (key.Length == 0) { continue; } switch (key) { case "{Text}": case "{Selection}": case "{CopyText}": case "{CopySelection}": var tmp = key.EndsWith("Text}") ? editor.Text : editor.Selection.Text; if (key.StartsWith("{Copy")) { Clipboard.SetText(tmp); } else { foreach (var c in tmp) { SendKeyToWindow(emulator, IntPtr.Zero, c); } } break; case "{Nop}": Thread.Sleep(1); break; case "{Focus}": SetForegroundWindow(emulator); break; case "{Show}": ShowWindow(emulator, 1); break; case "{Paste}": PostMessage(emulator, WM_COMMAND, (IntPtr)32801, IntPtr.Zero); break; case "{Wait}": for (int i = 0; i < 10; i++) { Thread.Sleep(10); Application.DoEvents(); } break; default: if (key.EndsWith("}")) { if (key.StartsWith("{Alert:")) { MessageBox.Show(key.Substring(7, key.Length - 8), "Alert"); continue; } if (key.StartsWith("{Question:")) { if ( MessageBox.Show(key.Substring(10, key.Length - 11), "Question", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } continue; } switch (key) { case "{ProgramName}": key = "\"" + CurrentProgramName + "\""; break; case "{RandomChar}": key = "\"" + (char)_random.Next('a', 'z' + 1) + "\""; break; case "{RandomCHAR}": key = "\"" + (char)_random.Next('A', 'Z' + 1) + "\""; break; case "{RandomNumber}": key = "\"" + (char)_random.Next('0', '9' + 1) + "\""; break; } } if (key.StartsWith("\"") && key.EndsWith("\"")) { foreach (var c in key.Substring(1, key.Length - 2)) { SendKeyToWindow(emulator, IntPtr.Zero, c); } } bool keyUp = true, keyDown = true; if (key.EndsWith("_up")) { keyDown = false; key = key.Substring(0, key.Length - 3); } else if (key.EndsWith("_down")) { keyUp = false; key = key.Substring(0, key.Length - 5); } Keys pressedKey; if (Enum.TryParse(key, out pressedKey)) { SendKeyToWindow(emulator, (IntPtr)pressedKey, char.MinValue, keyUp, keyDown); } break; } } } if (emulatorNotFound) { if (!String.IsNullOrEmpty(_parent.EmulatorExeFile)) { var p = Process.Start(_parent.EmulatorExeFile); p.WaitForInputIdle(1000); Thread.Sleep(100); SendCommandToEmulator(command); } else { MessageBox.Show("The emulator is not running, and it seems it is not available in this system.", "Run Emulator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }