#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <SendMessage.au3>
#include <Date.au3>
Global $hGUI = GUICreate("Example",700,700)
GUISetState(@SW_SHOW,$hGUI)
Local $idMyedit = GUICtrlCreateEdit("12345mytext12345hellomytext", 50, 0, 500, 500)
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
Local $idFilemenu1 = GUICtrlCreateMenu("Меню")
Local $idFileitem1 = GUICtrlCreateMenuItem("Открыть файл", $idFilemenu1)
Local $idFileitem2 = GUICtrlCreateMenuItem("Сохранить файл", $idFilemenu1)
Local $idFileitem3 = GUICtrlCreateMenuItem("Установить имя файла по умолчанию", $idFilemenu1)
Local $idFileitem5 = GUICtrlCreateMenuItem("Выход ", $idFilemenu1)
Local $idFilemenu2 = GUICtrlCreateMenu("Правка")
Local $idFile2item1 = GUICtrlCreateMenuItem("Вырезать", $idFilemenu2)
Local $idFile2item2 = GUICtrlCreateMenuItem("Копировать", $idFilemenu2)
Local $idFile2item3 = GUICtrlCreateMenuItem("Вставить", $idFilemenu2)
Local $idFile2item4 = GUICtrlCreateMenuItem("Удалить", $idFilemenu2)
Local $idFile2item5 = GUICtrlCreateMenuItem("Найти", $idFilemenu2)
Local $idFile2item6 = GUICtrlCreateMenuItem("Найти далее", $idFilemenu2)
Local $idFile2item7 = GUICtrlCreateMenuItem("Найти ранее", $idFilemenu2)
Local $idFile2item8 = GUICtrlCreateMenuItem("Заменить", $idFilemenu2)
Local $idFile2item9 = GUICtrlCreateMenuItem("Выделить все", $idFilemenu2)
Local $idFile2item10 = GUICtrlCreateMenuItem("Время и дата", $idFilemenu2)
Local $idScreen = GUICtrlCreateMenuItem("На полный экран", $idFilemenu2)
Local $idFilemenu3 = GUICtrlCreateMenu("Формат")
Local $idFile3item1 = GUICtrlCreateMenuItem("Шрифт", $idFilemenu3)
Local $idFilemenu4 = GUICtrlCreateMenu("Архив файлов")
Local $idArchive = GUICtrlCreateMenuItem("Добавить файл в архив", $idFilemenu4)
Local $idFilemenu5 = GUICtrlCreateMenu("Инструменты компиляции")
Local $idSettings = GUICtrlCreateMenuItem("Настроить командную строку", $idFilemenu5)
Local $count = 0
Local $localtext = "12345"
Local $newtext = ""
Local $namefile="test.au3"
$replacetext = "-"
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI)
ExitLoop
Case $idFileitem1
Local $sFileOpenDialog = FileOpenDialog("", @DesktopDir & "\", "Текстовые файлы (*.txt)")
Local $hFileOpen = FileOpen($sFileOpenDialog, $FO_READ)
Local $sFileRead = FileRead($hFileOpen)
GUICtrlSetData($idMyedit,$sFileRead)
Case $idFileitem2
Local $sFileSaveDialog = FileSaveDialog("", @DesktopDir & "\", "Текстовые файлы (*.txt)",2,$namefile)
Local $hFileOpen = FileOpen($sFileSaveDialog,$FO_APPEND)
Local $sData = GUICtrlRead($idMyedit)
FileWrite( $hFileOpen,$sData)
Case $idFileitem3
gui1()
Case $idFileitem5
Exitloop
;Меню 2
Case $idFile2item1
$aCtrlRecvMsg = GUICtrlRecvMsg($idMyedit, $EM_GETSEL)
MsgBox($MB_SYSTEMMODAL, "", "Start: " & $aCtrlRecvMsg[0] & " End: " & $aCtrlRecvMsg[1])
Local $sData = GUICtrlRead($idMyedit)
$sData = StringMid($sData,$aCtrlRecvMsg[0]+1,$aCtrlRecvMsg[1])
msgbox(0,"title",$sData)
ClipPut($sData)
Case $idFile2item2
$aCtrlRecvMsg = GUICtrlRecvMsg($idMyedit, $EM_GETSEL)
MsgBox($MB_SYSTEMMODAL, "", "Start: " & $aCtrlRecvMsg[0] & " End: " & $aCtrlRecvMsg[1])
Local $sData = GUICtrlRead($idMyedit)
$sData = StringMid($sData,$aCtrlRecvMsg[0]+1,$aCtrlRecvMsg[1])
msgbox(0,"title",$sData)
GUICtrlSetData($idMyedit, $sData )
ClipPut($sData)
Case $idFile2item3
Local $sData = ClipGet()
GUICtrlSetData($idMyedit, $sData )
Case $idFile2item4
$aCtrlRecvMsg = GUICtrlRecvMsg($idMyedit, $EM_GETSEL)
MsgBox($MB_SYSTEMMODAL, "", "Start: " & $aCtrlRecvMsg[0] & " End: " & $aCtrlRecvMsg[1])
Local $sData = GUICtrlRead($idMyedit)
Local $text = ""
for $i = 0 to stringlen($sData)+1
if $i < $aCtrlRecvMsg[0]+1 then $text &= StringMid($sData,$i,1)
if $i > $aCtrlRecvMsg[1] then $text &= StringMid($sData,$i,1)
next
GUICtrlSetData($idMyedit,$text)
case $idFile2item5
gui2()
case $idFile2item6
local $text1 = GUICtrlRead($idMyedit)
$count = $count + 1
ffind($text1)
case $idFile2item7
if $count > 0 then $count = $count - 1
local $text1 = GUICtrlRead($idMyedit)
ffind($text1)
case $idFile2item8
gui3()
case $idFile2item9
GUICtrlSendMsg($idMyedit, $EM_SETSEL, 0,-1)
case $idFile2item10
local $text = GUICtrlRead($idMyedit)
$text &= @CRLF & _NowTime() & " " & _NowDate()
GUICtrlSetData($idMyedit,$text)
case $idScreen
WinMove($hGUI , "", 0, 0,@DesktopWidth, @DesktopHeight)
case $idFile3item1
gui4()
;меню 4
Case $idArchive
local $text = GUICtrlRead($idMyedit)
$name = InputBox("Сообщение","Введите имя файла","test.txt")
msgbox(0,"cjj,otybt",@ScriptDir &"\archive\")
Local $iFileExists = FileExists(@ScriptDir &"\archive\")
If $iFileExists Then
Local $sFilePath =@ScriptDir &"\archive\"&$name
Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
FileWrite($hFileOpen, $text)
MsgBox(0,"сообщение","Файл "& $name &" добавлен в архив")
Else
MsgBox(0,"сообщение","Директория archive создана.Файл "& $name &" добавлен в архив")
DirCreate(@ScriptDir &"\archive\")
Local $sFilePath = @ScriptDir &"\archive\"&$name
Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
FileWrite($hFileOpen, $text)
Endif
Case $idSettings
gui5()
EndSwitch
WEnd
Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 1)
for $i = 0 to 20
$tLayout = _GDIPlus_RectFCreate(0, $i*20, 100, 20)
_GDIPlus_GraphicsDrawStringEx($hGraphic, String($i), $hFont, $tLayout, $hFormat, $hBrush)
next
EndFunc
Func ffind($text1)
Local $n = StringInStr($text1,$localtext,0,$count)
if $n = 0 then
$count = 0
Msgbox(0,"title","Больше совпадений не найдено")
EndIf
GUICtrlSendMsg($idMyedit, $EM_SETSEL,$n - 1,$n -1 +stringlen($localtext))
return $n
EndFunc
func deletesymbol($text1,$c,$reptext)
$newtext = ""
for $i = 1 to $c-1
$newtext &= stringmid($text1,$i,1)
next
$newtext &= $reptext
for $i = $c+stringlen($localtext) to stringlen($text1)
$newtext &= stringmid($text1,$i,1)
next
EndFunc
Func gui1()
Local $hGUI1 = GUICreate("GUI 2",500,500)
Local $idText = GUICtrlCreateInput("", 0, 0, 300, 25)
GUICtrlSetData($idText, $namefile)
$idButton = GUICtrlCreateButton("Установить имя", 300, 0, 180, 25)
GUISetState(@SW_SHOW, $hGUI1)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI1)
ExitLoop
Case $idButton
local $text = GUICtrlRead($idMyedit)
$namefile = GUICtrlRead($idText)
GUIDelete($hGUI1)
ExitLoop
EndSwitch
WEnd
EndFunc
func gui2()
Local $hGUI2 = GUICreate("GUI 2",500,500)
Local $idText = GUICtrlCreateInput("1", 0, 0, 300, 25)
GUICtrlSetData($idText, $localtext)
$idButton = GUICtrlCreateButton("Найти", 350, 0, 80, 25)
GUISetState(@SW_SHOW, $hGUI2)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI2)
ExitLoop
Case $idButton
local $text1 = GUICtrlRead($idMyedit)
$localtext = GUICtrlRead($idText)
$count = $count + 1
ffind($text1)
GUIDelete($hGUI2)
ExitLoop
EndSwitch
WEnd
EndFunc
func gui3()
Local $hGUI3 = GUICreate("GUI 2",500,500)
Local $idText1 = GUICtrlCreateInput("1", 0, 0, 300, 25)
Local $idText2 = GUICtrlCreateInput("1", 0, 50, 300, 25)
GUICtrlSetData($idText1, $localtext)
GUICtrlSetData($idText2, $replacetext)
$idButton = GUICtrlCreateButton("Заменить", 350, 0, 80, 25)
GUISetState(@SW_SHOW, $hGUI3)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI3)
ExitLoop
Case $idButton
local $text1 = GUICtrlRead($idMyedit)
$localtext = GUICtrlRead($idText1)
$replacetext = GUICtrlRead($idText2)
$count = 1
$c = ffind($text1)
$reptext = GUICtrlRead($idText2)
if $c > 0 then
deletesymbol($text1,$c,$reptext)
EndIf
GUICtrlSetData($idMyedit,$newtext)
msgbox(0,"title",$newtext)
GUIDelete($hGUI3)
ExitLoop
EndSwitch
WEnd
EndFunc
func gui4()
Local $hGUI4 = GUICreate("Шрифт",500, 200)
Local $idComboBox = GUICtrlCreateCombo("20", 10, 10, 185, 20)
Local $idButton = GUICtrlCreateButton("Установить размер", 0, 70, 250, 25)
Local $sizes = ""
for $i = 0 to 100
$sizes &= $i & "|"
next
GUICtrlSetData($idComboBox, $sizes)
GUISetState(@SW_SHOW, $hGUI4)
Local $sComboRead = ""
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI4)
ExitLoop
Case $idButton
$sComboRead = GUICtrlRead($idComboBox)
GUICtrlSetFont($idMyedit,$sComboRead )
GUIDelete($hGUI4)
ExitLoop
EndSwitch
WEnd
EndFunc
func gui5()
Local $hGUI5 = GUICreate("Настройка компилятора",500, 400)
GUICtrlCreateLabel("Путь к компилятору",10,10)
Local $idPathCompiler = GUICtrlCreateInput("", 10, 50, 400, 20)
GUICtrlSetData($idPathCompiler,@AutoItExe)
GUICtrlCreateLabel("Путь к исходному файлу",10,110)
Local $idPathFile = GUICtrlCreateInput("", 10, 150, 400, 20)
GUICtrlSetData($idPathFile,@ScriptDir &"\"& $namefile)
Local $idRun = GUICtrlCreateInput("", 10, 200, 400, 20)
Local $command = @AutoItExe & " " & @ScriptDir &"\"& $namefile
GUICtrlSetData( $idRun,$command )
Local $idButton = GUICtrlCreateButton("Запустить скрипт", 0, 270, 250, 25)
GUISetState(@SW_SHOW, $hGUI5)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI5)
ExitLoop
Case $idButton
Run($command )
GUIDelete($hGUI5)
ExitLoop
EndSwitch
WEnd
EndFunc
|