Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; rcons
- EnableExplicit
- Global WindowW,WindowH,*ActiveWnd,*wrapperWnd,*ShellWnd,*rconsWnd
- Define Hotkey,HotkeyModifier,HideOnStart,RollEffects,HideScroll,ToolWindow,Transparency,TransparencyValue,Offset
- Define Shell.s,ShellParams.s,WorkDir.s
- Global hidden
- Global RunDir.s = GetPathPart(ProgramFilename())
- ExamineDesktops()
- WindowW = DesktopWidth(0)
- IncludeFile "prefs.pb"
- IncludeFile "proc.pb"
- *ShellWnd = SpawnShell(Shell,ShellParams,WorkDir,#SW_HIDE)
- If ToolWindow
- *rconsWnd = OpenWindow(0,0,0,WindowW,WindowH,"rcons",#PB_Window_Tool)
- Else
- *rconsWnd = OpenWindow(0,0,0,WindowW,WindowH,"rcons",#PB_Window_BorderLess)
- EndIf
- RegisterHotKey_(*rconsWnd,0,HotkeyModifier,Hotkey)
- hidden = 0
- If *rconsWnd
- SetWindowColor(0,$000000)
- SetParent_(*ShellWnd,*rconsWnd)
- Define rc.RECT
- SetWindowPos_(*ShellWnd,#HWND_NOTOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
- SetWindowPos_(*ShellWnd,#HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
- SetWindowLong_(*ShellWnd,#GWL_STYLE,GetWindowLong_(*ShellWnd,#GWL_STYLE)&~#WS_SIZEBOX)
- ShowWindow_(*ShellWnd,#SW_MAXIMIZE)
- GetWindowRect_(*ShellWnd,rc.RECT)
- ShowWindow_(*ShellWnd,#SW_NORMAL)
- SetWindowPos_(*ShellWnd,0,-GetSystemMetrics_(#SM_CXFRAME)-Offset,-(GetSystemMetrics_(#SM_CYFRAME)+GetSystemMetrics_(#SM_CYCAPTION))-Offset,rc\right - rc\left,WindowH,#SWP_SHOWWINDOW)
- GetWindowRect_(*ShellWnd,rc.RECT)
- WindowH = rc\bottom-rc\top-2*GetSystemMetrics_(#SM_CYFRAME)-GetSystemMetrics_(#SM_CYCAPTION)-2*Offset
- SetWindowPos_(*rconsWnd,#HWND_TOPMOST,0,0,WindowW,WindowH,#SWP_NOMOVE)
- *wrapperWnd = OpenWindow(1,0,0,0,0,"rconswrapper",#PB_Window_BorderLess)
- SetWindowColor(1, $000000)
- SetParent_(*wrapperWnd,*rconsWnd)
- ; todo: vscroll hiding
- ;If HideScroll
- ;SetWindowPos_(*wrapperWnd,#HWND_TOP,rc\right-rc\left-2*GetSystemMetrics_(#SM_CXFRAME)-2*Offset-GetSystemMetrics_(#SM_CXVSCROLL),0,WindowW-rc\right-rc\left,WindowH,#SWP_NOZORDER)
- ;Else
- SetWindowPos_(*wrapperWnd,#HWND_TOP,rc\right-rc\left-2*GetSystemMetrics_(#SM_CXFRAME)-2*Offset,0,WindowW-rc\right-rc\left,WindowH,#SWP_NOZORDER)
- ;EndIf
- If Transparency
- SetWindowLong_(*rconsWnd,#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_LAYERED)
- SetLayeredWindowAttributes_(*rconsWnd,0,TransparencyValue,#LWA_ALPHA)
- EndIf
- RedrawWindow_(*ShellWnd, 0, 0, #RDW_INVALIDATE|#RDW_ERASE|#RDW_FRAME)
- SetWindowCallback(@ShellCallback())
- If HideOnStart
- hidden = 1
- SetWindowPos_(*rconsWnd, 0, 0, 0, 0, 0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_HIDEWINDOW)
- EndIf
- *ActiveWnd = GetActiveWindow_()
- Repeat
- Select WaitWindowEvent(100)
- Case #PB_Event_CloseWindow
- If IsWindow_(*ShellWnd)
- SetParent_(*ShellWnd,0)
- SendMessage_(*ShellWnd,#WM_CLOSE,0,0)
- EndIf
- CloseWindow(0)
- If *ActiveWnd And IsWindow_(*ActiveWnd)
- SetForegroundWindow_(*ActiveWnd)
- SetFocus_(*ActiveWnd)
- SetActiveWindow_(*ActiveWnd)
- EndIf
- Break
- Case #WM_HOTKEY
- If hidden
- *ActiveWnd = GetForegroundWindow_()
- hidden = 0
- SetWindowPos_(*ShellWnd, #HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
- If RollEffects
- SetWindowLong_(*rconsWnd,#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW)
- AnimateWindow_(*rconsWnd,200,#AW_VER_POSITIVE|#AW_SLIDE)
- Else
- SetWindowPos_(*rconsWnd,0,0,0,WindowW,WindowH,#SWP_NOMOVE|#SWP_SHOWWINDOW)
- EndIf
- RedrawWindow_(*ShellWnd, 0, 0, #RDW_INVALIDATE|#RDW_ERASE|#RDW_FRAME)
- SetForegroundWindow_(*rconsWnd)
- SetForegroundWindow_(*ShellWnd)
- SetFocus_(*ShellWnd)
- SetActiveWindow_(*ShellWnd)
- Else
- hidden = 1
- If RollEffects
- AnimateWindow_(*rconsWnd,200,#AW_HIDE|#AW_VER_NEGATIVE|#AW_SLIDE)
- EndIf
- SetWindowPos_(*rconsWnd, 0, 0, 0, 0, 0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_HIDEWINDOW)
- If *ActiveWnd And IsWindow_(*ActiveWnd)
- SetForegroundWindow_(*ActiveWnd)
- SetFocus_(*ActiveWnd)
- SetActiveWindow_(*ActiveWnd)
- EndIf
- EndIf
- EndSelect
- If Not IsWindow_(*ShellWnd)
- End
- EndIf
- ForEver
- EndIf
- End
- ; IDE Options = PureBasic 5.00 (Windows - x86)
- ; CursorPosition = 46
- ; EnableXP
- ; Executable = rcons.exe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement