• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4517
  • Last Modified:

print screen ASCII code

in my  if i click in ctrl+W  the make action to print screen   the same thing  (print screen button) on keyboard

how can make this ?
0
newnewmommon
Asked:
newnewmommon
  • 4
  • 3
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
(...attempts a translation...)

So you want to simulate a PrtScr keypress when the users press Ctrl-W in your Form?
0
 
newnewmommonAuthor Commented:
yes
simulate a PrtScr keypress when the users press Ctrl-W in your Form


sorry about my language
i want to say ( in my application ...)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
What version C# you working with?
0
Independent Software Vendors: 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!

 
newnewmommonAuthor Commented:
.Net 2.0
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Something like...

        private void Form1_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;            
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.W)
            {
                SendKeys.Send("{PRTSC}");
            }
        }

The Ctrl key would still be down when PrtScr is sent so you won't get a complete screen capture...just the form itself.  Is this what you wanted?
0
 
newnewmommonAuthor Commented:
ok nice but how if i make  try icon
and want my application listen  to the keyboard if i'm using another application ?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
That's a completely different ball game...

If you don't have your app in focus then you have several options:

(1) Register a HotKey with the system using the RegisterHotkey() API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/registerhotkey.asp

This option only responds to your registered keystroke combination.  The downside is that if your desired combination is already registered with another application then you are out of luck...

(2) Use a low level keyboard hook via WH_KEYBOARD_LL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/LowLevelKeyboardProc.asp

This options makes ALL keystrokes pass thru your application.  You then take action when the correct combination of keys is present.

(3) Use a Timer and the GetKeyState() / GetAsyncKeyState() APIs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getkeystate.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getasynckeystate.asp

This downside to this approach is that you are continously polling the keyboard state.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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