Skip to content

Commit a432930

Browse files
committed
POC version
1 parent 2a79fd8 commit a432930

File tree

4 files changed

+202
-0
lines changed

4 files changed

+202
-0
lines changed

Plugin.TypeClipboard/Class1.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using RdcMan;
2+
using System.Windows.Forms;
3+
using System.Xml;
4+
using System.ComponentModel.Composition;
5+
using System.Reflection;
6+
using System;
7+
using System.Text.RegularExpressions;
8+
9+
namespace Plugin.TypeClipboard
10+
{
11+
[Export(typeof(IPlugin))]
12+
public class TypeClipboard : IPlugin
13+
{
14+
Server TargetServer = null;
15+
16+
public void OnContextMenu(System.Windows.Forms.ContextMenuStrip contextMenuStrip, RdcTreeNode node)
17+
{
18+
if ((node as GroupBase) == null)
19+
{
20+
if ((node as ServerBase) != null)
21+
{
22+
this.TargetServer = node as Server;
23+
ToolStripMenuItem NewMenuItem = new DelegateMenuItem("Type clipboard text", MenuNames.None, () => this.TypeClipboardText());
24+
//NewMenuItem.Image = Properties.Resources.PowerShell5_32;
25+
26+
contextMenuStrip.Items.Insert(contextMenuStrip.Items.Count - 1, NewMenuItem);
27+
contextMenuStrip.Items.Insert(contextMenuStrip.Items.Count - 1, new ToolStripSeparator());
28+
}
29+
}
30+
}
31+
32+
public void OnDockServer(ServerBase server)
33+
{
34+
//MessageBox.Show("OnDockServer", "Plugin.TypeClipboard event", MessageBoxButtons.OK, MessageBoxIcon.Information);
35+
}
36+
37+
public void OnUndockServer(IUndockedServerForm form)
38+
{
39+
//MessageBox.Show("OnUndockServer", "Plugin.TypeClipboard event", MessageBoxButtons.OK, MessageBoxIcon.Information);
40+
}
41+
42+
public void PostLoad(IPluginContext context)
43+
{
44+
//MessageBox.Show("PostLoad", "Plugin.TypeClipboard event", MessageBoxButtons.OK, MessageBoxIcon.Information);
45+
}
46+
47+
public void PreLoad(IPluginContext context, XmlNode xmlNode)
48+
{
49+
//MessageBox.Show("PreLoad", "Plugin.TypeClipboard event", MessageBoxButtons.OK ,MessageBoxIcon.Information);
50+
}
51+
52+
public XmlNode SaveSettings()
53+
{
54+
//MessageBox.Show("SaveSettings", "Plugin.TypeClipboard event", MessageBoxButtons.OK, MessageBoxIcon.Information);
55+
return null;
56+
}
57+
58+
public void Shutdown()
59+
{
60+
//MessageBox.Show("Shutdown", "Plugin.TypeClipboard event", MessageBoxButtons.OK, MessageBoxIcon.Information);
61+
}
62+
63+
public void TypeClipboardText()
64+
{
65+
if(!this.TargetServer.IsConnected) {
66+
//MessageBox.Show("Not connected...", "Not connected...", MessageBoxButtons.OK, MessageBoxIcon.Error);
67+
return;
68+
}
69+
MethodInfo FocusMethod = this.TargetServer.GetType().GetMethod("Focus", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
70+
FocusMethod.Invoke(this.TargetServer, null);
71+
72+
string StuffToType = Clipboard.GetText();
73+
//MessageBox.Show(StuffToType, "StuffToType", MessageBoxButtons.OK, MessageBoxIcon.Information);
74+
75+
// Escape special chars which SendKeys is looking for:
76+
// https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys(v=vs.110).aspx
77+
string StuffToTypeEscaped = Regex.Replace(StuffToType, "[+^%~(){}]", "{$0}");
78+
79+
// Replace newlines with enter
80+
StuffToTypeEscaped = Regex.Replace(StuffToTypeEscaped, "\r\n?", "~");
81+
82+
//MessageBox.Show(StuffToTypeEscaped, "StuffToTypeEscaped", MessageBoxButtons.OK, MessageBoxIcon.Information);
83+
SendKeys.SendWait(StuffToTypeEscaped);
84+
}
85+
}
86+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{0959BCA8-6ABC-4F11-915A-D2A36392EFF9}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Plugin.TypeClipboard</RootNamespace>
11+
<AssemblyName>Plugin.TypeClipboard</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="RDCMan">
34+
<HintPath>C:\Program Files (x86)\Microsoft\Remote Desktop Connection Manager\RDCMan.exe</HintPath>
35+
</Reference>
36+
<Reference Include="System" />
37+
<Reference Include="System.ComponentModel.Composition" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Windows.Forms" />
40+
<Reference Include="System.Xml.Linq" />
41+
<Reference Include="System.Data.DataSetExtensions" />
42+
<Reference Include="Microsoft.CSharp" />
43+
<Reference Include="System.Data" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="Class1.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
</ItemGroup>
50+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
51+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
52+
Other similar extension points exist, see Microsoft.Common.targets.
53+
<Target Name="BeforeBuild">
54+
</Target>
55+
<Target Name="AfterBuild">
56+
</Target>
57+
-->
58+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.TypeClipboard", "Plugin.TypeClipboard.csproj", "{0959BCA8-6ABC-4F11-915A-D2A36392EFF9}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{0959BCA8-6ABC-4F11-915A-D2A36392EFF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0959BCA8-6ABC-4F11-915A-D2A36392EFF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0959BCA8-6ABC-4F11-915A-D2A36392EFF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0959BCA8-6ABC-4F11-915A-D2A36392EFF9}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Plugin.TypeClipboard")]
9+
[assembly: AssemblyDescription("Remote Desktop Connection Manager - TypeClipboard plugin")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Plugin.TypeClipboard")]
13+
[assembly: AssemblyCopyright("")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("0959bca8-6abc-4f11-915a-d2a36392eff9")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("0.0.1.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)