Deal with Screenshots ... can it be done?
Deal with Screenshots ... can it be done?
Oks.. since i'm new at PureBasic... i have one little question (or let's say Problem)
1. I want to run a PB code (LOL)
2. Within this code Launch a "Game or App or something" (but mainly a GAME)
3. Set a "DELAY" let-s say 20-30 seconds
4. While The "Game" runs Take a Screenshot and save it to .jpg mainly
1. I want to run a PB code (LOL)
2. Within this code Launch a "Game or App or something" (but mainly a GAME)
3. Set a "DELAY" let-s say 20-30 seconds
4. While The "Game" runs Take a Screenshot and save it to .jpg mainly
:D.. Thanks ... :D
Oks.. Thanks.. I Got this one...
, but can anyone share one bit (or two) of Code on this matter ?
.. Just Started PureBasic "TODAY" ... and startin' to "LOVE IT" ...
... (again, a piece of code WILL HELP VERRY MUCH, Thanks)



This should get you started
:

Code: Select all
;===========================================================================
;-CONSTANTS
;===========================================================================
#APP_NAME = "Delayed Screenshot taker v1.0"
Enumeration
#WINDOW_ROOT
#STRING_EXE
#BUTTON_SELECTEXE
#SPIN_TIME
#TEXT_SECONDS
#BUTTON_LAUNCH
#TIMER_MAIN
EndEnumeration
;===========================================================================
;-GLOBAL FLAGS / VARIABLES / STRUCTURES / ARRAYS
;===========================================================================
Global ExeName.s
;===========================================================================
;-PROCEDURES
;===========================================================================
;Handle an error
Procedure HandleError(Result, Text.s)
If Result = 0 : MessageRequester("Error", Text, #PB_MessageRequester_Ok) : End : EndIf
EndProcedure
;capture the screen
Procedure.l CaptureScreen()
ScreenWidth = GetSystemMetrics_(#SM_CXSCREEN)
ScreenHeight = GetSystemMetrics_(#SM_CYSCREEN)
dm.DEVMODE
BMPHandle.l
srcDC = CreateDC_("DISPLAY", "", "", dm)
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, ScreenWidth, ScreenHeight)
SelectObject_( trgDC, BMPHandle)
BitBlt_(trgDC, 0, 0, ScreenWidth, ScreenHeight, srcDC, 0, 0, #SRCCOPY)
DeleteDC_(trgDC)
ReleaseDC_(BMPHandle, srcDC)
CreateImage(0, ScreenWidth, ScreenHeight)
StartDrawing(ImageOutput())
DrawImage(BMPHandle, 0, 0)
StopDrawing()
UseJPEGImageEncoder()
SaveImage(0, "Screenshot.jpg", #PB_ImagePlugin_JPEG)
End
EndProcedure
;===========================================================================
;-GEOMETRY
;===========================================================================
HandleError(OpenWindow(#WINDOW_ROOT, 0, 0, 400, 55, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, #APP_NAME), "Main window could not be created.")
HandleError(CreateGadgetList(WindowID(#WINDOW_ROOT)), "Gadget list for the main window could not be created.")
StringGadget(#STRING_EXE, 5, 5, 285, 21, "")
ButtonGadget(#BUTTON_SELECTEXE, 295, 5, 100, 21, "Select Program...")
SpinGadget(#SPIN_TIME, 5, 30, 50, 21, 1, 1000)
SetGadgetState(#SPIN_TIME, 60) : SetGadgetText(#SPIN_TIME,"60")
TextGadget(#TEXT_SECONDS, 60, 33, 140, 21, "Seconds until screenshot.")
ButtonGadget(#BUTTON_LAUNCH, 295, 30, 100, 21, "Launch")
;===========================================================================
;-MAIN LOOP
;===========================================================================
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case #BUTTON_LAUNCH
RunProgram(ExeName)
Delay(GetGadgetState(#SPIN_TIME) * 1000)
CaptureScreen()
Case #BUTTON_SELECTEXE
ExeName = OpenFileRequester(#APP_NAME, "", "Executable (*.exe) | *.exe", 0)
SetGadgetText(#STRING_EXE, ExeName)
Case #SPIN_TIME
SetGadgetText(#SPIN_TIME, Str(GetGadgetState(#SPIN_TIME)))
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
End
But if he started programming today then that will be hebrew for him
I would help you but I only help when I know the purpose of the application
(dont blame me). Whats the deal with automatic screenies? I would write a burst-mode screenshooter so when theres good action I press a key and it takes a sequence, that sounds more interesting for a client.
Now for server-side via client, I would use this for checking if they are using some sort of hack (wallhack, ballhack, whitewalls, etc etc etc) so once the screenshot is in memory send it to the server and store it among some useful data. (date, client ip, uid, etc).
or what?

I would help you but I only help when I know the purpose of the application

Now for server-side via client, I would use this for checking if they are using some sort of hack (wallhack, ballhack, whitewalls, etc etc etc) so once the screenshot is in memory send it to the server and store it among some useful data. (date, client ip, uid, etc).
or what?

Re: Deal with Screenshots ... can it be done?
well kale's method probaly works but is very advanced hehb1be wrote:Oks.. since i'm new at PureBasic... i have one little question (or let's say Problem)
1. I want to run a PB code (LOL)
2. Within this code Launch a "Game or App or something" (but mainly a GAME)
3. Set a "DELAY" let-s say 20-30 seconds
4. While The "Game" runs Take a Screenshot and save it to .jpg mainly
If the game has any key to press on keyboard to grab picture, then it would be easier just to make a program that:
1. Launch game
2. Wait 20 seconds
3. Send the screenshotkey to game/program [to grap all just send print screen and grap image from memory..] Well kale's method will only capture the window wich you cant do with the printscreen
4. If the game has ingame screenshot-key and its used then copy the pic
from wherever game holds image to wherever you want the image to be and convert it to JPG if not already.
i know kale's method is better but this is far simpler to program and understand for a beginner

1st part
... ok ... I Just started with PureBasic ...
... but i have some experience in old Spectrum BASIC ..
,Visual Basic, BlitzBasic(Lacks of features btw), a little Old PASCAL and DELPHI, ... dunno' verry little C, ....
2nd part
it will be a kind of LAN Chat with MULTIFEATURES ....
i saw the sendfile command and others that will improve my work greatley .. (i started this project in BLITZ .. but... memoryhungry prog and loads of workarounds .... lacks in features)
in BLITZ .... i could make the screenshot of the desktop and Opengl, but if it was D3D->black screen ...
... (didn't try the code yet ... (when i'm writing this...)
delay ... what really should happen is when someone sends a //TAKE SCREENSHOT// command over chat i need to see what that people's doing ...
...
server sends takescreenshot .. client makes screenshot.. saves to jpeg... sends to server... server views the screenshot...
(bad english i know... but you may get the point) - if he's playing a game or whatever ... "I NEVER SAW THIS IN A CHAT PORG.." ...
or depending in "HOW MUCH MEMORY WILL TAKE" this may be set to auto (if it doesnt take so much ... like 10-20 secs let's say) ...
Thank you .... for the code...



2nd part
it will be a kind of LAN Chat with MULTIFEATURES ....
i saw the sendfile command and others that will improve my work greatley .. (i started this project in BLITZ .. but... memoryhungry prog and loads of workarounds .... lacks in features)
in BLITZ .... i could make the screenshot of the desktop and Opengl, but if it was D3D->black screen ...

delay ... what really should happen is when someone sends a //TAKE SCREENSHOT// command over chat i need to see what that people's doing ...

server sends takescreenshot .. client makes screenshot.. saves to jpeg... sends to server... server views the screenshot...
(bad english i know... but you may get the point) - if he's playing a game or whatever ... "I NEVER SAW THIS IN A CHAT PORG.." ...
or depending in "HOW MUCH MEMORY WILL TAKE" this may be set to auto (if it doesnt take so much ... like 10-20 secs let's say) ...
Thank you .... for the code...

Last edited by b1be on Sun Mar 20, 2005 1:22 pm, edited 1 time in total.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Works okay here with the usual PB 4 adjustments.
Code: Select all
;===========================================================================
;-CONSTANTS
;===========================================================================
#APP_NAME = "Delayed Screenshot taker v1.0"
Enumeration
#WINDOW_ROOT
#STRING_EXE
#BUTTON_SELECTEXE
#SPIN_TIME
#TEXT_SECONDS
#BUTTON_LAUNCH
#TIMER_MAIN
EndEnumeration
;===========================================================================
;-GLOBAL FLAGS / VARIABLES / STRUCTURES / ARRAYS
;===========================================================================
Global ExeName.s
;===========================================================================
;-PROCEDURES
;===========================================================================
;Handle an error
Procedure HandleError(Result, Text.s)
If Result = 0 : MessageRequester("Error", Text, #PB_MessageRequester_Ok) : End : EndIf
EndProcedure
;capture the screen
Procedure.l CaptureScreen()
ScreenWidth = GetSystemMetrics_(#SM_CXSCREEN)
ScreenHeight = GetSystemMetrics_(#SM_CYSCREEN)
dm.DEVMODE
BMPHandle.l
srcDC = CreateDC_("DISPLAY", "", "", dm)
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, ScreenWidth, ScreenHeight)
SelectObject_( trgDC, BMPHandle)
BitBlt_(trgDC, 0, 0, ScreenWidth, ScreenHeight, srcDC, 0, 0, #SRCCOPY)
DeleteDC_(trgDC)
ReleaseDC_(BMPHandle, srcDC)
CreateImage(0, ScreenWidth, ScreenHeight)
StartDrawing(ImageOutput(0))
DrawImage(BMPHandle, 0, 0)
StopDrawing()
UseJPEGImageEncoder()
Debug SaveImage(0, "Screenshot.jpg", #PB_ImagePlugin_JPEG)
End
EndProcedure
;===========================================================================
;-GEOMETRY
;===========================================================================
HandleError(OpenWindow(#WINDOW_ROOT, 0, 0, 400, 55, #APP_NAME,#PB_Window_SystemMenu | #PB_Window_ScreenCentered), "Main window could not be created.")
HandleError(CreateGadgetList(WindowID(#WINDOW_ROOT)), "Gadget list for the main window could not be created.")
StringGadget(#STRING_EXE, 5, 5, 285, 21, "")
ButtonGadget(#BUTTON_SELECTEXE, 295, 5, 100, 21, "Select Program...")
SpinGadget(#SPIN_TIME, 5, 30, 50, 21, 1, 1000)
SetGadgetState(#SPIN_TIME, 60) : SetGadgetText(#SPIN_TIME,"60")
TextGadget(#TEXT_SECONDS, 60, 33, 140, 21, "Seconds until screenshot.")
ButtonGadget(#BUTTON_LAUNCH, 295, 30, 100, 21, "Launch")
;===========================================================================
;-MAIN LOOP
;===========================================================================
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case #BUTTON_LAUNCH
RunProgram(ExeName)
Delay(GetGadgetState(#SPIN_TIME) * 1000)
CaptureScreen()
Case #BUTTON_SELECTEXE
ExeName = OpenFileRequester(#APP_NAME, "", "Executable (*.exe) | *.exe", 0)
SetGadgetText(#STRING_EXE, ExeName)
Case #SPIN_TIME
SetGadgetText(#SPIN_TIME, Str(GetGadgetState(#SPIN_TIME)))
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
End
I may look like a mule, but I'm not a complete ass.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact: