Welcome Guest.   Make a donation to an author on the site November 21, 2014, 01:01:57 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2014! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Request: Left-mouse-click triggers a PrtScr press in the background  (Read 8997 times)
davidvan
Supporting Member
**
Posts: 6

View Profile Give some DonationCredits to this forum member
« on: October 15, 2009, 10:11:46 AM »

Basically, I am currently using Screenshot Captor and I defined the PrtScr button to capture the active window each time I press it.  What I hope to do is to eliminate the need to press the PrtScr button by leveraging the left-button click on mouse to trigger it.  The left-mouse button click must still function as normal but now with an added function of simulating a press of the PrtScr button.  Is there such a program available that can help me do this?  Or can someone create a script to do this?  Thank you in advance for any suggestions.
Logged
mouser
First Author
Administrator
*****
Posts: 33,682



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: October 15, 2009, 10:32:08 AM »

when we talked earlier i think an important aspect of what you wanted was not to trigger the hotkey every time you pressed the left mouse button, but only when you clicked left mouse button on the title bar of a menu.
Logged
davidvan
Supporting Member
**
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #2 on: October 15, 2009, 10:59:37 AM »

Yes, you are correct.  However, after giving it some thoughts, I figured it may be easier to implement for every click then conditional clicks.  If by making the request simpler, my hope is that I can find a close-enough solution sooner.   Thanks.
Logged
skwire
Global Moderator
*****
Posts: 4,157



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: October 15, 2009, 04:51:26 PM »

This AutoHotkey code will send a PrintScreen every time you left click a titlebar.  Save it out to something.ahk, run it, and left click a titlebar.  Let me know if you have issues.

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. ~LButton::
  2. {
  3.    CoordMode, Mouse, Screen
  4.    SetMouseDelay, -1
  5.    SetKeyDelay, -1
  6.    MouseGetPos, X, Y, hWnd
  7.  
  8.    ; 0x84 is WM_NCHITTEST
  9.    SendMessage, 0x84, , ( x & 0xFFFF ) | ( y & 0xFFFF ) << 16, , ahk_id %hWnd%
  10.    If ErrorLevel in 2,3,8,9,20,21
  11.    {
  12.        Send, {PrintScreen}
  13.        ; Send, !{PrintScreen} ; Sends an alt-printscreen.
  14.    }
  15. }
« Last Edit: October 15, 2009, 05:12:55 PM by skwire » Logged

mouser
First Author
Administrator
*****
Posts: 33,682



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: October 15, 2009, 04:58:01 PM »

just tested it.. works.  very cool  thumbs up
to make it trigger Alt+Prtscr (screenshot captor's default for capturing the active window) skwire said to use "Send, !{PrintScreen}"

That may be a small amount of code.. but there's a fair amount of knowledge behind it.  Kudos to skwire for another amazing job.  Thmbsup Thmbsup Thmbsup
« Last Edit: October 15, 2009, 04:59:47 PM by mouser » Logged
skwire
Global Moderator
*****
Posts: 4,157



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: October 15, 2009, 05:05:07 PM »

Thanks, mouser.   cheesy  The kudos needs to go to Microsoft, however, for providing the window message that makes it easy to do stuff like that.
Logged

davidvan
Supporting Member
**
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #6 on: October 15, 2009, 08:59:03 PM »

Skwire, this is awesome!  Thank you so much for such a quick turn-around.  I will test it tomorrow in my work pc...but given the confirmation from mouser (thanks!), I know it will work for me.

One question: what change can I make to the code to have every mouse click trigger the prtscr without clicking on the titlebar?  Is this significantly more difficult to achieve?  Thanks! 
Logged
skwire
Global Moderator
*****
Posts: 4,157



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #7 on: October 15, 2009, 09:58:45 PM »

You want every left mouse click, no matter where, to trigger a PrintScreen?  If so:

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. ~LButton::
  2. {
  3.    Send, {PrintScreen}
  4.    ; Send, !{PrintScreen} ; Sends an alt-printscreen.
  5. }
Logged

davidvan
Supporting Member
**
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #8 on: October 15, 2009, 11:51:07 PM »

Thank you again.  This is exactly what I was looking for! 

A final question if I may (I promise):

If the mouse click in not on an application window (ie: desktop area, task bar, Start, etc.), can I not trigger the prtscr?  In other words, can I trigger only when a click is in an app window (including the title bar and border)? 
Logged
skwire
Global Moderator
*****
Posts: 4,157



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: October 16, 2009, 12:38:09 AM »

This should do it (under XP, at least):

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. ~LButton::
  2. {
  3.    CoordMode, Mouse, Screen
  4.    SetMouseDelay, -1
  5.    SetKeyDelay, -1
  6.    MouseGetPos, X, Y, hWnd
  7.  
  8.    WinGetClass, myClass, % "ahk_id " . hWnd
  9.  
  10.    If myClass not in Progman,Shell_TrayWnd
  11.    {
  12.        Send, {PrintScreen}
  13.    }
  14. }
« Last Edit: October 16, 2009, 12:41:48 AM by skwire » Logged

davidvan
Supporting Member
**
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #10 on: October 16, 2009, 11:22:38 AM »

Skwire,  this is perfect!  Thank you again for all your help!
Logged
skwire
Global Moderator
*****
Posts: 4,157



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #11 on: October 16, 2009, 12:56:33 PM »

You're welcome.  Happy to help.   cheesy
Logged

Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.214s | Server load: 0.2 ]