| 赞 | 23 |
| VIP | |
| 好人卡 | |
| 积分 | 31 |
| 经验 | |
| 最后登录 | 2026-8-4 |
| 在线时间 | 1054 小时 |
- 梦石
- 0
- 星屑
- 3069
- 在线时间
- 1054 小时
- 注册时间
- 2011-8-16
- 回帖
- 223
|
发表于 2018-12-6 18:40:56
|
显示全部楼层
- module Input
-
- RES_KEY = Input::F5
- HWND = Win32API.new('user32', 'GetActiveWindow', nil, 'l').call
- SetWindowPos = Win32API.new('user32', 'SetWindowPos', 'lliiiii', 'i')
- GetSystemMetrics = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
-
- @state = 0
-
- class << self
- alias update_res update
- def update
- if Input.trigger?(RES_KEY)
- case @state
- when 0
- @state = 1
- set_window(960, 640)
- when 1
- @state = 2
- set_window(1280, 960)
- when 2
- @state = 0
- set_window(640, 480)
- end
- end
- update_res
- end
-
- def set_window(w, h)
- x = (GetSystemMetrics.call(0) - w) / 2
- y = (GetSystemMetrics.call(1) - h) / 2
- h += GetSystemMetrics.call(4)
- SetWindowPos.call(HWND, 0, x, y, w, h, 0x0020)
- end
- end
- end
复制代码
以上代码能更改窗口分辨率,但是无法同时拉伸窗口内容。 |
评分
-
查看全部评分
|