SUPERCAT.DEV

Benvenut* sul mio blog

CSHARP

Scrolla su altro processo

20-09-2024

Tramite C# scrolla su un altro processo

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace PROVAKEYBOARD
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        public void Send()
        {
            System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("msedge"); //search for process notepad

            foreach (var x in p)
            {
                if (x.MainWindowTitle.StartsWith("Home | supercat.dev"))
                {
                    SetForegroundWindow(x.MainWindowHandle);
                    SendKeys.SendWait("{PGDN}");
                }
            }
        }

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // METTERE IL BROWSER APERTO SULLA SCHEDA
            Send();
        }
    }
}