Jump to content

speed problems with screenshot functions


corgano
 Share

Recommended Posts

Sorry for the low quality thread, but its 2 am at time of writing. I need a way to speed up this script, anyone know of a better method?

main loop:

$mod = 10
    while 1
        _ScreenCapture_Capture($temp,0-$mod,0-$mod,@desktopwidth + $mod, @desktopheight + $mod, False)
        If Not FileExists($temp) Then Return -1
        DllCall("user32.dll", "int", "SystemParametersInfo", _
        "int", $SPI_SETDESKWALLPAPER, _
        "int", 0, _
        "str", $temp, _
        "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
    WEnd

Is there any way to set the desktop image to a hbitmap instead of needing to make it an image first?

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

  • Moderators

corgano,

From the Help file for _ScreenCapture_Capture:

Remarks

If FileName is blank, this function will capture the screen and return a HBITMAP handle to the bitmap image. In this case, after you are finished with the bitmap you must call _WinAPI_DeleteObject to delete the bitmap handle.

I have used this function to return a HBITMAP handle successfully in several scripts.

I hope you slept well! :mellow:

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

I can get it to return the hbmp, but then I cannot set as the desktop. The setdesktopwalpaper() function I originally got did not support setting a bitmaphandle as the desktop, but would work with a file. Know of a function to set a hBitmap as the desktop wallpaper?

original function:

Func _ChangeDestopWallpaper($bmp, $style = 0)
   If Not FileExists($bmp) Then Return -1
   Local $SPI_SETDESKWALLPAPER = 20
   Local $SPIF_UPDATEINIFILE = 1
   Local $SPIF_SENDCHANGE = 2
   Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
      if $style = 1 then 
      RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1)
      RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
   Else
   RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
   RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
   EndIf
   DllCall("user32.dll", "int", "SystemParametersInfo", _
         "int", $SPI_SETDESKWALLPAPER, _
         "int", 0, _
         "str", $bmp, _
         "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
   Return 0
EndFunc  ;==>_ChangeDestopWallpaper

And, yes, I did try removing the "If Not FileExists($bmp) Then Return -1". It didn't help.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
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
 Share

  • Recently Browsing   0 members

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