Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?
Save up to 50% on our desktop apps during our Year End Sale!Save up to 50% on our desktop apps during our Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our Year End Sale!

Paste by Typing

Description
This macro will enter the clipboard text using SendKeys to type it out, instead of doing a normal paste.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
Sep 14, 2016
Date Last Modified
Sep 14, 2016

Macro Code

using System;
using System.Text;

public static class ClipboardFusionHelper
{
	public static string ProcessText(string text)
	{
		BFS.General.ThreadWait(2000);
		StringBuilder sendKeyString = new StringBuilder();
		bool isShiftDown = false;
		foreach(char c in text)
		{
			//smart shift syntax building for letters
			if(char.IsLetter(c) || c == ' ')
			{
				if(char.IsUpper(c) && isShiftDown)
				{
					sendKeyString.Append(c);
					continue;
				}
				
				if(char.IsUpper(c) && !isShiftDown)
				{
					isShiftDown = true;
					sendKeyString.Append("+(").Append(c);
					continue;
				}
				
				if(char.IsLower(c) && isShiftDown)
				{
					isShiftDown = false;
					sendKeyString.Append(')').Append(char.ToUpperInvariant(c));
					continue;
				}
				
				if(char.IsLower(c) && !isShiftDown)
				{
					sendKeyString.Append(char.ToUpperInvariant(c));
					continue;
				}
			}
			
			if(char.IsDigit(c))
			{
				if(isShiftDown)
				{
					isShiftDown = false;
					sendKeyString.Append(')').Append(c);
					continue;
				}
				
				sendKeyString.Append(c);
				continue;
			}
			
			//turn off smart shift here
			if(isShiftDown)
			{
				isShiftDown = false;
				sendKeyString.Append(')');
			}
			
			//this part will only work with en-us keyboards
			switch(c)
			{
				case '~':
					sendKeyString.Append("+(`)");
					break;
				case '!':
					sendKeyString.Append("+(1)");
					break;
				case '@':
					sendKeyString.Append("+(2)");
					break;
				case '#':
					sendKeyString.Append("+(3)");
					break;
				case '$':
					sendKeyString.Append("+(4)");
					break;
				case '%':
					sendKeyString.Append("+(5)");
					break;
				case '^':
					sendKeyString.Append("+(6)");
					break;
				case '&':
					sendKeyString.Append("+(7)");
					break;
				case '*':
					sendKeyString.Append("+(8)");
					break;
				case '(':
					sendKeyString.Append("+(9)");
					break;
				case ')':
					sendKeyString.Append("+(0)");
					break;
				case '_':
					sendKeyString.Append("+(-)");
					break;
				case '+':
					sendKeyString.Append("+(=)");
					break;
				case '{':
					sendKeyString.Append("+([)");
					break;
				case '}':
					sendKeyString.Append("+(])");
					break;
				case '|':
					sendKeyString.Append("+(\\)");
					break;
				case ':':
					sendKeyString.Append("+(;)");
					break;
				case '"':
					sendKeyString.Append("+(')");
					break;
				case '<':
					sendKeyString.Append("+(,)");
					break;
				case '>':
					sendKeyString.Append("+(.)");
					break;
				case '?':
					sendKeyString.Append("+(/)");
					break;				
				default:
					sendKeyString.Append(c);
					break;
			}
		}
		
		BFS.Input.SendKeys(sendKeyString.ToString());
		return text;
	}
}