Advertisement
deseven

rcons-main

Nov 9th, 2012
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; rcons
  2.  
  3. EnableExplicit
  4.  
  5. Global WindowW,WindowH,*ActiveWnd,*wrapperWnd,*ShellWnd,*rconsWnd
  6. Define Hotkey,HotkeyModifier,HideOnStart,RollEffects,HideScroll,ToolWindow,Transparency,TransparencyValue,Offset
  7. Define Shell.s,ShellParams.s,WorkDir.s
  8. Global hidden
  9. Global RunDir.s = GetPathPart(ProgramFilename())
  10.  
  11. ExamineDesktops()
  12. WindowW = DesktopWidth(0)
  13.  
  14. IncludeFile "prefs.pb"
  15. IncludeFile "proc.pb"
  16.  
  17. *ShellWnd = SpawnShell(Shell,ShellParams,WorkDir,#SW_HIDE)
  18.  
  19. If ToolWindow
  20.   *rconsWnd = OpenWindow(0,0,0,WindowW,WindowH,"rcons",#PB_Window_Tool)
  21. Else
  22.   *rconsWnd = OpenWindow(0,0,0,WindowW,WindowH,"rcons",#PB_Window_BorderLess)
  23. EndIf
  24.  
  25. RegisterHotKey_(*rconsWnd,0,HotkeyModifier,Hotkey)
  26.  
  27. hidden = 0
  28.  
  29. If *rconsWnd
  30.  
  31.   SetWindowColor(0,$000000)
  32.   SetParent_(*ShellWnd,*rconsWnd)
  33.   Define rc.RECT
  34.   SetWindowPos_(*ShellWnd,#HWND_NOTOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
  35.   SetWindowPos_(*ShellWnd,#HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
  36.   SetWindowLong_(*ShellWnd,#GWL_STYLE,GetWindowLong_(*ShellWnd,#GWL_STYLE)&~#WS_SIZEBOX)
  37.   ShowWindow_(*ShellWnd,#SW_MAXIMIZE)
  38.   GetWindowRect_(*ShellWnd,rc.RECT)
  39.   ShowWindow_(*ShellWnd,#SW_NORMAL)
  40.   SetWindowPos_(*ShellWnd,0,-GetSystemMetrics_(#SM_CXFRAME)-Offset,-(GetSystemMetrics_(#SM_CYFRAME)+GetSystemMetrics_(#SM_CYCAPTION))-Offset,rc\right - rc\left,WindowH,#SWP_SHOWWINDOW)
  41.   GetWindowRect_(*ShellWnd,rc.RECT)
  42.   WindowH = rc\bottom-rc\top-2*GetSystemMetrics_(#SM_CYFRAME)-GetSystemMetrics_(#SM_CYCAPTION)-2*Offset
  43.   SetWindowPos_(*rconsWnd,#HWND_TOPMOST,0,0,WindowW,WindowH,#SWP_NOMOVE)
  44.   *wrapperWnd = OpenWindow(1,0,0,0,0,"rconswrapper",#PB_Window_BorderLess)
  45.   SetWindowColor(1, $000000)
  46.   SetParent_(*wrapperWnd,*rconsWnd)
  47.  
  48.   ; todo: vscroll hiding
  49.   ;If HideScroll
  50.     ;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)
  51.   ;Else
  52.     SetWindowPos_(*wrapperWnd,#HWND_TOP,rc\right-rc\left-2*GetSystemMetrics_(#SM_CXFRAME)-2*Offset,0,WindowW-rc\right-rc\left,WindowH,#SWP_NOZORDER)
  53.   ;EndIf
  54.  
  55.   If Transparency
  56.     SetWindowLong_(*rconsWnd,#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_LAYERED)
  57.     SetLayeredWindowAttributes_(*rconsWnd,0,TransparencyValue,#LWA_ALPHA)
  58.   EndIf
  59.  
  60.   RedrawWindow_(*ShellWnd, 0, 0, #RDW_INVALIDATE|#RDW_ERASE|#RDW_FRAME)
  61.   SetWindowCallback(@ShellCallback())
  62.  
  63.   If HideOnStart
  64.     hidden = 1
  65.     SetWindowPos_(*rconsWnd, 0, 0, 0, 0, 0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_HIDEWINDOW)
  66.   EndIf
  67.  
  68.   *ActiveWnd = GetActiveWindow_()
  69.  
  70.   Repeat
  71.    
  72.     Select WaitWindowEvent(100)
  73.        
  74.       Case #PB_Event_CloseWindow
  75.         If IsWindow_(*ShellWnd)
  76.           SetParent_(*ShellWnd,0)
  77.           SendMessage_(*ShellWnd,#WM_CLOSE,0,0)
  78.         EndIf
  79.         CloseWindow(0)
  80.         If *ActiveWnd And IsWindow_(*ActiveWnd)
  81.           SetForegroundWindow_(*ActiveWnd)
  82.           SetFocus_(*ActiveWnd)
  83.           SetActiveWindow_(*ActiveWnd)
  84.         EndIf
  85.         Break
  86.        
  87.       Case #WM_HOTKEY
  88.         If hidden
  89.           *ActiveWnd = GetForegroundWindow_()
  90.           hidden = 0
  91.           SetWindowPos_(*ShellWnd, #HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
  92.           If RollEffects
  93.             SetWindowLong_(*rconsWnd,#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW)
  94.             AnimateWindow_(*rconsWnd,200,#AW_VER_POSITIVE|#AW_SLIDE)
  95.           Else
  96.             SetWindowPos_(*rconsWnd,0,0,0,WindowW,WindowH,#SWP_NOMOVE|#SWP_SHOWWINDOW)
  97.           EndIf
  98.           RedrawWindow_(*ShellWnd, 0, 0, #RDW_INVALIDATE|#RDW_ERASE|#RDW_FRAME)
  99.           SetForegroundWindow_(*rconsWnd)
  100.           SetForegroundWindow_(*ShellWnd)
  101.           SetFocus_(*ShellWnd)
  102.           SetActiveWindow_(*ShellWnd)
  103.         Else
  104.           hidden = 1
  105.           If RollEffects
  106.             AnimateWindow_(*rconsWnd,200,#AW_HIDE|#AW_VER_NEGATIVE|#AW_SLIDE)
  107.           EndIf
  108.           SetWindowPos_(*rconsWnd, 0, 0, 0, 0, 0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_HIDEWINDOW)
  109.           If *ActiveWnd And IsWindow_(*ActiveWnd)
  110.             SetForegroundWindow_(*ActiveWnd)
  111.             SetFocus_(*ActiveWnd)
  112.             SetActiveWindow_(*ActiveWnd)
  113.           EndIf
  114.         EndIf
  115.        
  116.     EndSelect
  117.    
  118.     If Not IsWindow_(*ShellWnd)
  119.       End
  120.     EndIf
  121.    
  122.   ForEver
  123.  
  124. EndIf
  125.  
  126. End
  127. ; IDE Options = PureBasic 5.00 (Windows - x86)
  128. ; CursorPosition = 46
  129. ; EnableXP
  130. ; Executable = rcons.exe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement