#NoTrayIcon #region: - Include #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #endregion #region: - Option Opt('GUIOnEventMode', 1) Opt('MustDeclareVars', 1) Opt('PixelCoordMode', 2) Opt('MouseCoordMode', 2) Opt('TrayIconDebug', 0) Opt('TrayIconHide', 1) Opt('TrayMenuMode', 1) Opt('TrayOnEventMode', 1) #endregion #region: - Global: Название и версия программы, ProID Global $sProName, $sProVer, $sProNameVer, $sProIDText, $sProIDClass1, $sProIDClass2 $sProName = 'Game Script' $sProVer = 'v1.0 Betta' $sProNameVer = $sProName & ' ' & $sProVer $sProIDText = $sProNameVer & ' [ID] ' & $sProNameVer $sProIDClass1 = '[CLASS:Static; INSTANCE:1]' $sProIDClass2 = '[CLASS:Static; INSTANCE:2]' #endregion #region: - Одна копия программы If ControlGetText($sProName, $sProIDText, $sProIDClass1) == $sProIDText Then While 1 If ControlGetText($sProName, $sProIDText, $sProIDClass2) == '' Then ExitLoop WEnd ControlSetText($sProName, $sProIDText, $sProIDClass2, 'show tray tip already run') Exit EndIf #endregion #region: - Global Global $hTrayOffOn Global $hWinMain, $hWinMainWidth, $hWinMainHeight, $hWhatDo, $sWinMainState, $iProHotKeyState Global $hIcon, $hOffOn, $iOn, $iTimerTime, $hTimerTime $hWinMainWidth = 200 $hWinMainHeight = 120 $iOn = 0 $iTimerTime = 15 Global $sPixelSerchColor = 0xFFFFFF #endregion #region: Tray TraySetClick(8) TraySetOnEvent(-7, '_Off_On') $hTrayOffOn = TrayCreateItem('Зпустить') TrayItemSetOnEvent(-1, '_Off_On') TrayCreateItem('Настройки') TrayItemSetOnEvent(-1, '_Pro_Show') TrayCreateItem('Закрыть') TrayItemSetOnEvent(-1, '_Pro_Exit') #endregion #region: Главное окно $hWinMain = GUICreate($sProNameVer, $hWinMainWidth, $hWinMainHeight, -1, -1, $WS_CAPTION+$WS_SYSMENU) GUISetIcon('shell32.dll', -138) GUISetBkColor(0xffffff) GUISetOnEvent($GUI_EVENT_CLOSE, '_Pro_Hide_Show') GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST') GUICtrlCreateLabel($sProIDText, 0, -100, 300, 20) GUICtrlSetState(-1, $GUI_HIDE) $hWhatDo = GUICtrlCreateLabel('', 0, -100, 300, 20) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateGroup('', 5, 5, $hWinMainWidth-10, $hWinMainHeight-10) $hOffOn = GUICtrlCreateButton('Запустить', 10, 20, 140, 25) GUICtrlSetFont(-1, 9, 700) GUICtrlSetTip(-1, 'ALT+F1 Остновить/Запустить') GUICtrlSetOnEvent(-1, '_Off_On') $hIcon = GUICtrlCreateIcon('shell32.dll', -138, 10+140+10, 25, 16, 16) GUICtrlSetOnEvent(-1, '_Off_On') GUICtrlCreateLabel('Время таймера:', 11, 52+3, 85, 18, -1, $GUI_WS_EX_PARENTDRAG) $hTimerTime = GUICtrlCreateCombo('', 100, 52-4+3, 88, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25', $iTimerTime) GUICtrlSetOnEvent(-1, '_Select_Timer_Time') GUICtrlCreateButton('Закрыть', 10, 73+3*2, 89, 25) GUICtrlSetTip(-1, 'ALT+ESC Закрыть') GUICtrlSetOnEvent(-1, '_Pro_Exit') GUICtrlCreateButton('Свернуть', 10+89+2, 73+3*2, 89, 25) GUICtrlSetTip(-1, 'ALT+F2 Свернуть/Показать') GUICtrlSetOnEvent(-1, '_Pro_Exit') #endregion #region: - После создания всех GUI HotKeySet('!{ESC}', '_Pro_Exit') HotKeySet('!{F1}', '_Off_On') HotKeySet('!{F2}', '_Pro_Hide_Show') ;~ _Pro_Show() _Pro_Hide() TraySetIcon('shell32.dll', -138) TraySetState(1) #endregion #region: - Sleep, Exit While 1 Sleep(10) _What_Do() _Pro_HotKey() WEnd Func _Pro_Exit() Exit EndFunc Func OnAutoItExit() HotKeySet('{Esc}') EndFunc Func _Pro_Hide() $sWinMainState = 'hide' GUISetState(@SW_HIDE, $hWinMain) EndFunc Func _Pro_Show() $sWinMainState = 'show' GUISetState(@SW_SHOW, $hWinMain) GUISetState(@SW_RESTORE, $hWinMain) EndFunc Func _Pro_Hide_Show() If WinActive($hWinMain) == 1 Then _Pro_Hide() Else _Pro_Show() EndIf EndFunc Func _Pro_Hide_Show_OneClick() If $sWinMainState == 'show' Then _Pro_Hide() Else _Pro_Show() EndIf EndFunc Func _Pro_HotKey() If WinActive($hWinMain) == 1 Then If $iProHotKeyState <> 1 Then $iProHotKeyState = 1 HotKeySet('{Esc}', '_Pro_Hide_Show') EndIf Else If $iProHotKeyState <> 0 Then $iProHotKeyState = 0 HotKeySet('!{Esc}') HotKeySet('{Esc}') EndIf EndIf EndFunc #endregion Func _What_Do() Switch GUICtrlRead($hWhatDo) Case 'show' GUICtrlSetData($hWhatDo, '') _Pro_Show() Case 'show tray tip already run' GUICtrlSetData($hWhatDo, '') TrayTip($sProName, 'Приложение запущено', 4, 1) EndSwitch EndFunc Func _Off_On() If $iOn == 0 Then $iOn = 1 If $iOn = 1 Then AdlibEnable('_Serch_Pixel_And_Click', $iTimerTime*1000*60) TraySetIcon('shell32.dll', -138+28) TrayItemSetText($hTrayOffOn, 'Остановить') GUICtrlSetData($hOffOn, 'Остановить') GUICtrlSetImage($hIcon, 'shell32.dll', -138+28) Else $iOn = 0 AdlibDisable() TraySetIcon('shell32.dll', -138) TrayItemSetText($hTrayOffOn, 'Запустить') GUICtrlSetData($hOffOn, 'Запустить') GUICtrlSetImage($hIcon, 'shell32.dll', -138) EndIf EndFunc Func _Serch_Pixel_And_Click() ;~ MsgBox(64, 'Внимени', 'Timer time out') ;~ Return Local $aCoords If WinExists('текст', '') Then WinActivate('текст', '') WinWaitActive('текст', '', 180) $aCoords = PixelSearch( 291, 212, 983, 770, $sPixelSerchColor, 0 ) If Not @error Then MouseClick('left', $aCoords[0]+70, $aCoords[1], 1) EndIf EndFunc Func _Select_Timer_Time() AdlibDisable() $iTimerTime = GUICtrlRead($hTimerTime) If $iOn = 1 Then AdlibEnable('_Serch_Pixel_And_Click', $iTimerTime*1000*60) EndFunc Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam) Local $iProc = DllCall('user32.dll', 'int', 'DefWindowProc', 'hwnd', $hWnd, 'int', $Msg, 'wparam', $wParam, 'lparam', $lParam) If $iProc[0] = $HTCLIENT Then Return $HTCAPTION Return $GUI_RUNDEFMSG EndFunc |