Jump to content

Genius Idea For a Script


 Share

Recommended Posts

Ill be honest, if i ever need TV static ill come back. I modified some code here and got this.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

;HotKeySet(("^!p"), "SaveImage"); Ctrl+Alt+p  Save image o file

Opt("GUIOnEventMode", 1);0=disabled, 1=OnEvent mode enabled
Global Const $ApW = Int(@DesktopWidth / 16) - Mod(Int(@DesktopWidth / 16), 16)
Global Const $ApH = Int(@DesktopHeight / 16) - Mod(Int(@DesktopHeight / 16), 16)
Global $hWnd, $hBitmap, $hImage, $hGraphic, $hBrush, $hBrush1, $hbmp, $aBmp
$hGui = GUICreate("", $ApW + 40, $ApH + 40)
GUISetOnEvent(-3, "_Quit")
GUISetBkColor(0x000000, $hGui)

$Pic = GUICtrlCreatePic("", 20, 20, $ApW, $ApH)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_DISABLE)

Global Const $STM_SETIMAGE = 0x0172
Global Const $IMAGE_BITMAP = 0
$hWnd = GUICtrlGetHandle($Pic)


PicSetGraphics($ApW, $ApH)
GUISetState(@SW_SHOW, $hGui)


While 1
    PicSetGraphics($ApW, $ApH)
    Sleep(0)
WEnd

Func PicSetGraphics($iW, $iH)
;$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    $hBitmap = _CreateRandomBitmap($hGui, $iW, $iH)
;$hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
;$aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hbmp)
    $iHBmp = GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBitmap)
    _WinAPI_DeleteObject($iHBmp)
    _WinAPI_DeleteObject($hBitmap)
;_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
;_WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME))
EndFunc;==>PicSetGraphics

Func _Quit()
;...
    Exit
EndFunc;==>_Quit

Func _CreateRandomBitmap($hWnd, $iWidth, $iHeight)
    Local $iI, $iSize, $tBits, $tBMI, $hDC, $hbmp, $iRow, $iW = 0, $iH = 0
    $iSize = $iWidth * $iHeight
    $tBits = DllStructCreate("int[" & $iSize & "]")
    For $iI = 1 To $iSize
  ;DllStructSetData($tBits, 1, "0xFF" & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2), $iI)
        DllStructSetData($tBits, 1, Random(0, 0xFFFFFF, 1) + 0xFF000000, $iI)
    Next
    $tBMI = DllStructCreate($tagBITMAPINFO)
    DllStructSetData($tBMI, "Size", DllStructGetSize($tBMI) - 4)
    DllStructSetData($tBMI, "Planes", 1)
    DllStructSetData($tBMI, "BitCount", 32)
    DllStructSetData($tBMI, "Width", $iWidth)
    DllStructSetData($tBMI, "Height", $iHeight)
    $hDC = _WinAPI_GetDC($hWnd)
    $hbmp = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    _WinAPI_SetDIBits(0, $hbmp, 0, $iHeight, DllStructGetPtr($tBits), DllStructGetPtr($tBMI))
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return $hbmp
EndFunc;==>_CreateRandomBitmap

Func SaveImage()
;GDI
    Return
EndFunc;==>SaveImage#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

;HotKeySet(("^!p"), "SaveImage"); Ctrl+Alt+p  Save image o file

Opt("GUIOnEventMode", 1);0=disabled, 1=OnEvent mode enabled
Global Const $ApW = Int(@DesktopWidth / 16) - Mod(Int(@DesktopWidth / 16), 16)
Global Const $ApH = Int(@DesktopHeight / 16) - Mod(Int(@DesktopHeight / 16), 16)
Global $hWnd, $hBitmap, $hImage, $hGraphic, $hBrush, $hBrush1, $hbmp, $aBmp
$hGui = GUICreate("", $ApW + 40, $ApH + 40)
GUISetOnEvent(-3, "_Quit")
GUISetBkColor(0x000000, $hGui)

$Pic = GUICtrlCreatePic("", 20, 20, $ApW, $ApH)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_DISABLE)

Global Const $STM_SETIMAGE = 0x0172
Global Const $IMAGE_BITMAP = 0
$hWnd = GUICtrlGetHandle($Pic)


PicSetGraphics($ApW, $ApH)
GUISetState(@SW_SHOW, $hGui)


While 1
    PicSetGraphics($ApW, $ApH)
    Sleep(0)
WEnd

Func PicSetGraphics($iW, $iH)
;$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    $hBitmap = _CreateRandomBitmap($hGui, $iW, $iH)
;$hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
;$aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hbmp)
    $iHBmp = GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBitmap)
    _WinAPI_DeleteObject($iHBmp)
    _WinAPI_DeleteObject($hBitmap)
;_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
;_WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME))
EndFunc;==>PicSetGraphics

Func _Quit()
;...
    Exit
EndFunc;==>_Quit

Func _CreateRandomBitmap($hWnd, $iWidth, $iHeight)
    Local $iI, $iSize, $tBits, $tBMI, $hDC, $hbmp, $iRow, $iW = 0, $iH = 0
    $iSize = $iWidth * $iHeight
    $tBits = DllStructCreate("int[" & $iSize & "]")
    For $iI = 1 To $iSize
  ;DllStructSetData($tBits, 1, "0xFF" & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2), $iI)
        DllStructSetData($tBits, 1, Random(0, 0xFFFFFF, 1) + 0xFF000000, $iI)
    Next
    $tBMI = DllStructCreate($tagBITMAPINFO)
    DllStructSetData($tBMI, "Size", DllStructGetSize($tBMI) - 4)
    DllStructSetData($tBMI, "Planes", 1)
    DllStructSetData($tBMI, "BitCount", 32)
    DllStructSetData($tBMI, "Width", $iWidth)
    DllStructSetData($tBMI, "Height", $iHeight)
    $hDC = _WinAPI_GetDC($hWnd)
    $hbmp = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    _WinAPI_SetDIBits(0, $hbmp, 0, $iHeight, DllStructGetPtr($tBits), DllStructGetPtr($tBMI))
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return $hbmp
EndFunc;==>_CreateRandomBitmap

Func SaveImage()
;GDI
    Return
EndFunc;==>SaveImage

I Generates even faster the smaller the image is but no kidding guys its tv static! ( coolest tv static ever tho! )

Now if some one made told me how to set how fast it will refresh, probly throttled for video cards that suck, i will have the ultimate Screensaver!

Edited by insignia96

Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

Link to comment
Share on other sites

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Nice modifications. What are they?

It can be faster, certainly simpler, like this:

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global Const $iWidth = 110
Global Const $iHeight = 70

GUICreate("", $iWidth, $iHeight)
GUISetOnEvent(-3, "_Quit")
GUISetBkColor(0x000000)

Global $Pic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)

Global Const $STM_SETIMAGE = 370

Global $iSize = $iWidth * $iHeight
Global $tBits = DllStructCreate("int[" & $iSize & "]")
Global $pBits = DllStructGetPtr($tBits)

Global $hBitmap, $aCall

GUISetState()


While 1

    For $i = 1 To $iSize
        DllStructSetData($tBits, 1, Random(0, 0xFFFFFF, 1), $i)
    Next

    DllCall("gdi32.dll", "int", "DeleteObject", "ptr", $hBitmap)

    $aCall = DllCall("gdi32.dll", "hwnd", "CreateBitmap", _
            "int", $iWidth, _
            "int", $iHeight, _
            "dword", 1, _
            "dword", 32, _
            "ptr", $pBits)

    $hBitmap = $aCall[0]

    DllCall("gdi32.dll", "int", "DeleteObject", "ptr", GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBitmap))

    Sleep(0)

WEnd


Func _Quit()
    Exit
EndFunc  ;==>_Quit

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Nice modifications. What are they?

It can be faster, certainly simpler, like this:

#include <GUIConstantsEx.au3>
 
 Opt("GUIOnEventMode", 1)
 
 Global Const $iWidth = 110
 Global Const $iHeight = 70
 
 GUICreate("", $iWidth, $iHeight)
 GUISetOnEvent(-3, "_Quit")
 GUISetBkColor(0x000000)
 
 Global $Pic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)
 
 Global Const $STM_SETIMAGE = 370
 
 Global $iSize = $iWidth * $iHeight
 Global $tBits = DllStructCreate("int[" & $iSize & "]")
 Global $pBits = DllStructGetPtr($tBits)
 
 Global $hBitmap, $aCall
 
 GUISetState()
 
 
 While 1
 
     For $i = 1 To $iSize
         DllStructSetData($tBits, 1, Random(0, 0xFFFFFF, 1), $i)
     Next
 
     DllCall("gdi32.dll", "int", "DeleteObject", "ptr", $hBitmap)
 
     $aCall = DllCall("gdi32.dll", "hwnd", "CreateBitmap", _
             "int", $iWidth, _
             "int", $iHeight, _
             "dword", 1, _
             "dword", 32, _
             "ptr", $pBits)
 
     $hBitmap = $aCall[0]
 
     DllCall("gdi32.dll", "int", "DeleteObject", "ptr", GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBitmap))
 
     Sleep(0)
 
 WEnd
 
 
 Func _Quit()
     Exit
 EndFunc ;==>_Quit
Is there a way to set the pixel size?

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 3 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...