AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Poor Man's Fullscreen

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
q445
Guest





PostPosted: Wed Feb 27, 2008 8:55 pm    Post subject: Poor Man's Fullscreen Reply with quote



- Removes the menu bars with by overlaying a black window for a poor man's fullscreen
- Good for those applications that you have to sit and think in front of.
- Autohides on mouse over.
- To exit, hold down the CONTROL key and mouse over.



Code:

#SingleInstance force
#NoEnv
CoordMode, mouse, screen

SCREEN_X = %A_ScreenWidth%
SCREEN_Y = %A_ScreenHeight%
if 0 = 4
{
   TOP = %1%
   BOT = %2%
   LEFT = %3%
   RIGHT = %4%
}
else
{
   TOP = 40
   BOT = 17
   LEFT= 17
   RIGHT = 15
}

Gui, Color, Black
Gui +LastFound +AlwaysOnTop +ToolWindow -Caption
WinSet, Region, % "0-0 " . SCREEN_X . "-0 " . SCREEN_X . "-" . SCREEN_Y . " 0-" . SCREEN_Y . " 0-0 " . LEFT . "-" . TOP . " " . SCREEN_X-RIGHT . "-" . TOP . " " . SCREEN_X-RIGHT . "-" . SCREEN_Y-BOT . " " . LEFT . "-" . SCREEN_Y-BOT . " " . LEFT . "-" . TOP
Gui, show,  % "W" . SCREEN_X . " H" . SCREEN_Y . " X0 Y0"
OnMessage(0x200, "WM_MOUSEMOVE")
Return

WM_MOUSEMOVE()
{
   global SCREEN_X, SCREEN_Y, TOP, BOT, LEFT, RIGHT

   GetKeyState, CtrlDwn, Ctrl
   if CtrlDwn = D
      ExitApp
   Gui, hide
   Loop
   {
      MouseGetPos, X, Y
      if (X>LEFT && X<SCREEN_X-RIGHT && Y>TOP && Y<SCREEN_Y-BOT)
         break
      Sleep, 1000
   }
   Gui, show, NA
       return
}
Back to top
not logged in crash23000
Guest





PostPosted: Thu Feb 28, 2008 7:38 am    Post subject: Reply with quote

thats pretty useful, nice job.
Back to top
Raccoon



Joined: 02 Jan 2008
Posts: 70
Location: Freenode IRC

PostPosted: Thu Feb 28, 2008 8:30 am    Post subject: Reply with quote

What text editor are you using there, q445? "TED..." something?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Thu Feb 28, 2008 11:25 am    Post subject: Reply with quote

Here's my attempt at a generic full-screen hotkey.
Code:
!Enter::
    ifWinExist, ahk_id %FullscreenWindow%
    {
        if PMenu                    ; Restore the menu.
            DllCall("SetMenu", "UInt", FullscreenWindow, "UInt", PMenu)
        WinSet, Style, +0xC40000    ; Restore WS_CAPTION|WS_SIZEBOX.
        WinMove,,, PX, PY, PW, PH   ; Restore position and size.
        FullscreenWindow =
        return
    }

    WinGet, Style, Style, A
    if (Style & 0xC40000) != 0xC40000 ; WS_CAPTION|WS_SIZEBOX
        return

    FullscreenWindow := WinExist("A")
   
    WinGetPos, PX, PY, PW, PH
   
    ; Remove WS_CAPTION|WS_SIZEBOX.
    WinSet, Style, -0xC40000
   
    PMenu := DllCall("GetMenu", "UInt", FullscreenWindow)
    ; Remove the window's menu.
    if PMenu
        DllCall("SetMenu", "UInt", FullscreenWindow, "UInt", 0)
   
    ; Get the area of whichever monitor the window is on.
    SysGet, m, Monitor, % ClosestMonitorTo(PX + PW//2, PY + PH//2)
   
    ; Size the window to fill the entire screen.
    WinMove,,, mLeft, mTop, mRight-mLeft, mBottom-mTop
return

ClosestMonitorTo(X, Y)
{
    SysGet, MonitorCount, MonitorCount
    mD = a ; All numbers are < a.
    Loop %MonitorCount%
    {
        SysGet, m, Monitor, %A_Index%
        mX := mLeft + (mRight-mLeft)//2 - X
        mY := mTop + (mBottom-mTop)//2 - Y
        if (D := Sqrt(mX*mX + mY*mY)) < mD
        {
            m := A_Index
            mD := D
        }
    }
    return m
}
If the active window has a caption (title bar) and sizable border, they are removed and the window is sized to fit the screen. If the window has a standard menu, it is also removed. Pressing the hotkey again restores the window to the way it was.

It has multi-monitor support, though it can handle only one full-screen window at a time...
Back to top
View user's profile Send private message
q455
Guest





PostPosted: Thu Feb 28, 2008 1:29 pm    Post subject: Update Reply with quote

Yeah, I'm using TED editor -- it's not good, lacks infinite undo. I've just switched to that HIEditor that everyone here seems to like.
lexiKos -- I haven't even thought of that, it seems so obvious. There are obviously pros and cons of course -- but I like the idea: nice and simple.

These scripts always get more and more elaborate, once you have a nice little way to use autohotkey, you can add onto it forever. This version lets you determine the border by drawing on the screen (if you don't pass it 4 arguments) so you can black out the background on the fly.

Next step: customizable colors, background images, music player, hamster animations (in that order)

Code:

#SingleInstance force
#NoEnv
CoordMode, mouse, screen

SCREEN_X = %A_ScreenWidth%
SCREEN_Y = %A_ScreenHeight%
if 0 = 4
{
   TOP = %1%
   BOT = %2%
   LEFT = %3%
   RIGHT = %4%
   
   Gui, Color, Black
   Gui +LastFound +AlwaysOnTop +ToolWindow -Caption
   WinSet, Region, % "0-0 " . SCREEN_X . "-0 " . SCREEN_X . "-" . SCREEN_Y . " 0-" . SCREEN_Y . " 0-0 " . LEFT . "-" . TOP . " " . SCREEN_X-RIGHT . "-" . TOP . " " . SCREEN_X-RIGHT . "-" . SCREEN_Y-BOT . " " . LEFT . "-" . SCREEN_Y-BOT . " " . LEFT . "-" . TOP
   Gui, show,  % "W" . SCREEN_X . " H" . SCREEN_Y . " X0 Y0"
}
else
{   
   Gui, Color, Black
   Gui +LastFound +AlwaysOnTop +ToolWindow -Caption
   Winset, Transparent, 200
   Gui, show,  % "W" . SCREEN_X . " H" . SCREEN_Y . " X0 Y0"
   
   Loop ;Wait for first mouse click
   {
      GetKeyState, MouseDown, LButton, P
      if MouseDown = D
         Break
      MouseGetPos, AX, AY
      Sleep 100
   }
   TOP := AY
   LEFT := AX
   Loop ;Wait for release
   {
      MouseGetPos, BX, BY
      BOT := SCREEN_Y-BY
      RIGHT := SCREEN_X-BX
      WinSet, Region, % "0-0 " . SCREEN_X . "-0 " . SCREEN_X . "-" . SCREEN_Y . " 0-" . SCREEN_Y . " 0-0 " . LEFT . "-" . TOP . " " . SCREEN_X-RIGHT . "-" . TOP . " " . SCREEN_X-RIGHT . "-" . SCREEN_Y-BOT . " " . LEFT . "-" . SCREEN_Y-BOT . " " . LEFT . "-" . TOP
      GetKeyState, MouseDown, LButton, P
      if MouseDown != D
         Break
      Sleep 500
   }
   Winset, Transparent, 255
   
   If (TOP + BOT > SCREEN_Y)
   {
      TOP := SCREEN_Y-BOT
      BOT := SCREENY_Y-TOP
   }
   If (LEFT + RIGHT > SCREEN_X)
   {
      LEFT := SCREEN_Y-RIGHT
      RIGHT := SCREENY_Y-LEFT
   }
}
OnMessage(0x200, "WM_MOUSEMOVE")
Return
   
WM_MOUSEMOVE()
{
   global SCREEN_X, SCREEN_Y, TOP, BOT, LEFT, RIGHT

   GetKeyState, CtrlDwn, Ctrl
   if CtrlDwn = D
      ExitApp
   Gui, hide
   Loop
   {
      MouseGetPos, X, Y
      if (X>LEFT && X<SCREEN_X-RIGHT && Y>TOP && Y<SCREEN_Y-BOT)
         break
      Sleep, 1000
   }
   Gui, show, NA
       return
}
Back to top
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Mon Mar 03, 2008 11:56 am    Post subject: Reply with quote

Nice!
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group