0

I have figured out how to move windowses, multiple of them, but I have this problem where all of them overlap each other, like this: enter image description here But I want it to be like this: enter image description here I also tried doing a single instance of notepad but I couldn't figure out.

using System;
using System.Diagnostics;
using System.Windows.Forms;

using WindowScrape.Types;

namespace test
{
    public partial class Form1 : Form
    {
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

        private void Form1_Load(object sender, EventArgs e)
        {

            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            uint SWP_NOSIZE = 0x0001;

            foreach (Process process in Process.GetProcessesByName("notepad"))
            {
                var lol = HwndObject.GetWindowByTitle(process.MainWindowTitle);

                var x = lol.Location.X;
                var y = lol.Location.Y;

                SetWindowPos(process.MainWindowHandle, 0, x + rnd.Next(0, 1), y + rnd.Next(0, 1), 0, 0, SWP_NOSIZE);
            }
        }
    }
}
  • Have you tried adding bigger values to X and Y - you may not notice what's happening if it's just moving them by a single pixel – Rikalous Sep 17 '21 at 14:46
  • No, but whenever I move the notepad window, the other instances of the notepad follows the one that I am moving. So I don't think it's something with adding bigger values. – rainbowisrainbow Sep 17 '21 at 15:02

0 Answers0