AutoHotkey Community

It is currently May 27th, 2012, 10:03 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: ~PrintScreen~
PostPosted: May 10th, 2009, 1:27 am 
Offline

Joined: October 22nd, 2008, 11:52 am
Posts: 85
~PrintScreen~

Image

Enlarge

Copy the code below to notepd, save as ~PrintScreen~.ahk, compile it to ~PrintScreen~.exe if you wish, or simply run ~PrintScreen~.ahk. F9 snapshots active window, F12 captures the whole screen. Has tray icon and a non-standard menu.


Code:
; By Roman Sibirko
#NoEnv
#SingleInstance Force
Menu, Tray, Icon, Shell32.dll, 81
Menu, Tray, Icon,,, 1
Menu, Tray, NoStandard
Menu, Tray, Tip, ~PrintScreen~
Menu, Tray, Color, C0C0C0
Menu, Tray, Add, Snapshot
Menu, Tray, Add, Pause
Menu, Tray, Add, Exit
Return
Snapshot:
GoSub, PrntScr
Return
Pause:
Menu, Tray, ToggleCheck, Pause
Suspend, Toggle
Return
Exit:
ExitApp
F9::
Critical, On
BlockInput, On
SendInput {Alt Down}{PrintScreen}{Alt Up}
BlockInput, Off
BlockInput, Off
KeyWait, F9, U
Sleep 500
Run mspaint.exe
WinWait, Paint ahk_class MSPaintApp, , 10
IfWinNotExist, ahk_class MSPaintApp
Return
BlockInput, On
WinActivate, ahk_class MSPaintApp
ControlSend, , {Control Down}{v}{Control Up}
BlockInput, Off
BlockInput, Off
Return
F12::
PrntScr:
Critical, On
BlockInput, On
SendInput {PrintScreen} 
BlockInput, Off
BlockInput, Off
KeyWait, F12, U
Sleep 500
Run mspaint.exe
WinWait, Paint ahk_class MSPaintApp, , 10
IfWinNotExist, ahk_class MSPaintApp
Return
BlockInput, On
WinActivate, ahk_class MSPaintApp
ControlSend, , {Control Down}{v}{Control Up}
BlockInput, Off
BlockInput, Off
Return

_________________
AutoHotKey


Last edited by Roman on May 11th, 2009, 2:23 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: printscreen
PostPosted: May 10th, 2009, 1:59 am 
Offline

Joined: April 10th, 2009, 1:46 am
Posts: 139
Location: Wichita,Kansas
it works in viista too!

_________________
Drainx1
Your favorite.

What says that we aren't a visualization of someones dream?
And that person could change the laws of physics without thinking a thing about it.
They could recreate the world, and not know what happened.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 9:40 am 
Offline

Joined: July 17th, 2008, 9:46 am
Posts: 225
Thank you! 8)
Its a great Script!
Greets,
DHMH


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 5:29 pm 
Offline

Joined: May 2nd, 2006, 11:16 pm
Posts: 800
Location: Greeley, CO
Thanks, Rom.

_________________
Image
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2009, 4:42 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Drawbacks:
• Can't work in Win9x because of unsupported Up/Down hotkey variants.
• Directly calls MSPaint.exe, which is bad practice (same as directly calling iexplore.exe).
• Subsequent hotkey presses open multiple copies of MSPaint.
Advantages:
• Takes into account multi-monitor environments.

Alternative: link. Requires GDIPlus (which shouldn't be a problem for XP+ users and runs in Win9x too).

Drawbacks:
• No multi-monitor support.
Advantages:
• Runs in Win9x (when GDIPlus is installed).
• No external application required.
• Automatic management of files.

EDIT: There's this one too, with support for transparent windows and cursor, but doesn't work in 9x as is (haven't looked into the code yet): link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2009, 6:28 pm 
Offline

Joined: October 22nd, 2008, 11:52 am
Posts: 85
Drugwash wrote:
Drawbacks:
Can't work in Win9x because of unsupported Up/Down hotkey variants.


No problem, we can change that: Send ^v.


Drugwash wrote:
Directly calls MSPaint.exe, which is bad practice (same as directly calling iexplore.exe).


I've never had a problem with direct callimg a standard windows program in XP or Vista, that's why I put it that way, but there can be issues in some cases - you are right. Let's make it:
run %A_WinDir%\System32\mspaint.exe.


Drugwash wrote:
Subsequent hotkey presses open multiple copies of MSPaint.


True. This is what I meant it to do. I find it convenient to have a seperate instance of mspaint for each screenshot. However, it doesn't have to be this way only, below I provide a revised script that pastes screenshots into the same most recently used instance of mspaint. (Least recently used would be WinActivateBottom, ahk_class MSPaintApp > Send ).


Drugwash wrote:
Advantages:
Takes into account multi-monitor environments.


Perhaps it does, I do not have a multi-monitor environment at the time. If it does, the credit goes to Microsoft.

PrintScreen is not that bad, Mspaint editor is good enough to quickly cut a region from a screenshot. PrintScreen captures Aero and movies just fine, at least that's what I can do with ~PrintScreen~ in my Server 2008 right now:

ImageImageImage

For advanced screen capturing purposes I sometimes use HyperSnap DX, WinSnap, and Fraps. But the latest versions of these aren't applicable to quite a few modern games. So, Microsoft Printscreen is a good freeware alternative and is convinient to use with freeware Autohotkey.


Revised script that pastes screenshots into the same most recently used instance of mspaint:

Code:
; By Roman Sibirko
#NoEnv
#SingleInstance Force
#MaxThreadsBuffer, Off
#MaxThreadsPerHotkey, 1
#HotKeyModifierTimeOut, 500
SendMode Event
SetKeyDelay, 50
Menu, Tray, Icon, Shell32.dll, 81
Menu, Tray, Icon,,, 1
Menu, Tray, NoStandard
Menu, Tray, Tip, ~PrintScreen~
Menu, Tray, Color, C0C0C0
Menu, Tray, Add, Snapshot
Menu, Tray, Add, Pause
Menu, Tray, Add, Exit
Return
Snapshot:
GoSub, PrntScr
Return
Pause:
Menu, Tray, ToggleCheck, Pause
Suspend, Toggle
Return
Exit:
ExitApp
$F9::
Hotkey, F9, Off
Hotkey, F12, Off
#MaxThreadsPerHotkey, 1
Critical, On
BlockInput, On
Send {Blind}
Send !{PrintScreen}
BlockInput, Off
BlockInput, Off
KeyWait, F9, U
IfWinNotExist, ahk_class MSPaintApp
{
Run %A_WinDir%\System32\mspaint.exe
WinWait, Paint ahk_class MSPaintApp, , 5
}
Sleep 150
BlockInput, On
Send {Blind}
WinActivate, ahk_class MSPaintApp
ControlSend, , ^{v}, ahk_class MSPaintApp
BlockInput, Off
BlockInput, Off
Hotkey, F9, On
Hotkey, F12, On
Return
$F12::
PrntScr:
Hotkey, F9, Off
Hotkey, F12, Off
#MaxThreadsPerHotkey, 1
Critical, On
BlockInput, On
Send {Blind}
Send {PrintScreen}
BlockInput, Off
BlockInput, Off
KeyWait, F12, U
IfWinNotExist, ahk_class MSPaintApp
{
Run %A_WinDir%\System32\mspaint.exe
WinWait, Paint ahk_class MSPaintApp, , 5
}
WinActivate, ahk_class MSPaintApp
Sleep 150
BlockInput, On
Send {Blind}
ControlSend, , ^{v}, ahk_class MSPaintApp
BlockInput, Off
BlockInput, Off
Hotkey, F9, On
Hotkey, F12, On
Return




drainx1 wrote:
it works in viista too!


DHMH wrote:
Thank you!
Its a great Script!
Greets,
DHMH


SoggyDog wrote:
Thanks, Rom.


Thank you drainx1, DHMH, SoggyDog, Drugwash, thanks to all who participate in the autohotkey forums. Thank you for helping learn things, thank you for sharing links, and best regards to everyone.

Roman.

_________________
AutoHotKey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2009, 7:40 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Quote:
Let's make it:
run %A_WinDir%\System32\mspaint.exe.

That'd be even worse, at least for 9x which doesn't use System32 but System and either way, in 98SE the path is "C:\Program Files\Accessories\MSPAINT.EXE" or A_ProgramFiles "\Accessories\MSPAINT.EXE" in correct AHK syntax.

Still, the point was not to call a certain application by name, but try to find the default editor. I believe there's people who use only preferred applications and have them associated with different file types.

Anyway, this obviously aims at the recent version(s) of the PrintScreen function which apparently works better than in older versions of Windows. I should let it rest. :)
Keep up the good work! 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2009, 8:22 pm 
Drugwash wrote:
I should let it rest.

Yes, you really should. I can't come to a thread without seeing you in there somewhere complaining that stuff doesn't work with your tired-assed antiquated system.

OS Usage Statistics (December 2008):
Windows XP = 72.0%
Windows 2000 = 1.8%
Windows 98 = 0.1%
Windows Vista = 15.1%
Windows 2003 = 1.6%
Linux = 3.8%
Mac OS = 5.3%


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2009, 8:50 pm 
Offline

Joined: October 22nd, 2008, 11:52 am
Posts: 85
Drugwash wrote:
Quote:
Let's make it:
run %A_WinDir%\System32\mspaint.exe.

That'd be even worse, at least for 9x which doesn't use System32 but System and either way, in 98SE the path is "C:\Program Files\Accessories\MSPAINT.EXE" or A_ProgramFiles "\Accessories\MSPAINT.EXE" in correct AHK syntax.


I never had a chance to try Widows 98, so your info is new to me. Thanks.

Drugwash wrote:
Still, the point was not to call a certain application by name, but try to find the default editor. I believe there's people who use only preferred applications and have them associated with different file types.


Now I see your point. Yet I think it is not easy and perhaps redundant to create an editor in .ahk, you know as if to reinvent the bycicle. You can do things in mspaint, and of cource anytime you can start an editor you prefer and paste the screenshot there. Besides, very often we do not need advanced features and rather use Cut and Save As only. Another point is that unlike other editors, mspaint is accessible to everybody. Anyway this is not a problem at all if a user chages run, mspaint to run prefered editor.

Drugwash wrote:
Anyway, this obviously aims at the recent version(s) of the PrintScreen function which apparently works better than in older versions of Windows. I should let it rest. :)
Keep up the good work! 8)


Thank you for comments and for kind words.

_________________
AutoHotKey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2009, 1:21 am 
Offline

Joined: May 2nd, 2006, 11:16 pm
Posts: 800
Location: Greeley, CO
@2009

What's your problem?
DW constantly makes positive contributions to the AHK forums.
You will also see him in many of these threads HELPING MAKE SCRIPTS BETTER.

Get over yourself.

_________________
Image
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: sks and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group