Page 1 of 1

Press key while on a full screen game

Posted: Thu Feb 10, 2011 1:48 pm
by oftit
Hello all

How do you let the program to push a key while playing a full screen game? Iv'e been trying with keybd_event but did not succeed?

Thank you

Re: Press key while on a full screen game

Posted: Thu Feb 10, 2011 2:27 pm
by bobobo
use ExamineKeyboard() and KeyboardPushed(#PB_Key_whatever) in you eventloop

an examples resides in pb-help under sprite , named sprite.pb

Re: Press key while on a full screen game

Posted: Thu Feb 10, 2011 6:04 pm
by Rook Zimbabwe
I have a similar problem... I wanna take a screenshot but I can't out to the capture program while running my game... have to take a bad photo of my computer screen... very lame solution! :mrgreen:

Re: Press key while on a full screen game

Posted: Thu Feb 10, 2011 8:49 pm
by oftit
bobobo: Not my own program. While another program is runnning.
Rook: I think this works, while having a full screen program runnning:

Code: Select all

;/ Author : Kale / Droopy

; Return pointer to BMP SnapShot

Global CaptureScreenWidth , CaptureScreenHeight , CaptureScreenBMPHandle

Procedure CaptureScreenPart(Left.l, Top.l, Width.l, Height.l)
  dm.DEVMODE
  BMPHandle.l
  srcDC = CreateDC_("DISPLAY", "", "", dm)
  trgDC = CreateCompatibleDC_(srcDC)
  BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)
  SelectObject_( trgDC, BMPHandle)
  BitBlt_( trgDC, 0, 0, Width, Height, srcDC, Left, Top, #SRCCOPY)
  DeleteDC_( trgDC)
  ReleaseDC_( BMPHandle, srcDC)
 
  CaptureScreenHeight=Height
  CaptureScreenWidth=Width
  CaptureScreenBMPHandle=BMPHandle
  ProcedureReturn BMPHandle
EndProcedure

Procedure CaptureFullScreen()
  ProcedureReturn CaptureScreenPart(0,0,GetSystemMetrics_(#SM_CXSCREEN),GetSystemMetrics_(#SM_CYSCREEN))
EndProcedure

Procedure CaptureWindow(Handle.l) ; ### The Window must be visible !

    If Handle
      WindowSize.RECT
      GetWindowRect_(Handle, @WindowSize)
      ProcedureReturn CaptureScreenPart(WindowSize\Left, WindowSize\Top, WindowSize\Right - WindowSize\Left, WindowSize\Bottom - WindowSize\Top)
    EndIf
   
EndProcedure

; #PB_ImagePlugin_BMP / #PB_ImagePlugin_JPEG / #PB_ImagePlugin_PNG
; JpegCompression 0 (Bad) to 10 (Best) --> Only for Jpeg

Procedure SaveCapture(File.s, ImagePlugin , JpegCompression)
 
  If CaptureScreenBMPHandle
    Id=CreateImage(#PB_Any, CaptureScreenWidth, CaptureScreenHeight)
    StartDrawing(ImageOutput(Id))
    DrawImage(CaptureScreenBMPHandle,0,0)
    StopDrawing()
   
    Select ImagePlugin
     
      Case #PB_ImagePlugin_JPEG
        UseJPEGImageEncoder()
        Retour=SaveImage(Id, File,#PB_ImagePlugin_JPEG,JpegCompression)
       
      Case #PB_ImagePlugin_PNG
        UsePNGImageEncoder()
        Retour=SaveImage(Id, File,#PB_ImagePlugin_PNG)
       
      Default
        Retour=SaveImage(Id, File)
       
    EndSelect

    FreeImage(Id)
   
  EndIf
 
  ProcedureReturn Retour
EndProcedure

;/ Test
CaptureFullScreen()
SaveCapture("c:\CaptureFullScreen.png",#PB_ImagePlugin_PNG,0)
SaveCapture("c:\CaptureFullScreen.bmp",#PB_ImagePlugin_BMP,0)
SaveCapture("c:\CaptureFullScreen.Jpg",#PB_ImagePlugin_JPEG,10)
I think it says that Kale / Droopy made it.

Re: Press key while on a full screen game

Posted: Fri Feb 11, 2011 8:55 pm
by Zach
Rook Zimbabwe wrote:I have a similar problem... I wanna take a screenshot but I can't out to the capture program while running my game... have to take a bad photo of my computer screen... very lame solution! :mrgreen:
Most capture programs allow you to set hotkey combos... that should work?