wgestures吧 关注:886贴子:3,627
  • 2回复贴,共1

有没有大佬可以实现窗口以固定大小屏幕居中的功能?

只看楼主收藏回复

用ChatGPT写了一段Lua脚本没反应,如下:
function wgAction()
-- 定义目标窗口大小
local targetWidth = 800
local targetHeight = 600
-- 获取屏幕大小
local screenWidth = User32.GetSystemMetrics(0) -- SM_CXSCREEN = 0
local screenHeight = User32.GetSystemMetrics(1) -- SM_CYSCREEN = 1
-- 计算窗口应该放置的位置
local x = (screenWidth - targetWidth) / 2
local y = (screenHeight - targetHeight) / 2
-- 获取当前活动窗口的句柄
local hwnd = User32.GetForegroundWindow()
-- 设置窗口大小和位置
-- SWP_NOZORDER = 0x0004, SWP_NOACTIVATE = 0x0010
User32.SetWindowPos(hwnd, 0, x, y, targetWidth, targetHeight, 0x0004 + 0x0010)
end


IP属地:上海1楼2024-03-02 18:21回复
    这个好弄,你的代码运行正常不


    IP属地:广东来自Android客户端2楼2024-03-05 18:05
    回复
      我用了个专门的软件AltDrag


      IP属地:上海来自iPhone客户端3楼2024-04-21 23:14
      回复