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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
module Kernel GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L") GetWindow = Win32API.new("user32", "GetWindow", "LL", "L") GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L") GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L") GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L") def get_hWnd threadID = GetCurrentThreadId.call hWnd = GetWindow.call(GetForegroundWindow.call, 0) while hWnd != 0 if threadID == GetWindowThreadProcessId.call(hWnd, 0) className = " " * 11 GetClassName.call(hWnd, className, 12) break if className == "RGSS Player" end hWnd = GetWindow.call(hWnd, 2) end return hWnd end end module Kernel Console = Win32API.new('kernel32', 'AllocConsole', 'v', 'v').call Conout = File.open("CONOUT$", "w") def p(str) Conout.write str.inspect Conout.write "\n" Conout.flush end def show_console _console_switch end def hide_console _console_switch(false) end def _console_switch(show = true) Win32API.new('user32', 'ShowWindow', 'll', 'l').call( Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, show ? 5 : 0 ) end def facus_this hWnd = Kernel.get_hWnd Win32API.new('user32', 'SetForegroundWindow', 'l', 'l').call( hWnd ) end end facus_this
|