Sign in to follow this  
Followers 0
sandman

OnTask

5 posts in this topic

#1 ·  Posted (edited)

I whipped this up for to assist in my sudden obsession with productivity. Maybe it'll help with the obsession of other people also. This script, when activated by pressing F9, will create a mask window and bring only your current window on top of it, so the only window you can see is the one that you have chosen.

Without further ado, the notoriously short, 39 lines (after pretty spacing techniques were applied):

#include <GUIConstants.au3>
#include <GUIList.au3>
#include <Misc.au3>

HotKeySet("{F9}", "Start")

Global $mask, $init

Global $STATE_ask = 0
Global $STATE_trap = 0

While 1
    Sleep(1)
WEnd

Func Start()
    If $STATE_trap = 1 Then
        GUIDelete($mask)
        WinSetOnTop($init, "", 0)
        $STATE_trap = 0
    ElseIf $STATE_trap = 0 Then
        $init = Init(WinGetTitle(""), WinGetHandle(WinGetTitle("")))
    EndIf
EndFunc

Func Init($sWinTitle, $hWindow)
    Global $mask = GUICreate("OnTask Mask Window", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0x000000, $mask)
    WinSetTrans("OnTask Mask Window", "", 254)
    GUISetState(@SW_SHOW, $mask)
    WinSetState($sWinTitle, "", @SW_RESTORE)
    WinSetOnTop($sWinTitle, "", 1)
    $pos = WinGetPos($sWinTitle)
    $STATE_trap = 1
    Return $sWinTitle
EndFunc

Enjoy. Press F9 to activate.

:^) / ( 8^I) Which one?

And yes, I am joining the manual-signature club (see above). And yes, I am in a very good mood.

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

OK, cool. It clears the clutter all except the window you are focused on when you hit F9... Nice..

Share this post


Link to post
Share on other sites

Oh, forgot to tell the hotkey.. Posted Image


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

Oh, forgot to tell the hotkey.. Posted Image

C:\Projects\Project.AU3\ssss.au3(21,24) : WARNING: $mask: possibly used before declaration.

GUIDelete($mask)

~~~~~~~~~~~~~~~~~~~~~~~^

C:\Projects\Project.AU3\ssss.au3 - 0 error(s), 1 warning(s)

->18:17:27 AU3Check ended.rc:1

It works but would be nicer without errors :)


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

C:\Projects\Project.AU3\ssss.au3(21,24) : WARNING: $mask: possibly used before declaration.

GUIDelete($mask)

~~~~~~~~~~~~~~~~~~~~~~~^

C:\Projects\Project.AU3\ssss.au3 - 0 error(s), 1 warning(s)

->18:17:27 AU3Check ended.rc:1

It works but would be nicer without errors :)

That's just because $mask is initially defined in a function which comes after that loop... sorry! I'll fix that warning right now.

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0