System.Windows.Forms.Clipboard.GetText()

Here are the examples of the csharp api class System.Windows.Forms.Clipboard.GetText() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

160 Examples 7

1. Example

Project: SeleniumBasic
Source File: ClipboardExt.cs
View license
public static string GetText() {
            string result = ThreadExt.RunSTA(() => {
                string text = Clipboard.GetText();
                return text;
            }, 6000);
            return result;
        }

2. Example

View license
private void toggleFormatClearButton_Click(object sender, EventArgs e)
        {
            try
   /n ..... /n //View Source file for more details /n }

3. Example

Project: Baka-MPlayer-old
Source File: UrlForm.cs
View license
private void pasteButton_Click(object sender, EventArgs e)
        {
            Url = Clipboard.GetText();
            urlTextbox.Focus();
        }

4. Example

Project: Rosin
Source File: JsonViewer.cs
View license
private void btnPaste_Click(object sender, EventArgs e)
        {
            txtJson.Text = Clipboard.GetText();
        }

5. Example

Project: DarkHider
Source File: Message.cs
View license
private void bunifuImageButton1_Click(object sender, EventArgs e)
        {
            SecretMessageBox2.Text = Clipboard.GetText();
        }

6. Example

Project: ActivityManager
Source File: FormMultiValue.cs
View license
private void ???????????ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintillaEditor.Selection.Text = Clipboard.GetText();
        }

7. Example

Project: fdotoolbox
Source File: ClipboardWrapper.cs
View license
public static string GetText()
		{
			// retry 2 times should be enough for read access
			try {
				return Clipboard.GetText();
			} catch (ExternalException) {
				return Clipboard.GetText();
			}
		}

8. Example

Project: FileHelpers
Source File: frmTextDiff.cs
View license
private void cmdPasteA_Click(object sender, EventArgs e)
        {
            txtTextA.Text = Clipboard.GetText();
        }

9. Example

Project: FileHelpers
Source File: frmTextDiff.cs
View license
private void cmdPasteB_Click(object sender, EventArgs e)
        {
            txtTextB.Text = Clipboard.GetText();
        }

10. Example

Project: MSniper
Source File: FConsole.cs
View license
private void MultiplePaste()
        {
            ReadOnly = true;
            CurrentLine = Clipboard.GetText();
            InputEnable = false;
        }

11. Example

View license
[Test]
        public void RestrictedProcessShouldNotBeAbleToWriteToClipboard()
        {
            const string WriteToClipboardSourceCode = @"using System;
using System.Windows.Forms;
class Program
{
    public static void Main()
    {
        Clipboard.SetText(""i did it"");
    }
}";
            var exePath = this.CreateExe("RestrictedProcessShouldNotBeAbleToWriteToClipboard.exe", WriteToClipboardSourceCode);

            var process = new RestrictedProcessExecutor();
            var result = process.Execute(exePath, string.Empty, 1500, 32 * 1024 * 1024);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Type == ProcessExecutionResultType.RunTimeError, "No exception is thrown!");
            Assert.AreNotEqual("i did it", Clipboard.GetText());
        }

12. Example

Project: monogameui
Source File: SystemSpecific.cs
View license
public static string GetClipboardText()
        {
            return System.Windows.Forms.Clipboard.GetText();
        }

13. Example

Project: tcp-gecko-dotnet
Source File: MainForm.cs
View license
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (AddressContextMenuOwner != null)
                AddressContextMenuOwner.Text = Clipboard.GetText();
            else if (HistoryContextMenuOwner != null)
                HistoryContextMenuOwner.Text = Clipboard.GetText();
        }

14. Example

Project: dnGrep
Source File: MainForm.cs
View license
private void btnSelectFolder_Click(object sender, EventArgs e)
		{
			fileFolderDialog.Dialog.Multiselect = true;
			fileFolderDialog.SelectedPath = Utils.GetBaseFolder(tbFolderName.Text);
			if (tbFolderName.Text == "")
			{
				string clipboard = Clipboard.GetText();
				try
				{
					if (Path.IsPathRooted(clipboard))
						fileFolderDialog.SelectedPath = clipboard;
				}
				catch (Exception ex)
				{
					// Ignore
				}
			}
			if (fileFolderDialog.ShowDialog() == DialogResult.OK)
			{
				if (fileFolderDialog.SelectedPaths != null) 
					tbFolderName.Text = fileFolderDialog.SelectedPaths;
				else
					tbFolderName.Text = fileFolderDialog.SelectedPath;
			}
		}

15. Example

Project: FTPbox
Source File: Translate.cs
View license
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var l = new List<string>(Clipboard.GetText().Split(new[] {Environment.NewLine}, StringSplitOptions.None));
            var i = data.SelectedCells[0].RowIndex;

            foreach (var s in l)
            {
                try
                {
                    data.Rows[i].Cells[1].Value = s;
                    i++;
                }
                catch
                {
                }
            }
        }

16. Example

View license
public static string GetURLOnClipboard()
        {
            string url = string.Empty;

            if (Clipboard.ContainsText())
            {
                string tempUrl = Clipboard.GetText();

                if (ResourceLocation.IsURL(tempUrl))
                {
                    url = tempUrl;
                }
                else
                {
                    tempUrl = null;
                }
            }

            return url;
        }

17. Example

Project: KeeThief
Source File: ClipboardUtil.cs
View license
public static string GetText()
		{
			if(!NativeLib.IsUnix()) // Windows
				return Clipboard.GetText();
			if(NativeLib.GetPlatformID() == PlatformID.MacOSX)
				return GetStringM();
			if(NativeLib.IsUnix())
				return GetStringU();

			Debug.Assert(false);
			return Clipboard.GetText();
		}

18. Example

Project: KeeThief
Source File: ClipboardUtil.Unix.cs
View license
private static string GetStringU()
		{
			// string strGtk = GtkGetString();
			// if(strGtk != null) return strGtk;

			// string str = NativeLib.RunConsoleApp("xclip",
			//	"-out -selection clipboard");
			// if(str != null) return str;

			string str = NativeLib.RunConsoleApp("xsel",
				"--output --clipboard", null, XSelFlags);
			if(str != null) return str;

			if(Clipboard.ContainsText())
				return (Clipboard.GetText() ?? string.Empty);

			return string.Empty;
		}

19. Example

Project: VncSharp
Source File: RemoteDesktop.cs
View license
public void FillServerClipboard()
        {
            FillServerClipboard(Clipboard.GetText());
        }

20. Example

Project: Histacom2
Source File: WinClassicTerminal.cs
View license
private void btnPaste_Click(object sender, EventArgs e)
        {
            if (Clipboard.GetText() != "")
                Write(Clipboard.GetText()); // Write the contents of the Clipboard text in the RichTextBox
            else
                wm.StartInfobox95("ERROR", "You need to have something in your clipboard to paste.", Engine.Template.InfoboxType.Error, Engine.Template.InfoboxButtons.OK); // Display an error message if the clipboard is null/empty
        }

21. Example

View license
private void btnPaste_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                txtAccessToken.Text = Clipboard.GetText();
            }
            DialogResult = DialogResult.OK;
        }

22. Example

Project: Repetier-Host
Source File: RepetierEditor.cs
View license
private void toolPaste_Click(object sender, EventArgs e)
        {
            InsertString(Clipboard.GetText());
        }

23. Example

Project: HostsFileEditor
Source File: MainForm.cs
View license
private void OnPasteClick(object sender, EventArgs e)
        {
            // HACK: If editing cell forward cut/copy/paste command
            // to editing control
            if (this.dataGridViewHostsEntries.IsCurrentCellInEditMode)
            {
                var keys = this.menuPaste.ShortcutKeys;
                this.menuPaste.ShortcutKeys = Keys.None;
                this.menuContextPaste.ShortcutKeys = Keys.None;
                SendKeys.SendWait("^(V)");
                this.menuPaste.ShortcutKeys = keys;
                this.menuContextPaste.ShortcutKeys = keys;
                return;
            }

            this.dataGridViewHostsEntries.CancelEdit();

            if (this.dataGridViewHostsEntries.SelectedRows.Count > 0 && 
                this.clipboardEntries != null)
            {
                HostsFile.Instance.Entries.Insert(
                    this.dataGridViewHostsEntries.CurrentHostEntry, 
                    this.clipboardEntries);

                this.clipboardEntries = null;
            }
            else
            {
                foreach (
                    DataGridViewCell cell in 
                    this.dataGridViewHostsEntries.SelectedCells)
                {
                    if (cell.ValueType == typeof(string))
                    {
                        cell.Value = Clipboard.GetText();
                    }
                }
            }
        }

24. Example

Project: ShareX
Source File: WebpageCaptureForm.cs
View license
private void CheckClipboardURL()
        {
            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (URLHelpers.IsValidURL(text))
                {
                    txtURL.Text = text;
                }
            }
        }

25. Example

Project: subtitleedit
Source File: Main.cs
View license
private void addParagraphAndPasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            addParagraphHereToolStripMenuItem_Click(sender, e);
            textBoxListViewText.Text = Clipboard.GetText();
        }

26. Example

Project: Clipboarder
Source File: MainFormPresenter.cs
View license
private TextContent getTextContentFromClipboard() {
            TextContent contentToReturn = new TextContent();

            contentToReturn.index = view.TextRowCount + 1;
            contentToReturn.text = Clipboard.GetText();
            contentToReturn.time = System.DateTime.Now.ToShortTimeString();

            return contentToReturn;
        }

27. Example

Project: NFirmwareEditor
Source File: ClipboardManager.cs
View license
[NotNull]
		public List<bool[,]> GetData()
		{
			var images = new List<bool[,]>();
			try
			{
				var buffer = Clipboard.GetText();
				var data = Serializer.Read<List<ExportedImage>>(buffer);
				if (data == null) return images;

				foreach (var exportedImage in data)
				{
					images.Add(ResourcePacksStorage.ReadImageFromAsciiString(exportedImage.Width, exportedImage.Height, exportedImage.DataString));
				}
				return images;
			}
			catch
			{
				return images;
			}
		}

28. Example

Project: nquery
Source File: LoadTableFromClipboard.cs
View license
public QueryContext CreateQueryContext()
		{
			
			string textFromClipboard = Clipboard.GetText();
			Parser parser = new Parser(textFromClipboard);
			DataTable dataTable = parser.ParseTable();
			dataTable.TableName = "Clipboard";

			Query query = new Query();
			query.DataContext.Tables.Add(dataTable);
			query.Text = "SELECT * FROM Clipboard";

			QueryContext queryContext = new QueryContext(query, "Clipboard");
			return queryContext;
		}

29. Example

View license
private void CheckClipboard()
        {
            if (cbClipboard.Visible &&
                Properties.Settings.Default.CheckClipboard)
            {
                if (Clipboard.ContainsText())
                {
                    txtLinks.Text = Clipboard.GetText();                    
                }
            }
        }

30. Example

Project: Wolven-kit
Source File: frmModExplorer.cs
View license
private void contextMenu_Opened(object sender, EventArgs e)
        {
            pasteToolStripMenuItem.Enabled = File.Exists(Clipboard.GetText());
        }

31. Example

Project: ReoGrid
Source File: ClipboardEventDemo.cs
View license
void grid_BeforePaste(object sender, BeforeRangeOperationEventArgs e)
		{
			if (chkPreventPasteEvent.Checked || chkCustomizePaste.Checked)
			{
				e.IsCancelled = true;

				if (chkCustomizePaste.Checked)
				{
					string text = Clipboard.GetText();

					object[,] data = RGUtility.ParseTabbedString(text);

					// set a new range 
					var applyRange = new RangePosition(worksheet.SelectionRange.Row,
						worksheet.SelectionRange.Col,
						data.GetLength(0), data.GetLength(1));

					worksheet.SetRangeData(applyRange, data);

					worksheet.SetRangeStyles(applyRange, new WorksheetRangeStyle
					{
						Flag = PlainStyleFlag.BackAll,
						BackColor = Color.Yellow,
					});
				}
			}
		}

32. Example

Project: ReoGrid
Source File: ClipboardEventDemo.cs
View license
void grid_BeforePaste(object sender, BeforeRangeOperationEventArgs e)
		{
			if (chkPreventPasteEvent.Checked || chkCustomizePaste.Checked)
			{
				e.IsCancelled = true;

				if (chkCustomizePaste.Checked)
				{
					string text = Clipboard.GetText();

					object[,] data = RGUtility.ParseTabbedString(text);

					// ??????????????? 
					var applyRange = new RangePosition(worksheet.SelectionRange.Row,
						worksheet.SelectionRange.Col,
						data.GetLength(0), data.GetLength(1));

					worksheet.SetRangeData(applyRange, data);

					worksheet.SetRangeStyles(applyRange, new WorksheetRangeStyle
					{
						Flag = PlainStyleFlag.BackAll,
						BackColor = Color.Yellow,
					});
				}
			}
		}

33. Example

Project: xenadmin
Source File: Clip.cs
View license
private static void GetClipboard()
        {
            Program.AssertOffEventThread();

            try
            {
                if (Clipboard.ContainsText())
                {
                    string s = Clipboard.GetText();
                    if (s != ClipboardText)
                    {
                        ClipboardText = s;
                        Program.Invoke(Program.MainWindow, OnClipboardChanged);
                    }
                }
            }
            catch
            {
            }
            GettingClipboard = false;
        }

34. Example

Project: tcp-gecko-dotnet
Source File: AddressTextBox.cs
View license
public void CopyClipboardToHistory()
        {
            CopyStringToHistory(Clipboard.GetText());
        }

35. Example

Project: tcp-gecko-dotnet
Source File: HistoryTextBox.cs
View license
public void CopyClipboardToHistory()
        {
            CopyStringToHistory(Clipboard.GetText());
        }

36. Example

Project: tcp-gecko-dotnet
Source File: MainForm.cs
View license
private void pasteToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            String[] sep = Clipboard.GetText().Split(new char[] { '\r', '\n' });
            foreach (String entry in sep)
            {
                BreakpointCondition cond = BreakpointCondition.FromString(entry);
                if (cond != null)
                {
                    bpHandler.conditions.Add(cond);
                }
            }
        }

37. Example

Project: EvilFOCA
Source File: IPTextBox.cs
View license
protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {

                case 0x302: //WM_PASTE
                    {
                        string text = Clipboard.GetText();
                        if (ValidateIPFromString(text))
                            this.Text = text;
                        break;
                    }
            }
            base.WndProc(ref m);
        }

38. Example

Project: gitextensions
Source File: FormGoToCommit.cs
View license
private void SetCommitExpressionFromClipboard()
        {
            string text = Clipboard.GetText().Trim();
            if (text.IsNullOrEmpty())
            {
                return;
            }

            string guid = Module.RevParse(text);
            if (!string.IsNullOrEmpty(guid))
            {
                textboxCommitExpression.Text = text;
                textboxCommitExpression.SelectAll();
            }
        }

39. Example

Project: GKeyBank
Source File: Import.cs
View license
private void tsbpaste_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText()) txtsource.Text = Clipboard.GetText();
            else MessageBox.Show(Functions.Translation("No text found in the clipboard") + ".", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

40. Example

Project: gitter
Source File: ApplyPatchesDialog.cs
View license
private void OnAddFromClipboardClick(object sender, EventArgs e)
		{
			string patch = null;
			try
			{
				patch = Clipboard.GetText();
			}
			catch(Exception exc)
			{
				if(exc.IsCritical())
				{
					throw;
				}
			}
			if(!string.IsNullOrWhiteSpace(patch))
			{
				var src = new PatchFromString("Patch from clipboard", patch);
				AddPatchSource(src);
			}
		}

41. Example

Project: trizbort
Source File: CopyController.cs
View license
public ICopyObj PasteElements()
    {
      var clipboardText = Clipboard.GetText();

      ICopyObj xx;
      if (clipboardText.Contains("\"CopyType\": 1"))
      {
        xx = JsonConvert.DeserializeObject<CopyColorsObj>(clipboardText);
      }
      else
      {
        xx = JsonConvert.DeserializeObject<CopyObject>(clipboardText);
      }

      return xx;
    }

42. Example

Project: deeply
Source File: Program.cs
View license
private static string LoadSourceText(Options options)
        {
            switch (options.MetadataSource)
            {
                case "CONS":
                    return LoadSourceTextFromConsole();
                case "CLIP":
                    return Clipboard.GetText();
                default:
                    return File.ReadAllText(options.MetadataSource);
            }
        }

43. Example

Project: logwizard
Source File: test_syntax_form.cs
View license
private void test_syntax_form_Activated(object sender, EventArgs e) {
            if (ignore_) {
                // ignore first time - we're using the log lines from the existing log
                ignore_ = false;
                return;
            }

            // check clipboard - if non-empty, and more than 10 lines, use it
            string text = "";
            try {
                text = Clipboard.GetText();
            } catch {
            }
            text = util.normalize_enters(text);
            if (text.Split('\r').Length < LEAST_LINES)
                return;

            if (text == lines.Text)
                return;

            use_lines(text, syntax.Text);
        }

44. Example

Project: PKHeX
Source File: Main.cs
View license
private void ClickShowdownImportPKM(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            { WinFormsUtil.Alert("Clipboard does not contain text."); return; }

            // Get Simulator Data
            ShowdownSet Set = new ShowdownSet(Clipboard.GetText());

            if (Set.Species < 0)
            { WinFormsUtil.Alert("Set data not found in clipboard."); return; }

            if (Set.Nickname?.Length > C_SAV.SAV.NickLength)
                Set.Nickname = Set.Nickname.Substring(0, C_SAV.SAV.NickLength);

            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Import this set?", Set.Text))
                return;

            if (Set.InvalidLines.Any())
                WinFormsUtil.Alert("Invalid lines detected:", string.Join(Environment.NewLine, Set.InvalidLines));

            // Set Species & Nickname
            PKME_Tabs.LoadShowdownSet(Set);
        }

45. Example

Project: PKHeX
Source File: Main.cs
View license
private void ClickShowdownExportPKM(object sender, EventArgs e)
        {
            if (!PKME_Tabs.VerifiedPKM())
            {
                WinFormsUtil.Alert("Fix data before exporting.");
                return;
            }

            var text = PreparePKM().ShowdownText;
            Clipboard.SetText(text);
            var clip = Clipboard.GetText();
            if (clip != text)
                WinFormsUtil.Alert("Unable to set to Clipboard.", "Try exporting again.");
            else
                WinFormsUtil.Alert("Exported Showdown Set to Clipboard:", text);
        }

46. Example

Project: just-gestures
Source File: InternetOptions.cs
View license
private void SearchWeb()
        {
            System.Collections.ObjectModel.ReadOnlyCollection<ClipData> clipData = ClipboardHandler.GetClipboard();
            ExecuteKeyList(MouseAction.ModifierClick, m_location);
            System.Threading.Thread.Sleep(250);            
            string text = Clipboard.GetText(); //ClipboardHandler.GetClipboardText();
            Process myProcess = new Process();            
            myProcess.StartInfo.FileName = this.Details.Replace("(*)", text);
            myProcess.Start();

            ClipboardHandler.SetClipboard(clipData);
        }

47. Example

Project: just-gestures
Source File: KeystrokesOptions.cs
View license
private void CopyToClip()
        {
            //ReadOnlyCollection<ClipData> backup = ClipboardHandler.GetClipboard();
            //ClipboardHandler.EmptyClipboard();
            //KeyInput.ExecuteKeyInput(AllKeys.KEY_CONTROL_DOWN);
            //KeyInput.ExecuteKeyInput(AllKeys.KEY_C);
            //KeyInput.ExecuteKeyInput(AllKeys.KEY_CONTROL_UP);
            ExecuteKeyList(MouseAction.ModifierClick, m_location);
            System.Threading.Thread.Sleep(250);
            //SendKeys.SendWait("^c");
            //Win32.SendMessage(hwnd, Win32.WM_COPY, 0, 0);
            int index = int.Parse(this.Details);

            Form_engine.PrivateTextClipboards[index] = Clipboard.GetText();
            //Form_engine.PrivateClipboards[index] = ClipboardHandler.GetClipboard();
            
            
            //ClipboardHandler.EmptyClipboard();
            //ClipboardHandler.SetClipboard(backup);            

        }

48. Example

Project: ShinraMeter
Source File: KeyboardHook.cs
View license
private static void hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (/n ..... /n //View Source file for more details /n }

49. Example

Project: Youtube-downloader
Source File: MainForm.cs
View license
private void getClipboardData()
        {

            if (Clipboard.ContainsText())
            {
                Regex isUrl = new Regex("^https?://|^www"); //if it begins with http:// or https:// or www
                Match URLtest = isUrl.Match(Clipboard.GetText());
                if (URLtest.Success) //copy content from clipboard only if it begins with http:// or https:// or www
                {
                    txtURL.Text = Clipboard.GetText();
                }

            }
        }

50. Example

Project: ShareX
Source File: ExportImportControl.cs
View license
private void tsmiImportClipboard_Click(object sender, EventArgs e)
        {
            if (ImportRequested != null)
            {
                if (Clipboard.ContainsText())
                {
                    string json = Clipboard.GetText();
                    Import(json);
                }
            }
        }