; Test include
#include <Array.au3>
;//
; Globals
#Include <GuiTab.au3>
#include "AllConstants.au3" ; подключение всех констант
AutoItSetOption ("TrayIconHide", 1)
Global $winpos[4], $set[20], $gui_set_close=-1
;//
; Проверка повторного запуска
$process = ProcessList (@AutoItExe)
If $process[0][0] > 1 Then
WinActivate (@ScriptName)
Exit
EndIf
; //
$set = ReadSettings () ; чтение настроек
; ---------------------------------GUI----------------------------------------
$win = GUICreate(@ScriptName, $Set[2], $Set[3], $Set[0], $Set[1], $GUI_SS_DEFAULT_GUI+$WS_MAXIMIZEBOX+$WS_SIZEBOX, $WS_EX_COMPOSITED)
WinSetDefaultLang (0x0409) ; установка дефолтного языка окну
GUIRegisterMsg ($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING") ; Регистрация функции вызываемой при изменении позиции окна
GUIRegisterMsg ($WM_KILLFOCUS, "Exit_Timer") ; Регистрация функции вызываемой при потере фокуса
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") ; Регистрация функции вызываемой при сворачивании/разворачивании
; Построение меню Файл
$m_file = GUICtrlCreateMenu ("Файл")
$m_addtab = GUICtrlCreateMenuItem ('Добавить вкладку', $m_file)
$m_deltab = GUICtrlCreateMenuItem ('Удалить вкладку', $m_file)
$m_renametab = GUICtrlCreateMenuItem ('Переименовать вкладку', $m_file)
$m_encrypt = GUICtrlCreateMenuItem ('Шифровать вкладку', $m_file)
GUICtrlCreateMenuItem ('', $m_file)
$m_exit = GUICtrlCreateMenuItem ('Выход', $m_file)
;//
; Построение меню Настройки
$m_settings = GUICtrlCreateMenu ("Настройки")
$m_ch_font = GUICtrlCreateMenuitem ("Шрифт", $m_settings)
$m_ch_bgcolor = GUICtrlCreateMenuitem ("Цвет фона", $m_settings)
$m_trans = GUICtrlCreateMenuitem ("Прозрачность окна", $m_settings)
GUICtrlCreateMenuItem ('', $m_settings)
$m_CRLF = GUICtrlCreateMenuitem ("Перенос по словам", $m_settings)
_GUICtrlSwitchState($m_CRLF, $set[17], $GUI_UNCHECKED, $GUI_CHECKED)
$m_last_tab = GUICtrlCreateMenuitem ("Запоминать последнюю вкладку", $m_settings)
_GUICtrlSwitchState($m_last_tab, $set[18], $GUI_UNCHECKED, $GUI_CHECKED)
$m_autocenter = GUICtrlCreateMenuitem ("Всегда по центру", $m_settings)
$set[19]=_GUICtrlSwitchState($m_autocenter, $set[19], $GUI_UNCHECKED, $GUI_CHECKED)
$m_set_close = GUICtrlCreateMenuitem ("Параметры закрытия", $m_settings)
;//
; Построение меню Справка
$m_help = GUICtrlCreateMenu ("Справка")
$m_about = GUICtrlCreateMenuItem ("О программе", $m_help)
$m_hotkeys = GUICtrlCreateMenuItem ("Горячие клавиши", $m_help)
;//
$files = FileListToArray (@ScriptDir, "*.txt")
If Not IsArray ($files) Then
Dim $DATA[2][6]
$DATA[0][0] = 1
$DATA[1][0] = "Noname.txt" ; или new_tab()!!!!!!!!!!!!
$DATA[1][1] = ''
Else
Dim $DATA[$files[0]+1][6]
$DATA[0][0] = $files[0]
EndIf
;-----------------------------TEST-----------------------------
; не рабочий кусок
$tab_space = GUICtrlCreateTab(5, 5, $Set[2]-10, $set[3]-50)
For $i = 1 to $DATA[0][0]
$DATA[$i][0]=$files[$i]
GUICtrlCreateTabItem($DATA[$i][0])
$DATA[$i][5] = GUICtrlCreateEdit ('', 10, 50, $set[2]-20, $set[3]-100)
Next
;-----------------------------TEST-----------------------------
; Проверка стартовых параметров окна...
if $Set[4] = 1 Then WinSetState ($win, "", @SW_MAXIMIZE) ; ...на развернутость
If $Set[14] <> 0 Then ; ...на прозрачность
WinSetTrans ($win, '', -255*$Set[14]/100)
EndIf
If $set[19] = $GUI_CHECKED Then ; ...на автоцентрирование
$winpos = WinGetPos ($win)
WinMove ($win, '', $winpos[0]+1, $winpos[1]+1)
EndIf
;//
GUISetState (@SW_SHOW)
While 1
$msg = GUIGetMsg ($win)
Select
case $msg = $GUI_EVENT_CLOSE or $msg = $m_exit
Myexit()
Case $msg = $m_CRLF
$set[17]=_GUICtrlSwitchState($m_CRLF, $set[17], $GUI_CHECKED, $GUI_UNCHECKED)
Case $msg = $m_last_tab
$set[18] = _GUICtrlSwitchState($m_last_tab, $set[18], $GUI_CHECKED, $GUI_UNCHECKED)
Case $msg = $m_autocenter
$set[19] = _GUICtrlSwitchState($m_autocenter, $set[19], $GUI_CHECKED, $GUI_UNCHECKED)
If $set[19] = $GUI_CHECKED Then
$winpos = WinGetPos ($win)
WinMove ($win, '', $winpos[0]+1, $winpos[1]+1)
EndIf
Case $msg = $m_set_close
$gui_set_close = GUICreate (@ScriptName, 275, 160, -1, -1, '', $WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
Dim $gui_set_close_ctrl[8]
$gui_set_close_ctrl[0]= GUICtrlCreateCheckbox ("Закрывать окно если оно неактивно", 10, 10, 330, 25)
$gui_set_close_ctrl[1]= GUICtrlCreateGroup ("Таймер: ", 10, 35, 250, 50)
$gui_set_close_ctrl[2]= GUICtrlCreateLabel ("Min:", 20, 55, 50, 20, 0x01)
$gui_set_close_ctrl[3]= GUICtrlCreateInput ("0", 80, 50, 50, 25)
$gui_set_close_ctrl[4]= GUICtrlCreateUpdown ($gui_set_close_ctrl[3])
$gui_set_close_ctrl[5] = GUICtrlCreateLabel ("Sec:", 130, 55, 50, 20, 0x01)
$gui_set_close_ctrl[6]= GUICtrlCreateInput ("0", 190, 50, 50, 25)
$gui_set_close_ctrl[7]= GUICtrlCreateUpdown ($gui_set_close_ctrl[6])
$gui_set_close_accept = GUICtrlCreateButton ("Океюшки!", 10, 95, 250, 30)
GUICtrlSetLimit ($gui_set_close_ctrl[4], 59, 0)
GUICtrlSetLimit ($gui_set_close_ctrl[7], 59, 0)
GUICtrlSetData ($gui_set_close_ctrl[6], ($set[15]/60000 - Floor ($set[15]/60000))*60)
GUICtrlSetData ($gui_set_close_ctrl[3], Floor ($set[15]/60000))
_GUICtrlSwitchState($gui_set_close_ctrl[0], $set[16], $GUI_UNCHECKED, $GUI_CHECKED)
For $i = 1 to 7
_GUICtrlSwitchState($gui_set_close_ctrl[$i], $set[16], $GUI_DISABLE, $GUI_ENABLE)
Next
GUISetState (@SW_SHOW, $gui_set_close)
Do
$msg = GUIGetMsg ($gui_set_close)
If $msg = $gui_set_close_ctrl[0] Then
$set[16] = _GUICtrlSwitchState('', $set[16], True, False)
For $i = 1 to 7
_GUICtrlSwitchState($gui_set_close_ctrl[$i], $set[16], $GUI_DISABLE, $GUI_ENABLE)
Next
EndIf
Until $msg = $gui_set_close_accept
$min = GUICtrlRead ($gui_set_close_ctrl[3])
If StringIsDigit($min)=0 Then $min = 0
$sec = GUICtrlRead ($gui_set_close_ctrl[6])
If StringIsDigit($sec)=0 Then $sec = 0
$set[15]= $min*60000+$sec*1000
GUIDelete ($gui_set_close)
$gui_set_close=-1
EndSelect
WEnd
; -------------------------------FUNC------------------------------------------
Func ReadSettings ()
$ini = StringTrimRight (@ScriptFullPath, 4)&".ini"
$set[0] = IniRead ($ini, "Settings", "x", -1)
$set[1] = IniRead ($ini, "Settings", "y", -1)
$set[2] = IniRead ($ini, "Settings", "w", 640)
$set[3] = IniRead ($ini, "Settings", "h", 480)
$set[4] = IniRead ($ini, "Settings", "max", 0)
$set[5] = IniRead ($ini, "Settings", "font_1", 0)
$set[6] = IniRead ($ini, "Settings", "font_2", "Arial")
$set[7] = IniRead ($ini, "Settings", "font_3", 10)
$set[8] = IniRead ($ini, "Settings", "font_4", 400)
$set[9] = IniRead ($ini, "Settings", "font_5", 0)
$set[10] = IniRead ($ini, "Settings", "font_6", 0x000000)
$set[11] = IniRead ($ini, "Settings", "font_7", 0x000000)
$set[12] = IniRead ($ini, "Settings", "bgcolor", 0xFFFFFF)
$set[13] = IniRead ($ini, "Settings", "last_tab", 1)
$set[14] = IniRead ($ini, "Settings", "trans", 0)
$set[15] = IniRead ($ini, "Settings", "nonactive_close_timeout", 0)
$set[16] = IniRead ($ini, "Settings", "nonactive_close", True)
$set[17] = IniRead ($ini, "Settings", "CRLF", False)
$set[18] = IniRead ($ini, "Settings", "remember_last_tab", False)
$set[19] = IniRead ($ini, "Settings", "autocenter", True)
Return ($set)
EndFunc
Func WinSetDefaultLang($sLayoutID, $hWnd = 0)
Local Const $WM_INPUTLANGCHANGEREQUEST = 0x50
Local $aRet = DllCall("user32.dll", "long", "LoadKeyboardLayoutW", "wstr", Hex($sLayoutID, 8), "int", 0)
If Not @error And $aRet[0] Then
If $hWnd = 0 Then
$hWnd = WinGetHandle(AutoItWinGetTitle())
EndIf
DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $aRet[0])
Return 1
EndIf
Return SetError(1)
EndFunc
Func FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $sFileList, $sDelim = "|"
$sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
If Not FileExists($sPath) Then Return SetError(1, 1, "")
If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
$hSearch = FileFindFirstFile($sPath & $sFilter)
If @error Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If ($iFlag + @extended = 2) Then ContinueLoop
$sFileList &= $sDelim & $sFile
WEnd
FileClose($hSearch)
If Not $sFileList Then Return SetError(4, 4, "")
Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc
Func _GUICtrlSwitchState($ctrlid, $param, $true, $false)
If IsBool($param) Then $param=Number($param)
If not StringIsDigit($param) Then
Switch $param
Case "True", "+" ; сюда можно добавлять другие СТРОКОВЫЕ значения
$param = $false
Case "False", "-" ; сюда можно добавлять другие СТРОКОВЫЕ значения
$param = $true
Case Else
Return -1
EndSwitch
Else
Switch $param
Case 1, $GUI_CHECKED, $GUI_ENABLE, $GUI_SHOW, $GUI_FOCUS ; сюда можно добавлять другие ЧИСЛОВЫЕ значения
$param = $false
Case 0, $GUI_UNCHECKED, $GUI_DISABLE, $GUI_HIDE , $GUI_NOFOCUS ; сюда можно добавлять другие ЧИСЛОВЫЕ значения
$param = $true
Case Else
Return -1
EndSwitch
EndIf
If $ctrlid > 0 Then GUICtrlSetState ($ctrlid, $param)
Return $param
EndFunc
Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
If $set[19] = 1 Then
Local $stRect = DllStructCreate("int;int;int;int")
Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)
DllCall("User32.dll", "int", "SystemParametersInfo", "int", 0x30, "int", 0, "ptr", DllStructGetPtr($stRect), "int", 0)
Local $nRight = DllStructGetData($stRect, 3) - DllStructGetData($stWinPos, 5)
Local $nBottom = DllStructGetData($stRect, 4) - DllStructGetData($stWinPos, 6)
If $nRight/2<>DllStructGetData($stWinPos, 3) Then DllStructSetData($stWinPos, 3, $nRight/2)
If $nBottom/2<>DllStructGetData($stWinPos, 4) Then DllStructSetData($stWinPos, 4, $nBottom/2)
EndIf
EndFunc
Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
#forceref $iMsg, $wParam
If $hWnd = $win Then
Local $tMINMAXINFO = DllStructCreate("int;int;" & _
"int MaxSizeX; int MaxSizeY;" & _
"int MaxPositionX;int MaxPositionY;" & _
"int MinTrackSizeX; int MinTrackSizeY;" & _
"int MaxTrackSizeX; int MaxTrackSizeY", _
$lParam)
DllStructSetData($tMINMAXINFO, "MinTrackSizeX", 240) ; минимальные размеры окна
DllStructSetData($tMINMAXINFO, "MinTrackSizeY", 160)
EndIf
EndFunc
Func MyExit()
GUIDelete ($win)
Exit
EndFunc
Func Exit_Timer()
$set[16] = _GUICtrlSwitchState('', $set[16], False, True)
If $set[16] = True And $gui_set_close=-1 Then
$timer = TimerInit ()
Do
Sleep(250)
If WinGetState ($win) <> 7 Then ExitLoop
Until TimerDiff ($timer) >= $set[15]
If WinGetState ($win) = 7 Then Myexit()
EndIf
EndFunc