DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Screenshot Tool (Autoit)

11.22.2009
| 6397 views |
  • submit to reddit
        // A tool that can be used to take screen shots of your desktop

HotKeySet ( "{F10}", "DID_CLICK" )
HotKeySet ( "{F11}", "CLOSE" )
TraySetToolTip("Mr.Numbers Quick Screen Shot")
Opt("TrayMenuMode",1)

$JPEG_ITEM  = TrayCreateItem("JPEG")
TrayCreateItem("")
$PNG_ITEM = TrayCreateItem("PNG")
TrayCreateItem("")
$BMP_ITEM   = TrayCreateItem("BMP")
TrayCreateItem("")
$EXIT_ITEM	= TrayCreateItem("Exit")


MsgBox( 0, "Mr.Numbers Quick Screen Shot", "Welcome to Mr.Numbers quick screen shot tool! Using this tool, you can take quick screenshots!")
MsgBox( 0, "Mr.Numbers Quick Screen Shot", "Please tell me where to save your files!")
$WINDOWSPATH = FileSelectFolder ( "Choose A Folder", "" , 1 )

If $WINDOWSPATH = "" Then
	Exit 0
	Endif

MsgBox( 0, "Mr.Numbers Quick Screen Shot", "Press OK to start your screen capturing! Simply press F10! (Your clipboard will be erased)")
MsgBox( 0, "Mr.Numbers Quick Screen Shot", "Edit the DATA.INI File to change the desired file format")
MsgBox( 0, "Mr.Numbers Quick Screen Shot", "Press F11 to close this program")
$NUMBER = IniRead( $WINDOWSPATH & "\" & "DATA.INI", "INI", "NUMBER", "x")
If $NUMBER = "X" Then
	IniWrite( $WINDOWSPATH & "\DATA.INI", "INI", "NUMBER", "1")
	IniWrite( $WINDOWSPATH & "\DATA.INI", "INI", "FILETYPE", "JPEG")
	IniWrite( $WINDOWSPATH & "\DATA.INI", "COMMENTS", "DIFFERENT FILE TYPES", "JPEG, PNG, BMP")
	$NUMBER = IniRead( $WINDOWSPATH & "\" & "DATA.INI", "INI", "NUMBER", "")
	$FILETYPE = IniRead( $WINDOWSPATH & "\" & "DATA.INI", "INI", "FILETYPE", "JPEG")
	EndIf

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $JPEG_ITEM
            IniWrite( $WINDOWSPATH & "\DATA.INI", "INI", "FILETYPE", "JPEG")
        Case $msg = $PNG_ITEM
            IniWrite( $WINDOWSPATH & "\DATA.INI", "INI", "FILETYPE", "PNG")
        Case $msg = $BMP_ITEM
			IniWrite( $WINDOWSPATH & "\DATA.INI", "INI", "FILETYPE", "BMP")
        Case $msg = $EXIT_ITEM
            ExitLoop
    EndSelect
WEnd


Func DID_CLICK()
	$NUMBER = IniRead( $WINDOWSPATH & "\" & "DATA.INI", "INI", "NUMBER", "x")
	$FILETYPE = IniRead( $WINDOWSPATH & "\" & "DATA.INI", "INI", "FILETYPE", "JPEG")
	Send("{PRINTSCREEN}")
    Run( "mspaint.exe" )
	WinWaitActive("Untitled - Paint")
	Send("^v")
	WinClose("Untitled - Paint")
	WinWaitActive( "Paint")
	Send("s")
	WinWaitActive( "Save As" )
	Send($WINDOWSPATH & "\" & $NUMBER)
	If $FILETYPE = "JPEG" Then
		Send("{Enter}")
	Elseif $FILETYPE = "PNG" Then
		Send("{TAB}")
		Send("p")
		Send("{ENTER}")
	Elseif $FILETYPE = "BMP" Then
		Send("{TAB}")
		Send("{DOWN}")
		Send("{UP}")
		Send("{ENTER}")
		Send("{ENTER}")
		Endif
	INIWrite( $WINDOWSPATH & "\DATA.INI", "INI", "NUMBER", $NUMBER + 1)
		
EndFunc

Func CLOSE()
	Exit 0
EndFunc