赞 | 86 |
VIP | 0 |
好人卡 | 1 |
积分 | 136 |
经验 | 14048 |
最后登录 | 2021-1-24 |
在线时间 | 2753 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 13562
- 在线时间
- 2753 小时
- 注册时间
- 2014-10-4
- 帖子
- 756
|
5楼
楼主 |
发表于 2018-2-6 16:40:42
|
只看该作者
本帖最后由 SixRC 于 2018-2-6 16:43 编辑
#随主窗口移动而移动 hm = Win32API.new('kernel32','GetModuleHandleA','p','l').call('RGSS103J') code = [139,68,36,4,139,128,196,182,18,0,139,64,8,194,16,0].pack('C*') $main_hwnd = Win32API.new('user32.dll','CallWindowProc','pllll','l').call(code,hm,0,0,0) xy = ' '*16 Win32API.new('user32','GetWindowRect','lp','v').call($main_hwnd,xy) $main_xy = xy.unpack('ll') class << Graphics GetWindowRect = Win32API.new('user32','GetWindowRect','lp','v') MoveWindow = Win32API.new('user32','MoveWindow','llllll','l') alias e_update update def update xy = ' '*16 GetWindowRect.call($main_hwnd,xy) if (xy1 = xy.unpack('ll')) != $main_xy GetWindowRect.call(Ewindow::Hwnd,xy) xy2 = xy.unpack('llll') MoveWindow.call(Ewindow::Hwnd,xy2[0]+xy1[0]-$main_xy[0], xy2[1]+xy1[1]-$main_xy[1], xy2[2]-xy2[0], xy2[3]-xy2[1],0) $main_xy = xy1 end e_update end end
#随主窗口移动而移动
hm = Win32API.new('kernel32','GetModuleHandleA','p','l').call('RGSS103J')
code = [139,68,36,4,139,128,196,182,18,0,139,64,8,194,16,0].pack('C*')
$main_hwnd = Win32API.new('user32.dll','CallWindowProc','pllll','l').call(code,hm,0,0,0)
xy = ' '*16
Win32API.new('user32','GetWindowRect','lp','v').call($main_hwnd,xy)
$main_xy = xy.unpack('ll')
class << Graphics
GetWindowRect = Win32API.new('user32','GetWindowRect','lp','v')
MoveWindow = Win32API.new('user32','MoveWindow','llllll','l')
alias e_update update
def update
xy = ' '*16
GetWindowRect.call($main_hwnd,xy)
if (xy1 = xy.unpack('ll')) != $main_xy
GetWindowRect.call(Ewindow::Hwnd,xy)
xy2 = xy.unpack('llll')
MoveWindow.call(Ewindow::Hwnd,xy2[0]+xy1[0]-$main_xy[0],
xy2[1]+xy1[1]-$main_xy[1],
xy2[2]-xy2[0],
xy2[3]-xy2[1],0)
$main_xy = xy1
end
e_update
end
end
把它插到子窗口的脚本前面就可以了
哪个或哪些个子窗口需要随着主窗口动而动就插过去
子窗口需要是后台运行的
原理是检测主窗口的位置 他动了子窗口就跟着动 所以每次update会刷新位置
子窗口自己移动不会影响主窗口 测试了下效率和效果蛮好的 |
|