protected override void OnLoad(EventArgs e) { base.OnLoad(e); proc = ForeignProcess.Get(Target); hookResults = WMKeyDownHook.Get(proc, Target); hookResults .ObserveOn(this) .Subscribe( t => listBox1.Items.Add(t), () => Close() ); }
public Form1() { InitializeComponent(); var demoProcess = Process.GetProcessesByName("Itp.Win32.DemoMdiApplication").SingleOrDefault(); if (demoProcess != null) { window = ForeignMdiWindow.Get(demoProcess); } else { foreach (var a in this.Controls.Cast <Control>()) { if (a == btHookNotepad || a == btHookWpf) { // no-op } else { a.Enabled = false; } } } var demoWpfProcess = Process.GetProcessesByName("Itp.Win32.DemoWpfTarget").SingleOrDefault(); if (demoWpfProcess != null) { wpfWindow = ForeignProcess.Get(demoWpfProcess); wpfWindowIntPtr = demoWpfProcess.MainWindowHandle; } else { btHookWpf.Enabled = false; } }