Sign in to follow this  
Followers 0
ezzetabi

Hole in the black

8 posts in this topic

#1 ·  Posted (edited)

I sometime watch movies using my computer and so I made this little script for making the screen black all around the movie window.

To start: Start it, start the movie, press CTRL.

To finish: click in the black, press ALT-F4.

#include <GUIConstants.au3>
Opt ('MustDeclareVars', 1)
Opt ('TrayIconHide', 1)

Local $NullGifFile = "47494638396105000500830000000000800000008000808000000080" & _
      "800080008080C0C0C0808080FF000000FF00FFFF000000FFFF00FF00" & _
      "FFFFFFFFFF21F9040300000F002C0000000005000500000406F0C949ABA511003B"

Local $Style = $WS_POPUP
Local $ExStyle = BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)
Local $hHandle, $aCCC

GUISetBkColor(0, GUICreate('', @DesktopWidth, @DesktopHeight, 0, 0, $Style, $ExStyle, 0))

FileDelete(@ScriptDir & '\null.gif')
_CreateFile($NullGifFile, @ScriptDir & '\null.gif')

If FileExists(@ScriptDir & '\null.gif') Then
   Do
      $hHandle = _WaitTheWindow()
      $aCCC = WinGetPos($hHandle)
   Until Not @error
   
   GUICtrlCreatePic('null.gif', $aCCC[0], $aCCC[1], $aCCC[2], $aCCC[3], -1, -1)
   FileDelete(@ScriptDir & '\null.gif')
   GUISetState()
   
   While GUIGetMsg() <> $GUI_EVENT_CLOSE
   WEnd
EndIf

Exit
Func _WaitTheWindow()
   While _IsPressed(0x11) = 0
      ToolTip('Activate the window and press "Ctrl".')
      Sleep(1)
   WEnd
   ToolTip('')
   Return WinGetHandle('')
EndFunc  ;==>_WaitTheWindow

Func _IsPressed($hexKey)
   Local $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc  ;==>_IsPressed

Func _CreateFile($sHexData, $sFileName)
   Local $dllKernel32 = DllOpen("kernel32.dll")
   Local $nStrSize = StringLen($sHexData)
   Local $p = DllStructCreate ("ubyte[" & $nStrSize / 2 & "]")
   For $i = 1 To $nStrSize Step 2
      DllStructSetData ($p, 1, Dec(StringMid($sHexData, $i, 2)) , ($i + 1) / 2)
   Next
   Local $ret = DllCall($dllKernel32, "int", "CreateFile", _
         "str", $sFileName, _
         "int", 0x40000000, _
         "int", 1, _
         "ptr", 0, _
         "int", 4, _
         "int", 0x80, _
         "ptr", 0)
   DllCall($dllKernel32, "int", "WriteFile", _
         "int", $ret[0], _
         "ptr", DllStructGetPtr ($p), _
         "int", $nStrSize / 2, _
         "int_ptr", 0, _
         "ptr", 0)
   DllCall($dllKernel32, "int", "CloseHandle", "int", $ret[0])
   DllClose($dllKernel32)
EndFunc  ;==>_CreateFile
Edited by ezzetabi

Share this post


Link to post
Share on other sites



Haha, that's a really neat script :) Keep it up. Actually, pretty usefull too, because watching movies on the computer is like, next generation stuff here! :evil:


FootbaG

Share this post


Link to post
Share on other sites

?

Share this post


Link to post
Share on other sites

?

<{POST_SNAPBACK}>

get it? $aHole? asshole? :evil:

BTW,

what is $HoleFile? what is all that Chr stuff? :)


FootbaG

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I watch movies in a small window. I can't focus to the whole screen surface as I like. Secondly, some movies fullscreen become too pixelated.

Edit: Since LazyCat have some problems with the creationg of the gif file I changed the script, put the script and the attached .gif file in the same folder.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Yes, now it works :)

Here a simple function that should correctly write gif:

Func _CreateNullGif()
    Local $sHexData = "47494638396105000500830000000000800000008000808000000080" &_
                      "800080008080C0C0C0808080FF000000FF00FFFF000000FFFF00FF00" & _
                      "FFFFFFFFFF21F9040300000F002C0000000005000500000406F0C949ABA511003B"
    Local $nStrSize = StringLen($sHexData)
    Local $p = DllStructCreate("byte[" & $nStrSize/2 & "]")
    For $i = 1 To $nStrSize Step 2
        DllStructSetData($p, 1, Dec(StringMid($sHexData, $i, 2)), ($i+1)/2)
    Next
    Local $ret  = DllCall("kernel32.dll","int","CreateFile",_
                        "str","null1.gif",_
                        "int",0x40000000,_
                        "int",1,_
                        "ptr",0,_
                        "int",4,_
                        "int",0x80,_
                        "ptr",0)

    DllCall("kernel32.dll","int","WriteFile",_
                    "int",$ret[0],_
                    "ptr",DllStructGetPtr($p),_
                    "int",$nStrSize/2,_
                    "int_ptr",0,_
                    "ptr",0)

    DllCall("kernel32.dll","int","CloseHandle","int",$ret[0])
EndFunc

Edit: wordwrap

Edited by Lazycat

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks to the most excellent LazyCat func, a new version!

It is interesting how to a simple .gif file makes a hole in the gui so easily... :)

Edited by ezzetabi

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