Help.. With Running My Program

CoBrA
03-08-2004, 06:35 AM
I looked through about everypost I could find that has anything to do with screenshots to try and solve this, but I cant find a answer.

I made a program that takes screenshots of my desktop and then saves them in a folder. When I run my program and Hit my command key (Keyboard letter =X) it works fine. BUT if I open my program and then start up a game and try to take a screenshot while I am in a game, it will NOT work, It will also NOT work if I Minimize the form and hit X.

I got it to work by putting it on a timer, then starting it and going into a game real fast and it saves a screenshot fine. I just cant get it to work by pressing my command key in a game.

If its the MAIN program running, it works fine, but as soon as I try it in a game or Minimize it, or try to run it with another program running (like PSP), it wont work.

I take lots of screenshots in some of my games, so useing the PrintScreen button is a pain. (1 pic at a time)

Can anyone help me out with this? I have searched and even downloaded some free codes, but they dont help.

Is there something I am missing that would keep my program from taking a screenshot during a game or when Minimized?

Thanks for any help or code that you could help me out with.
I really need it,lol :eek:

---------------------------------------------------
Code that I am Useing
---------------------------------------------------
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = 88
Call keybd_event(vbKeySnapshot, 1, 0, 0)
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "c:\TestPic.bmp"

End Sub
----------------------------------------------------------

Thanks

GavinO
03-08-2004, 10:14 AM
Your form can only receive keypresses when it is the active form (has focus). I think what you're looking for is something called like global keyboard hooks or something. Because of the way that it can be used for keyloggers, etc, info on it is kinda hard to get.

CoBrA
03-08-2004, 12:30 PM
Thanks. I found this topic
http://www.visualbasicforum.com/showthread.php?s=&threadid=66513

is this what you are referring to? I am new to VB, and I am not sure how some of these things work. All I know now is, my whole program is pretty much trash, since I cant use it for what I wanted. ( take in-game screenshots)

This su%$#.
Thanks for your help though. :D

GavinO
03-08-2004, 01:31 PM
That HotKey control that Merrion mentions is exactly what you want. It handles the hard parts of watching all keypresses system wide and alerts your program when the appropriate key is pressed. Hopefully that will make your app useful :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum