Press key while on a full screen game

Just starting out? Need help? Post your questions and find answers here.
oftit
User
User
Posts: 52
Joined: Sun Apr 25, 2010 5:08 am

Press key while on a full screen game

Post 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
User avatar
bobobo
Enthusiast
Enthusiast
Posts: 206
Joined: Mon Jun 09, 2003 8:30 am

Re: Press key while on a full screen game

Post by bobobo »

use ExamineKeyboard() and KeyboardPushed(#PB_Key_whatever) in you eventloop

an examples resides in pb-help under sprite , named sprite.pb
사십 둘 .
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Press key while on a full screen game

Post 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:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
oftit
User
User
Posts: 52
Joined: Sun Apr 25, 2010 5:08 am

Re: Press key while on a full screen game

Post 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.
Zach
Addict
Addict
Posts: 1676
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Press key while on a full screen game

Post 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?
Post Reply