topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 6:43 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Request: Left-mouse-click triggers a PrtScr press in the background  (Read 22622 times)

davidvan

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
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.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #1 on: October 15, 2009, 10:32 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.

davidvan

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #2 on: October 15, 2009, 10:59 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.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #3 on: October 15, 2009, 04:51 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.

Code: AutoIt [Select]
  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 PM by skwire »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #4 on: October 15, 2009, 04:58 PM »
just tested it.. works.  very cool  :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 PM by mouser »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #5 on: October 15, 2009, 05:05 PM »
Thanks, mouser.   :D  The kudos needs to go to Microsoft, however, for providing the window message that makes it easy to do stuff like that.

davidvan

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #6 on: October 15, 2009, 08:59 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! 

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #7 on: October 15, 2009, 09:58 PM »
You want every left mouse click, no matter where, to trigger a PrintScreen?  If so:

Code: AutoIt [Select]
  1. ~LButton::
  2. {
  3.     Send, {PrintScreen}
  4.     ; Send, !{PrintScreen} ; Sends an alt-printscreen.
  5. }

davidvan

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #8 on: October 15, 2009, 11:51 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)? 

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #9 on: October 16, 2009, 12:38 AM »
This should do it (under XP, at least):

Code: AutoIt [Select]
  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 AM by skwire »

davidvan

  • Supporting Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #10 on: October 16, 2009, 11:22 AM »
Skwire,  this is perfect!  Thank you again for all your help!

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: Request: Left-mouse-click triggers a PrtScr press in the background
« Reply #11 on: October 16, 2009, 12:56 PM »
You're welcome.  Happy to help.   :D