Can ahk take a screenshot of a window when it is hidden ?
Can ahk take a screenshot of a window when it is hidden ?
i need to screenshot noxplayer each x second, so that i can use the screen to do other things. If ahk can, can you help me ? And if ahk can't, are there any other software can do that ?
Re: Can ahk take a screenshot of a window when it is hidden ?
Timed background window screenshot
Code: Select all
/* Timed window screenshot ------------------------------------------------------
This script uses GDI+ to save screenshots of a window (foreground or background)
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=121434&p=539053#p539053
https://github.com/marius-sucan/AHK-GDIp-Library-Compilation
By mikeyww • For AutoHotkey version 1.1.37.01
14 September 2023
---------------------------------------------------------------------------------
*/
#Requires AutoHotkey v1.1.33
#Include d:\Q\vis2\lib\Gdip_All.ahk
winTitle := "ahk_class Notepad" ; Target window
dir := A_ScriptDir ; Output directory for images
freq := 1000 ; Frequency (ms) of image capture
Global pBitmap, pToken := Gdip_Startup()
OnExit("done") ; Clean up upon exit
#If WinExist(winTitle)
F3:: ; F3 = Toggle timer for screenshots
If on := !on {
SetTimer Capture, % freq ; Schedule for image capture
SoundBeep 1500
Gosub Capture
Return
}
Stop:
SetTimer Capture, Off
SoundBeep 1000
on := False
Return
#If
Capture:
If hWnd := WinExist(winTitle) { ; Get target window's HWND
pBitmap := Gdip_BitmapFromHWND(hWnd) ; Get window's bitmap
FormatTime ts,, yyMMdd-HHmmss ; Use timestamp in file name
Gdip_SaveBitmapToFile(pBitmap, dir "\image" ts ".png") ; Save image file
SoundBeep 2500
} Else Gosub Stop ; Stop timer when window does not exist
Return
done(exitReason, exitCode) {
If pBitmap
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
SoundBeep 1000
}
Last edited by mikeyww on 15 Sep 2023, 11:57, edited 3 times in total.
Re: Can ahk take a screenshot of a window when it is hidden ?
And i have 2 noxplayer windows already running, how i can screenshot them using 1-2 your .ahk ?
Code: Select all
; This script uses GDI+ to save screenshots of a window (foreground or background)
; https://github.com/buliasz/AHKv2-Gdip
#Include C:\Users\admin\Desktop\abc\Gdip_All.ahk
winTitle := "ahk_exe notepad.exe"
dir := A_ScriptDir
pToken := Gdip_Startup()
OnExit("done")
#If WinExist(winTitle)
F3::
If on := !on {
SetTimer Capture, 1000
SoundBeep 1500
Gosub Capture
Return
}
Stop:
SetTimer Capture, Off
SoundBeep 1000
on := False
Return
#If
Capture:
If !win := WinExist(winTitle)
Gosub Stop
FormatTime, ts,, yyMMdd-HHmmss
image := Format("{}\image{}.png", dir, ts)
pBitmap := Gdip_BitmapFromHWND(win)
Gdip_SaveBitmapToFile(pBitmap, image)
SoundBeep 2500
Return
done(exitReason, exitCode) {
If pBitmap
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
SoundBeep 1000
}
Re: Can ahk take a screenshot of a window when it is hidden ?
Try my latest update (edited above). This is the v1 forum.
Re: Can ahk take a screenshot of a window when it is hidden ?
Good day Mikey!!
Was curious about this idea so had to give it a try of course. It may be my copies from when I found them, but for this script to work I had to switch Gdip_All.ahk for Gdip.ahk.
And while I am a big fan of soundbeep (thanks to you), That is all I have happening once I press F3. I get the intial beep, followed by the second beep every 1 second, but nothing showing up as images in the A_ScriptDir. Ideas?
Was curious about this idea so had to give it a try of course. It may be my copies from when I found them, but for this script to work I had to switch Gdip_All.ahk for Gdip.ahk.
And while I am a big fan of soundbeep (thanks to you), That is all I have happening once I press F3. I get the intial beep, followed by the second beep every 1 second, but nothing showing up as images in the A_ScriptDir. Ideas?
Re: Can ahk take a screenshot of a window when it is hidden ?
Sorry I had posted the wrong URL (for v2), though still using Gdip_All.ahk in the #Include.
This is the URL: https://github.com/marius-sucan/AHK-GDIp-Library-Compilation.
Test with Notepad first. I updated my script to reflect the correct URL.
How do I work around problems caused by User Account Control (UAC)?
This is the URL: https://github.com/marius-sucan/AHK-GDIp-Library-Compilation.
Test with Notepad first. I updated my script to reflect the correct URL.
How do I work around problems caused by User Account Control (UAC)?
Re: Can ahk take a screenshot of a window when it is hidden ?
oh i have to run as admin to work
now with nox i try this but not work
now with nox i try this but not work
Code: Select all
winTitle := "ahk_class NoxVMHandle" ; Target window
Code: Select all
winTitle := "ahk_class NoxVMHandleFrontend" ; Target window
Code: Select all
winTitle := "ahk_class NoxVMHandle Frontend" ; Target window
Code: Select all
winTitle := "ahk_class NoxPlayer" ; Target window
- Attachments
-
- image.png (9.03 KiB) Viewed 787 times
Re: Can ahk take a screenshot of a window when it is hidden ?
First question: does the script work with Notepad?
Last edited by mikeyww on 14 Sep 2023, 08:27, edited 2 times in total.
Re: Can ahk take a screenshot of a window when it is hidden ?
Run Window Spy to see the WinTitle information.
Some games block scripting.
You can also (alternatively) try ahk_exe with the process name.
Some games block scripting.
You can also (alternatively) try ahk_exe with the process name.
Re: Can ahk take a screenshot of a window when it is hidden ?
It blank, i guess nox block it, or it have other .exe for screen
Anyway, thank you, sir
Anyway, thank you, sir
Who is online
Users browsing this forum: Google [Bot], Marium0505, Trunks298 and 174 guests