Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsInput;
- namespace TesteLibrary
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll", SetLastError = true)]
- static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
- [DllImport("user32.dll")]
- private static extern bool SetForegroundWindow(IntPtr hWnd);
- [DllImport("user32.dll")]
- private static extern IntPtr SendMessage(IntPtr hWnd, int Msg,
- IntPtr wParam, IntPtr lParam);
- [DllImport("user32.dll", EntryPoint = "WindowFromPoint",
- CharSet = CharSet.Auto, ExactSpelling = true)]
- public static extern IntPtr WindowFromPoint(Point point);
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- IntPtr hWnd = (IntPtr)FindWindow("notepad.exe", null);
- SetForegroundWindow(hWnd);
- //InputSimulator.SimulateKeyPress(VirtualKeyCode.F1);
- var screenPoint = this.PointToScreen(new Point(1210, 460));
- var handle = WindowFromPoint(screenPoint);
- if (handle != IntPtr.Zero)
- {
- SendMessage(handle, 0x0204, IntPtr.Zero, IntPtr.Zero);
- SendMessage(handle, 0x0205, IntPtr.Zero, IntPtr.Zero);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement