Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Screen Capture with Transparent Windows and Mouse Cursor


  • Please log in to reply
245 replies to this topic
guest12
  • Guests
  • Last active:
  • Joined: --

I know that there already exist script(s) of the kind. Then, why another one?
It'll also capture the transparent windows and/or the mouse cursor, according to the options.
Please read the comments in the script for the details.

PS. It REQUIREs GdiPlus.dll.

DOWNLOAD ScreenCapture.ahk.


hello!
congratulation for script!
i try to launch in windows 2000 and it doesnt't work.
why?

this is the "log"

Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.

023: CaptureScreen()
028: if !aRect
029: {
030: SysGet,Mon,Monitor,1
031: nL := MonLeft
032: nT := MonTop
033: nW := MonRight - MonLeft
034: nH := MonBottom - MonTop
035: }
060: hDC := DllCall("GetDC", "Uint", 0)
061: mDC := DllCall("CreateCompatibleDC", "Uint", hDC)
062: hBM := DllCall("CreateCompatibleBitmap", "Uint", hDC, "int", nW, "int", nH)
063: oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
064: DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
065: if bCursor
067: DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
068: DllCall("DeleteDC", "Uint", mDC)
069: if znW && znH
071: if sFile = 0
073: Convert(hBM, sFile)
122: if !sFileTo
124: sFileTo := "C:" A_DD "_" A_MMM "_" A_Hour "_" A_Min ".bmp"
125: SplitPath,sFileTo,,,sExtTo
127: hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll")
128: VarSetCapacity(si, 16, 0), si := Chr(1)
129: DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)
130: DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
131: VarSetCapacity(ci, nSize)
132: DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)
134: Loop,%nCount%
142: if !sFileFr
149: if sFileFr is Integer
150: DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage)
153: if pImage
156: DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
157: DllCall("FreeLibrary", "Uint", hGdiPlus)
158: }
074: DllCall("DeleteObject", "Uint", hBM)
075: DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
076: }
027: {
079: {
104: {
121: {
161: {
172: {
180: { (32.77)


thanks

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

PS. It REQUIREs GdiPlus.dll.

i try to launch in windows 2000 and it doesnt't work.

W2K doesn't have GdiPlus.dll which is needed to save the captured screen-shot to a file on HDD. I think MS provides GdiPlus.dll as a redistributed one, so you may download it. Or, I may extend the script to not use GdiPlus.dll when it's not found, however, you'll able to save to BMP only in this case.

guest12
  • Guests
  • Last active:
  • Joined: --

PS. It REQUIREs GdiPlus.dll.

i try to launch in windows 2000 and it doesnt't work.

W2K doesn't have GdiPlus.dll which is needed to save the captured screen-shot to a file on HDD. I think MS provides GdiPlus.dll as a redistributed one, so you may download it. Or, I may extend the script to not use GdiPlus.dll when it's not found, however, you'll able to save to BMP only in this case.



great!
thank you!

BoBo¨
  • Guests
  • Last active:
  • Joined: --
Based on a request regarding a text-highlighter, I thought about if it would be possible to specify an area, copy its content to the clipboard (aka having a screenshot, right?), change one color of the captured content (eg. black to yellow, to mimik the "highlighting" of a text) and 'repaint' the original/source/screen area with that edited screenshot.

Complete nonsense :?:

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

change one color of the captured content (eg. black to yellow, to mimik the "highlighting" of a text)

I suppose you want to change only the color of the text, i.e., without affecting the color of the background. Then, the obvious question is how to identify/confine the region of the text programmatically? I don't think it's an easy job if not impossible.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
The script is updated so as to save the screen capture to a .bmp file (even) when GdiPlus.dll is not found in the system.

tic
  • Members
  • 1934 posts
  • Last active: May 30 2018 08:13 PM
  • Joined: 22 Apr 2007
Sean (or anyone else) do you know how to convert to an .ico? I am trying to help someone, and it would be useful to be able to convert for example from a bmp to an ico, even if it doesnt have different sizes, it would be useful to just convert to 32x32 ico with the fewest number of colours. I have been reading a bit, but I dont have enough knowledge about gdiplus, so the going is slow :(

If you understand this then it would be very useful:

<!-- m -->http://weblogs.foxit... ... /4346.aspx<!-- m -->

and even better (but i dont require it):

<!-- m -->http://weblogs.foxit... ... /4528.aspx<!-- m -->

thanks for your time.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Sean (or anyone else) do you know how to convert to an .ico?

There exist a simple method to create hIcon from an image file using GDI+, although it's not perfect: GdipLoadImageFromFile/GdipCreateBitmapFromFile & GdipCreateHICONFromBitmap. AFAIK, however, there doesn't exist a simple way to save hIcon to a .ico file. To achieve it, you have to follow the step shown in the second linked page in your post, which I don't want to go into it myself, at least for now.

tic
  • Members
  • 1934 posts
  • Last active: May 30 2018 08:13 PM
  • Joined: 22 Apr 2007

There exist a simple method to create hIcon from an image file using GDI+, although it's not perfect: GdipLoadImageFromFile/GdipCreateBitmapFromFile & GdipCreateHICONFromBitmap.


So you mean it converts it, but then cant be written to a file? What state is it in so that it cant be written to a file? Would there be any way to create a tray icon directly from this hIcon?

Also, would the 1st link be any easier to do? Im really gtting lost on the gdi+ front. where have you read all this stuff? I tried searching and couldnt find anything useful, such as all the gdiplus functions.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

What state is it in so that it cant be written to a file?

You cannot directly save device-dependent memory objects, hBitmapColor and hBitmapMask in hIcon case, to a file.

Would there be any way to create a tray icon directly from this hIcon?

Yes it does. Read about Shell_NotifyIcon, which is also included in my TrayIcons script.

Also, would the 1st link be any easier to do? Im really gtting lost on the gdi+ front.

It doesn't use GDI+, does use OLE function(s) which used to be useful before the advent of GDI+. And, it uses its site's own custom function to save to .ico.

where have you read all this stuff? I tried searching and couldnt find anything useful, such as all the gdiplus functions.

MSDN, especially GDI+'s Flat APIs.

tic
  • Members
  • 1934 posts
  • Last active: May 30 2018 08:13 PM
  • Joined: 22 Apr 2007

Yes it does. Read about Shell_NotifyIcon, which is also included in my TrayIcons script.


Im not sure that youre answering the question im trying to ask. i dont mean, can i create a whole new tray icon. i mean, is it possible to change the scripts icon from a bmp as its source image (as you said it was possible to convert to a hIcon, but hard to write this to .ico). So could a bmp be used as a tray icon for the current script then without having to convert and write it to an .ico file?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

So could a bmp be used as a tray icon for the current script then without having to convert and write it to an .ico file?

I already answered that. First read about Shell_NotifyIcon, it can add/modify/delete trayicon.

impecco
  • Members
  • 3 posts
  • Last active: Feb 13 2008 08:55 PM
  • Joined: 09 Dec 2007
This miraculous script also solves some "old" problem discussed in
http://www.autohotke...741.html#164741
which is to save an image in the clipboard to a file.
See impecco's posting.
Impecco: Rerum Cognoscere Causas!

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

http://www.autohotke...741.html#164741
which is to save an image in the clipboard to a file.
See impecco's posting.

In fact, I was thinking about updating that part to use DIB. If you encounter a problem with the current one, please post here.

winngy
  • Members
  • 1 posts
  • Last active: Jan 18 2008 09:51 AM
  • Joined: 17 Jan 2008
Hi guys new here (well new to posting)

Could some help me make this script do the following

1. Loop and take a screenshot of the client area of a window every second.

2. save the files as frame000.bmp , frame001.bmp.........frame999.bmp. In folder created by me.

I can add a line to sctivate the window in question and i can add the loop , but if you could also enable a hotkey escape.