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
Erwin
  • Guests
  • Last active:
  • Joined: --
Hello!

Nice piece of code!

Is it also possible to capture running wmv (avi and other video) files on the screen? Now I just get a transparent hole in my bmp.

Would be great, cause even ready made software (free) which can do that is very scarce!

Thanks!

AHK Guest
  • Guests
  • Last active:
  • Joined: --
How do I use variables for the filename? I have tried
CaptureScreen(aRect = 0, bCursor = False, sFile = A_Now . ".png" )
but it says

---------------------------
ScreenCapture.ahk
---------------------------
Error at line 26.

Line Text: CaptureScreen(aRect = 0, bCursor = False, sFile = A_Now . ".png" )
Error: Unsupported parameter default.

The program will exit.
---------------------------
OK
---------------------------

and
CaptureScreen(aRect = 0, bCursor = False, sFile = "%A_Now%.png" )
but it saves the file as %A_Now%.png without the variable converted. What is wrong?

tic
  • Members
  • 1934 posts
  • Last active: May 30 2018 08:13 PM
  • Joined: 22 Apr 2007
CaptureScreen(0, 0, A_Now ".png")

read about functions in the documentation.

BioBrain
  • Members
  • 17 posts
  • Last active: Nov 21 2014 10:23 PM
  • Joined: 13 Feb 2008
Hi Sean, that's a great script. I've using it for a while to search what kind of cursor is active right now coz it can capture mouse cursor.

I've been thinking, do U thing it's possible to search is image in clipboard is the same with image I want 2 search. kinda like ImageSearch but not on screen, but search in the Clipboard.

because b4 i use to to save it Hd 1st & show it 2 GUI 2 search it using imagesearch. And I think it'll be more efficient 2 search in clipboard.

Can U tell me how? tx b4.

krfiii
  • Guests
  • Last active:
  • Joined: --
I am trying to use Sean's syntax, and all I seem to get is the full screen (1920x1200) not sure what i am doing wrong here... even tried to comment out everything and just do the screen capture portion... same result. Running XPSP2... current AHK, just dled the screencapture.ahk

IfWinNotActive, EVE, 
WinActivate, EVE, 
WinWaitActive, EVE,

#Persistent
;#SingleInstance force
;SetKeyDelay, 11
;SetDefaultMouseSpeed, 11

#include ScreenCapture.ahk

;Process, Priority, MMine, H
;Process, Priority, MMine, A






;MsgBox, 4,, Would you like to continue? (press Yes or No)

;Gosub, Start

;Start:
Sleep, 2000

;KeyWait, LButton, D
;MouseGetPos, XPos, Ypos,
;X1:=XPos 
;Y1:=YPos 
;X2:=XPos+150 
;Y2:=YPos+150
;Size=%X1%, %Y1%, %X2%, %Y2%
gosub, capscr


Return


Capscr:

sleep 1000
;CaptureScreen(Size, True, 0)
CaptureScreen("100,100,500,500", 0, 0)
return


  • Guests
  • Last active:
  • Joined: --
Your code will never run. If you'd like to use #include, remove from the head of ScreenCapture.ahk
CaptureScreen()
Return
And your current code will save it to the clipboard.

  • Guests
  • Last active:
  • Joined: --

I've been thinking, do U thing it's possible to search is image in clipboard is the same with image I want 2 search. kinda like ImageSearch but not on screen, but search in the Clipboard.

Sure it's possible. You can obtain, using GetClipboardData(), hbitmap (:DDB) or DIB. All necessary ones are ready by now. The remaining question is what procedure you're gonna use for the search, GetPixel through memory dc, where hbitmap is useful but maybe the slowest, or compare raw pixel, where DIB is handy, one by one, or may use hashes of the data.

  • Guests
  • Last active:
  • Joined: --

Is it also possible to capture running wmv (avi and other video) files on the screen? Now I just get a transparent hole in my bmp.

Would be great, cause even ready made software (free) which can do that is very scarce!

That's a whole lot different story. I don't think it's possible with the current AHK (alone) unless the DirectX surface is owned by AHK when the hardware acceleration is in effect.

Shawn
  • Guests
  • Last active:
  • Joined: --
I'm new to AHK, and I'm wondering if this script can be modified to work on a minimized window without restoring it. Also, how exactly do I make it capture only a certain portion of the screen if I have the coords. Thanks.

  • Guests
  • Last active:
  • Joined: --

I'm new to AHK, and I'm wondering if this script can be modified to work on a minimized window without restoring it. Also, how exactly do I make it capture only a certain portion of the screen if I have the coords. Thanks.

Use PrintWindow API, but you'll capture the extent of a minimized window.

tinku99
  • Members
  • 560 posts
  • Last active: Feb 08 2015 12:54 AM
  • Joined: 03 Aug 2007
I am trying to screen capture from a second monitor, but I am having problems. It works fine on the first monitor:


aTest := scan_x_start . ", " . scan_x_start . ", " . scan_y_end . ", " . scan_y_end
CaptureScreen(aTest)

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
Does anybody know why this function doesn't work for me properly? :(
I just simply tested it on my WinXP SP2
i can't handle it.
it only captures fullscreen, and saves to screen.bmp only whatever parameters were.

#Include ScreenShot.ahk

;Below are from the example
CaptureScreen(0)                                           ;Captures FullScreen and saves to screen.bmp
CaptureScreen(1)                                           ;same
CaptureScreen(2)                                           ;same
CaptureScreen("100, 100, 200, 200")                        ;same
CaptureScreen("100, 100, 200, 200, 400, 400")              ;same
CaptureScreen(1, 0,"test.png")                             ;same
CaptureScreen(2, False,"test.jpg")                         ;same


  • Guests
  • Last active:
  • Joined: --
The answer is a few post above.

Your code will never run. If you'd like to use #include, remove from the head of ScreenCapture.ahk

CaptureScreen()
Return



ZeosCentric
  • Guests
  • Last active:
  • Joined: --
Hello, thank you for this support group. Conversely, I have a simple question about this particular function, hopefully someone can take it seriously and see it for what it is. I have IP software I don't want people taking screenshots of.... this function seems to tap into windows dll calls to accomplish the task.

I am wondering, is there any anti-protection code I can implement, that would defeat this general function from working on my systems? Please let me know if anyone knows! :)

Have the best day and thank you.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Perfect for capturing errors when someone is running my scripts
thanks
Never lose.
WIN or LEARN.