0

simply put I want my program which runs in the background to check whether the print screen button has been pressed (which mostly triggers a function within another program to generate a screenshot of the current window. eg a game screen).

I have seen lots of possible answers, but most seem overkill for just detecting the print screen button.

I want to have a program in the background check so that it can move the screenshot that has just been made/saved to a certain location. after the button had been pressed.

I hope this question is clear, if not I'll try to explain more clearly.

ps On a side note, would it be better to try and detect the printscreen button or to simply check the specified folder every 1 or 5 minutes whether a new image has been put in that folder and then move it if true.

EDIT I decided to use the FileSystemWatch, however it seems to be to fast if i use the on create event as sometimes the file is still being made and it can't move the file yet. Would the best action be to use a timer to delay ?

Raskaroth
  • 639
  • 1
  • 9
  • 25

2 Answers2

2

You could just watch the folder location for updates using a FileSystemWatcher. There are many examples around the place.

Reddog
  • 15,219
  • 3
  • 51
  • 63
  • Thanks, I think that really is what I needed (as explained in my other comment). I'll check it out and see if it is what i was looking for, if so I'll mark this as my answer. – Raskaroth Sep 29 '11 at 14:57
2

Global keyboard capture in C# application

You should be able to use a global key hook to handle the print screen key press.

Community
  • 1
  • 1
Kevin Coulombe
  • 1,517
  • 1
  • 17
  • 35
  • As mentionned, you should probably use a FileSystemWatcher instead. Otherwise you'd probably catch the event before the file is created using a global key hook anyway... – Kevin Coulombe Sep 29 '11 at 01:43
  • I was planning on using a timer. currently i'm using a timmer that checks the folder every 5 minutes to see if a new file has been added that has to be moved. I'll look into the File System Watcher. The answer that you gave in your coment and that Reddog gave was really the reason i posted it, just couldn't figure out how to word it properly so went with the most simple solution – Raskaroth Sep 29 '11 at 14:55