AutoHotkey Community

It is currently May 27th, 2012, 10:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Poor Man's Fullscreen
PostPosted: February 27th, 2008, 8:55 pm 
Image

- 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
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2008, 7:38 am 
thats pretty useful, nice job.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2008, 8:30 am 
Offline

Joined: January 2nd, 2008, 4:47 am
Posts: 150
Location: Freenode IRC
What text editor are you using there, q445? "TED..." something?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2008, 11:25 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Update
PostPosted: February 28th, 2008, 1:29 pm 
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
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2008, 11:56 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
Nice!

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 7th, 2009, 7:27 am 
Lexikos wrote:
It has multi-monitor support, though it can handle only one full-screen window at a time...


Would very much like to see a multi-window version! I can't seem to make the right modifications, it must be getting a window reference and sticking to that but can't find where to change that method when it's activated.

To be honest it took me a few minutes to figure out that the ifWinExist was to undo fullscreen...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2009, 8:35 am 
Offline

Joined: October 26th, 2005, 5:11 pm
Posts: 28
Hey, I'm surprised this is still up here. I've actually found it quite useful, as I write my paper. Try the new version "Distraction Elimination / Full Screen Script", which is basically the same thing, with a few bonuses or variations. (But still no dual screen).

http://www.autohotkey.com/forum/viewtopic.php?t=51664


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group