Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2258
  • Last Modified:

simulate a key press

Hi!

Maybe my question is very simple but I have no idea how to do it....
here´s my problem...

I have to take a screenshot of my computer every day at the same time and upload it to a server...
I was thinking to use a scheduled task in Windows to do this...after a long search for the right capturing program, Screenshot Utility 1.0 was the best I could find.
In this program you can configure your capture key and then de screenshot wil be saved at a pre-defined place.
Now for my question, I need to make a program wich simulates a press on the keyboard(for example C)...
I have no idea how to do that...The languages i know are powerbuilder, java en PHP...
but maybe I´ll have to use VB.

How can I do it the best and easiest way?!?!

thanks in advance,

willem
0
wbph
Asked:
wbph
5 Solutions
 
mattaustinCommented:
http://www.erginsoft.com/products/esc/ offers a commandline program to get a screen capture you could emulate this with:

system(C:\esc.exe desktop.bmp);

otherwise you may want to look into Gimp or GD to see if it offers anything for screen capture.
0
 
fantasy1001Commented:
You can do the screen shot pretty easy with VB:

Step:
Include the keybd_event API in your project
then add this code

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 Command1_Click()
    keybd_event vbKeySnapshot, 0, 0, 0
    SavePicture Clipboard.GetData, "c:\my.jpg"
End Sub
0
 
sunnycoderCommented:
just try if shell redirection works for you

command_prompt] path/to/executable < inputfile

in the inputfile just store the input you wish to provide .... in this case character c
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
RJSoftCommented:
In C++ VC it is harder to do.

After creating your application (via VC wizard (the easy way)) maybe a dialog based application. you might do this.

First setup a timer for the main class window. Basically the timer acts like a thread and runs in background. You can also hide your application in the background with ShowWindow api (SW_HIDE).

The timer thread can then be used to call up some function that you design to test how much elapsed time has passed. Something like GetTime which uses a structure that counts the number of seconds since 1970 or something like that. What you could do then is store to a file a starting time ( a first number of seconds since 1970) and then subtract that from the current number of seconds. That is how you could calculate the number of hours and minutes and seconds that have passed since the last time you took a screen shot. When that condition is met then use api SendMessage. Then you could send WM_KEYDOWN and set the WParam and lParam members to what the Print Screen Key is. Then also re-write the value of your first seconds to the current seconds.

If you can not get the SendMessage to work then you can also do it another way which is more difficult yet. You can save your screen as a bitmap. If you want that code I can send it to you. Then all you would have to do is call the function and the screen would be saved in a bitmap file.

RJSoft
0
 
jimmackCommented:
Have a look at the javadocs for java.awt.Robot.
0
 
vbs03Commented:
Hi,
Very easy. To type a charcter say "C" through VB app, just use function:

Sendkeys("C")

This will type the character "C" on the current visible application.
Regards,
vbs03
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now