Jump to content

detect black screen


Recommended Posts

in windows 8 the games in windowed mode when you do the screenshot the image is black ho i can detect the black screen? i've found this and i 've tried to change with the screen capture but don't work

Func _isBlackScreen()
    Local $hImage, $iW, $iH, $tBitmapData, $iStride, $iScan0, $sRet
    Local $hBmp, $hBitmap, $hGraphic, $tCodeBuffer, $bytecode, $tPixelData
    _GDIPlus_Startup()

    $hBitmap = _ScreenCapture_Capture()
        $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)

    ;=> Start Work around For XP, GDIPBitmapLockBits() seem to hard crash autoit When using images that are less then 24bpp
    ; If your using Vista or Newer OS then this won't be called or needed.
    ; http://www.autoitscript.com/forum/index.php?showtopic=102626&view=findpost&p=728034
    If StringInStr("WIN_2003,WIN_XP,WIN_2000", @OSVersion) Then
        Local $aRet, $hBmp, $hBitmap, $hGraphic
        $aRet = _GDIPlus_ImageGetPixelFormat($hImage)
        If Int(StringRegExpReplace($aRet[1], "\D+", "")) < 24 Then
            $hBmp = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
            $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
            _WinAPI_DeleteObject($hBmp)
            $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_GraphicsDispose($hGraphic)
            $hImage = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, $iW, $iH, $GDIP_PXF32ARGB)
            _GDIPlus_BitmapDispose($hBitmap)
        EndIf
    EndIf
    ;=> End Work around

    $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32ARGB)
    $iStride = DllStructGetData($tBitmapData, "stride")
    $iScan0 = DllStructGetData($tBitmapData, "Scan0")
    $tPixelData = DllStructCreate("dword[" & (Abs($iStride * $iH)) & "]", $iScan0)
    $bytecode = "0x8B7424048B4C24088B0638E0750EC1E80838E0750783C604E2EE31C0C3"
    $tCodeBuffer = DllStructCreate("byte[" & StringLen($bytecode) / 2 - 1 & "]") ;alloc some memory
    DllStructSetData($tCodeBuffer, 1, $bytecode) ;write bytecode into struct
    $sRet = DllCall("user32.dll", "ptr", "CallWindowProcW", "ptr", DllStructGetPtr($tCodeBuffer), "ptr", DllStructGetPtr($tPixelData), "int", $iW * $iH, "int", 0, "int", 0);returns eax in ret[0]

    _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    Return ($sRet[0] = 0)
EndFunc   ;==>_IsImageGrayScale
Edited by MRXTO09
Link to comment
Share on other sites

I don't think it's related to games only. Taking screenshots isn't automating any way the game and in my opinion it's not against the rules, but who knows. Moderators will decide :)

Anyways:

MRXTO09 - I can't really understand what's the question? Do you want to bypass the limitation and make a screenshot even if such software is running? Or you just want to detect if the screenshot failed?(since you told the second, but it doesn't seem to be logical).

Link to comment
Share on other sites

I don't think it's related to games only. Taking screenshots isn't automating any way the game and in my opinion it's not against the rules, but who knows. Moderators will decide :)

Anyways:

MRXTO09 - I can't really understand what's the question? Do you want to bypass the limitation and make a screenshot even if such software is running? Or you just want to detect if the screenshot failed?(since you told the second, but it doesn't seem to be logical).

 

Please read the Forum Rules, Specially this part:

 

you have misunderstood! I wanted to do a program like fraps to take screenshots and if he saw a screenshot black not save it. here as

Link to comment
Share on other sites

  • Moderators

MRXTO09,

I wanted to do a program like fraps to take screenshots

Are these screenshots specifically of the game window as a record of its current state? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

MRXTO09,

Then that counts as "game interaction" - thread locked. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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