-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRS_WindowManager.rb
48 lines (42 loc) · 1.7 KB
/
RS_WindowManager.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#================================================================
# The MIT License
# Copyright (c) 2020 biud436
# ---------------------------------------------------------------
# Free for commercial and non commercial use.
#================================================================
#==============================================================================
# ** WindowManager
# Desc : This script allows you to adjust the transparency for main program.
# Author : biud436
# Usage :
# You should add a new script above the section called '(Insert Here)' by
# copying script itself. You can add an new script command and try below code.
#
# WindowManager.alpha = x
#
# 'x' is a number between 0 and 255.
# If its value is close to with 255, it will absolutely set as an opaque.
#==============================================================================
$imported = {} if $imported.nil?
$imported["RS_WindowManager"] = true
module WindowManager
FindWindow = Win32API.new('User32','FindWindow',['P','P'],'L')
HWND = FindWindow.call('RGSS Player', 0)
GetWindowLong = Win32API.new('User32', 'GetWindowLong', ['L','L'],'L')
SetWindowLong = Win32API.new("User32", 'SetWindowLong', ['L','L','L'],'L')
ShowWindow = Win32API.new('User32','ShowWindow',['L','L'],'L')
SetLayered = Win32API.new('User32', 'SetLayeredWindowAttributes', ['L','L','L','L'],'L')
GWL_EXSTYLE = -20
LWA_ALPHA = 0x00000002
WS_EX_LAYERED = 0x00080000
def self.alpha=(args)
begin
if args.to_i.between?(0,255)
SetWindowLong.call(HWND,GWL_EXSTYLE,GetWindowLong.call(0,GWL_EXSTYLE) | WS_EX_LAYERED)
SetLayered.call(HWND,0,args,LWA_ALPHA);
ShowWindow.call(HWND,5)
end
rescue
end
end
end