using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern bool PostMessage(
IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);
public Form1()
{
InitializeComponent();
}
Button button1;
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
this.ClientSize = new Size(200, 40);
button1 = new Button();
button1.Text = "チャンネル変更";
button1.Size = new Size(200, 40);
button1.Click += new EventHandler(button1_Click);
this.Controls.Add(button1);
}
const int WM_KEYDOWN = 0x100;
void button1_Click(object sender, EventArgs e)
{
Process[] p = Process.GetProcessesByName("TVTest");
IntPtr hWnd = (IntPtr)p[0].MainWindowHandle;
PostMessage(hWnd, WM_KEYDOWN, (IntPtr)Keys.Right, IntPtr.Zero);
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkNvbXBvbmVudE1vZGVsOwp1c2luZyBTeXN0ZW0uRGF0YTsKdXNpbmcgU3lzdGVtLkRyYXdpbmc7CnVzaW5nIFN5c3RlbS5MaW5xOwp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLldpbmRvd3MuRm9ybXM7CnVzaW5nIFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlczsKdXNpbmcgU3lzdGVtLkRpYWdub3N0aWNzOwoKbmFtZXNwYWNlIFdpbmRvd3NGb3Jtc0FwcGxpY2F0aW9uMQp7CiAgICBwdWJsaWMgcGFydGlhbCBjbGFzcyBGb3JtMSA6IEZvcm0KICAgIHsKICAgICAgICBbRGxsSW1wb3J0KCJ1c2VyMzIuZGxsIiwgQ2hhclNldCA9IENoYXJTZXQuVW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