Четверг, 28.11.2024, 09:39 | Приветствую Вас Гость

...

Код

Главная » Статьи » Autoit

SText

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <SendMessage.au3>
#include <Date.au3>

Local $hGUI = GUICreate("Example",700,700)
Local $idMyedit = GUICtrlCreateEdit("12345mytext12345hellomytext", 0, 0, 500, 500)

Local $idFilemenu1 = GUICtrlCreateMenu("Меню")
Local $idFileitem1 = GUICtrlCreateMenuItem("Открыть файл", $idFilemenu1)
Local $idFileitem2 = 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 $idFilemenu3 = GUICtrlCreateMenu("Формат")
Local $idFile3item1 = GUICtrlCreateMenuItem("Шрифт", $idFilemenu3)

GUISetState(@SW_SHOW, $hGUI)
Local $count = 0
Local $localtext = "12345"
Local $newtext = ""
$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)")

Local $hFileOpen = FileOpen($sFileSaveDialog,$FO_APPEND)
Local $sData =   GUICtrlRead($idMyedit)
FileWrite( $hFileOpen,$sData)


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

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

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

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

case $idFile2item9
GUICtrlSendMsg($idMyedit, $EM_SETSEL, 0,-1)

case $idFile2item10
local $text = GUICtrlRead($idMyedit)
$text &= @CRLF & _NowTime() & " " & _NowDate()
GUICtrlSetData($idMyedit,$text)

case $idFile3item1

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

EndSwitch
WEnd


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

Категория: Autoit | Добавил: moskov (26.12.2021)
Просмотров: 125 | Рейтинг: 0.0/0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]

Меню сайта

Категории раздела

PHP [41]
C++ [71]
Autoit [108]
Processing [105]
Basic4GL [7]
Fasm [2]
PABC [7]
Js [236]
Gentee [1]
Python [204]
Java android [3]
Small Basic [9]

Мини-чат

Статистика


Онлайн всего: 6
Гостей: 6
Пользователей: 0

Форма входа

Друзья сайта

  • ЗОВ КОСМОСА

  • Хулиган Вселенной

  • Тюремная поэзия

  • Религиозная поэзия

  • Сайт клана ЛеГиоН
  • Поиск