c# - 如何移动其他应用程序但又不将它们重叠在一起
问题描述
我已经想出了如何移动多个窗口的方法,但是我遇到了一个问题,所有这些窗口都相互重叠,就像这样: 但我希望它是这样的: 我也尝试过做一个记事本实例,但我不能想不通
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);
}
}
}
}
解决方案
推荐阅读
- jenkins - 使用 Jenkins 监控外部事件作业进度
- python - 搜索多个页面进行匹配
- docker - Docker: 引起: java.nio.file.FileSystemException: ./conf/flow.xml.gz: 资源繁忙
- javascript - 如何过滤此数组中大于或等于 90 的标记?
- java - Twitter4J sendDirectMessage 返回页面不存在
- python - 如何使用seaborn绘制彼此相邻的独立图?
- c++ - 为什么 sscanf 不能从一个字符串中读取 uint64_t 和 char?
- angular - 在使用 Angular 5 在 AWS s3 中创建存储桶时设置 CORS
- java - replaceAll 粘贴部分不必要的额外字符串
- sql-server - 如何在 MS Access 和 SQL Server 上获得相同的 UPDATE 查询结果