Что нового

Программа просмотра комментария к изображению

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
AutoIt: 3.3.6.1
Версия: 1.0

Категория: Разное

Описание: Позволяет создавать или вызывать комментарий к просматриваемому изображению. Условия работы программы: изображения просматриваются через Программу просмотра изображений и факсов ( встроенная в Windows).

Код/Пример:
Код:
#NoTrayIcon
#RequireAdmin
#include <WinAPI.au3>
#include <Misc.au3>
#include <File.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
Opt('GUICloseOnESC', 0)
_Singleton("pictures&comment_GUI.exe")
Global $sTitle = "Pictures&Comment"
$Form1 = GUICreate("Pictures&Comment", 147, 172, 850, 0, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
$comment = GUICtrlCreateButton("Комментарий", 8, 0, 131, 25, $WS_GROUP)
$esc = GUICtrlCreateButton("Клавиша(ESC)", 8, 24, 131, 25, $WS_GROUP)
$noesc = GUICtrlCreateButton("Отмена(ESC)", 8, 48, 131, 25, $WS_GROUP)
$archiv = GUICtrlCreateButton("Архив", 8, 72, 131, 25, $WS_GROUP)
$dellprog = GUICtrlCreateButton("Uninstall", 8, 96, 131, 25, $WS_GROUP)
$mini = GUICtrlCreateButton("Свернуть", 8, 120, 131, 25, $WS_GROUP)
$exit = GUICtrlCreateButton("Выход", 8, 144, 131, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg(0)
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $comment
			_RunFunc()
		Case $esc
			HotKeySet("{ESC}", "_RunFunc")
			WinSetState($sTitle, "", @SW_MINIMIZE)
		Case $noesc
			HotKeySet("{ESC}")
		Case $mini
			WinSetState($sTitle, "", @SW_MINIMIZE)
		Case $archiv
			ShellExecute(@MyDocumentsDir & "\Comments")
		Case $dellprog
			If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
			$iMsgBoxAnswer = MsgBox(65, "Удаление программы Pictures&Comment", "Для удаления нажмите ОК")
			Select
				Case $iMsgBoxAnswer = 1 ;OK
					FileCopy(@ScriptDir & "\uninstall.exe", @TempDir & "\uninstall.exe", 1)
					ShellExecute(@TempDir & "\uninstall.exe")
					_Exit()
				Case $iMsgBoxAnswer = 2 ;Cancel
			EndSelect
		Case $exit
			_Exit()
	EndSwitch
WEnd

Func _RunFunc()
	If @OSVersion = "WIN_XP" Then
		If WinExists("[CLASS:ShImgVw:CPreviewWnd]") = 0 Then
			Return
		EndIf
		_PictureComment()
	ElseIf @OSVersion = "WIN_7" Then
		If WinExists("[CLASS:Photo_Lightweight_Viewer]") = 0 Then
			Return
		EndIf
		_PictureComment7()
	EndIf
EndFunc   ;==>_RunFunc

Func _PictureComment()
	$sHandle = WinGetHandle("[CLASS:ShImgVw:CPreviewWnd]", "")
	$sText = _WinAPI_GetWindowText($sHandle)
	$sName = StringRegExpReplace($sText, '[.\h].*$', '')
	If FileExists(@MyDocumentsDir & "\Comments\" & $sName & ".txt") Then
		ShellExecute(@MyDocumentsDir & "\Comments\" & $sName & ".txt")
	Else
		If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
		$iMsgBoxAnswer = MsgBox(65, "Информация",  "Описание к " & """" & $sName & """" & " не создано." & @CRLF & "Создать?")
		Select
			Case $iMsgBoxAnswer = 1 
				_FileCreate(@MyDocumentsDir & "\Comments\" & $sName & ".txt")
				ShellExecute(@MyDocumentsDir & "\Comments\" & $sName & ".txt")
			Case $iMsgBoxAnswer = 2 
		EndSelect
	EndIf
EndFunc   ;==>_PictureComment

Func _PictureComment7()
	$sHandle = WinGetHandle("[CLASS:Photo_Lightweight_Viewer]", "")
	$sText = _WinAPI_GetWindowText($sHandle)
	$sName = StringRegExpReplace($sText, '[.\h].*$', '')
	If FileExists(@MyDocumentsDir & "\Comments\" & $sName & ".txt") Then
		ShellExecute(@MyDocumentsDir & "\Comments\" & $sName & ".txt")
	Else
		If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
		$iMsgBoxAnswer = MsgBox(65, "Информация", "Описание к " & """" & $sName & """" & " не создано." & @CRLF & "Создать?")
		Select
			Case $iMsgBoxAnswer = 1 
				_FileCreate(@MyDocumentsDir & "\Comments\" & $sName & ".txt")
				ShellExecute(@MyDocumentsDir & "\Comments\" & $sName & ".txt")
			Case $iMsgBoxAnswer = 2 
		EndSelect
	EndIf
EndFunc   ;==>_PictureComment7

Func _Exit()
	Exit
EndFunc   ;==>_Exit

Файл: AU3,EXE


Источник: autoit-script.ru

Автор(ы): joiner
 
Верх