Maza Faka
Спасибо за ссылки. Все вроде по ним понятно. Однако чего-то окончательный вариант написать не могу. вот что есть пока:
Код: #Include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MouseSetOnEvent_UDF.au3>
#include <Array.au3>
$MainColor = 0x00FF00 ; зеленый
$FailureColor = 0x0000FF ; красный
$SuccessColor = 0xFFBA00 ; голубой
$BackgroundColor = 0x000000 ; черный
$BeginColor = 0xFF4DFF ; фиолетовый
$TimerColor = 0x00FEFE ; желтый
$TABS = @TAB & @TAB
$GUI = GUICreate("Лог",700,600)
$hRichText = RichText_Create($GUI, 0, 0, 700, 500)
RichText_BkColor ($hRichText, $BackgroundColor)
$Button = GUICtrlCreateButton ("Скопировать лог в буфер обмена", 250, 520, 200, 51)
ControlFocus ($GUI, '',$Button)
GUICtrlSetState (-1, $GUI_DISABLE)
GUISetState()
_Archive_Process()
$Count = 0
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button
MsgBox(0, "", "Нажата кнопка")
Case $GUI_EVENT_PRIMARYDOWN
$Count +=1
ConsoleWrite ("нажата левая кнопка " & $Count & @CRLF)
If ControlGetFocus($GUI, $hRichText) <> "" Then
ConsoleWrite ("Edit Is Focused" & @CRLF)
ControlFocus ($GUI, '',$Button)
Else
ConsoleWrite ("Edit IsNOT Focused" & @CRLF)
EndIf
Case $GUI_EVENT_SECONDARYDOWN
$Count +=1
ConsoleWrite ("нажата правая кнопка " & $Count & @CRLF)
If ControlGetFocus($GUI, $hRichText) <> "" Then
ConsoleWrite ("Edit Is Focused" & @CRLF)
ControlFocus ($GUI, '',$Button)
Else
ConsoleWrite ("Edit IsNOT Focused" & @CRLF)
EndIf
EndSwitch
WEnd
Func _Archive_Process ()
For $q = 1 to 200
_IsHoveredControl ($GUI, '', $hRichText)
RichText_SetFont($hRichText, "Tahoma")
RichText_SetFontSize ($hRichText, 10)
$begin = TimerInit ()
RichText_SetColor($hRichText, $BeginColor)
RichText_AppendText($hRichText, $q & " " & @MDAY & "." & @MON & "." & @YEAR & " " & " " & @HOUR & ":" & @MIN& ":" & @SEC & $TABS)
ControlFocus ($GUI, '',$Button)
RichText_SetColor($hRichText, $MainColor)
RichText_AppendText($hRichText, " Архивирую Dreamers.avi" & $TABS)
ControlFocus ($GUI, '',$Button)
Sleep (1)
RichText_SetBold($hRichText, True)
If Mod ($q, 2) = 0 Then
RichText_SetColor($hRichText, $SuccessColor)
$dif = TimerDiff($begin)
RichText_AppendText($hRichText, "Успешно!" & $TABS)
ControlFocus ($GUI, '',$Button)
Else
RichText_SetColor($hRichText, $FailureColor)
$dif = TimerDiff($begin)
RichText_AppendText($hRichText, "Ошибка!" & $TABS)
ControlFocus ($GUI, '',$Button)
EndIf
RichText_SetColor($hRichText, $TimerColor)
RichText_SetBold($hRichText, False)
RichText_AppendText($hRichText, "(" & Round ($dif/1000, 2) & " сек.)" & @CRLF)
ControlFocus ($GUI, '',$Button)
Next
GUICtrlSetState ($Button, $GUI_ENABLE)
ControlFocus ($GUI, '',$Button)
EndFunc ;==> _Archive_Process
Func _IsHoveredControl ($hWnd, $text, $CtrlID)
Local $iRet = False
Local $aWin_Pos = WinGetPos($hWnd)
; _ArrayDisplay ($aWin_Pos, "координаты окна")
Local $clientSize = WinGetClientSize($hWnd)
Local $winBorder = ($aWin_Pos[2] - $clientSize[0]) / 2
Local $titleBarHeight = $aWin_Pos[3] - $clientSize[1] - $winBorder
Local $aControl_Pos = ControlGetPos ($hWnd, '', $CtrlID)
_ArrayDisplay ($aControl_Pos, "координаты контрола")
Local $aMouse_Pos = MouseGetPos()
; $controlPosAbsX = $aWin_Pos[0] + $winBorder + $aControl_Pos[0]
; $controlPosAbsY = $aWin_Pos[1] + $titleBarHeight + $aControl_Pos[1]
; $controlPosAbsX = $aWin_Pos[0] + $winBorder + 0
; $controlPosAbsY = $aWin_Pos[1] + $titleBarHeight + 0
; Local $aMouse_Pos = MouseGetPos()
; If $aMouse_Pos[0] >= $aWin_Pos[0] And $aMouse_Pos[0] <= ($aWin_Pos[0] + $aWin_Pos[2]) And _
; $aMouse_Pos[1] >= $aWin_Pos[1] And $aMouse_Pos[1] <= ($aWin_Pos[1] + $aWin_Pos[3]) Then $iRet = True
; Local $aRet = DllCall("user32.dll", "int", "WindowFromPoint", _
; "long", $aMouse_Pos[0], _
; "long", $aMouse_Pos[1])
; If Not WinActive($hWnd) Or ($aRet[0] <> $hWnd And Not $iRet) Then $iRet = False
; Return $iRet
EndFunc ;==> _IsHoveredControl
Спасибо за ссылки. Все вроде по ним понятно. Однако чего-то окончательный вариант написать не могу. вот что есть пока:
Код: #Include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MouseSetOnEvent_UDF.au3>
#include <Array.au3>
$MainColor = 0x00FF00 ; зеленый
$FailureColor = 0x0000FF ; красный
$SuccessColor = 0xFFBA00 ; голубой
$BackgroundColor = 0x000000 ; черный
$BeginColor = 0xFF4DFF ; фиолетовый
$TimerColor = 0x00FEFE ; желтый
$TABS = @TAB & @TAB
$GUI = GUICreate("Лог",700,600)
$hRichText = RichText_Create($GUI, 0, 0, 700, 500)
RichText_BkColor ($hRichText, $BackgroundColor)
$Button = GUICtrlCreateButton ("Скопировать лог в буфер обмена", 250, 520, 200, 51)
ControlFocus ($GUI, '',$Button)
GUICtrlSetState (-1, $GUI_DISABLE)
GUISetState()
_Archive_Process()
$Count = 0
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button
MsgBox(0, "", "Нажата кнопка")
Case $GUI_EVENT_PRIMARYDOWN
$Count +=1
ConsoleWrite ("нажата левая кнопка " & $Count & @CRLF)
If ControlGetFocus($GUI, $hRichText) <> "" Then
ConsoleWrite ("Edit Is Focused" & @CRLF)
ControlFocus ($GUI, '',$Button)
Else
ConsoleWrite ("Edit IsNOT Focused" & @CRLF)
EndIf
Case $GUI_EVENT_SECONDARYDOWN
$Count +=1
ConsoleWrite ("нажата правая кнопка " & $Count & @CRLF)
If ControlGetFocus($GUI, $hRichText) <> "" Then
ConsoleWrite ("Edit Is Focused" & @CRLF)
ControlFocus ($GUI, '',$Button)
Else
ConsoleWrite ("Edit IsNOT Focused" & @CRLF)
EndIf
EndSwitch
WEnd
Func _Archive_Process ()
For $q = 1 to 200
_IsHoveredControl ($GUI, '', $hRichText)
RichText_SetFont($hRichText, "Tahoma")
RichText_SetFontSize ($hRichText, 10)
$begin = TimerInit ()
RichText_SetColor($hRichText, $BeginColor)
RichText_AppendText($hRichText, $q & " " & @MDAY & "." & @MON & "." & @YEAR & " " & " " & @HOUR & ":" & @MIN& ":" & @SEC & $TABS)
ControlFocus ($GUI, '',$Button)
RichText_SetColor($hRichText, $MainColor)
RichText_AppendText($hRichText, " Архивирую Dreamers.avi" & $TABS)
ControlFocus ($GUI, '',$Button)
Sleep (1)
RichText_SetBold($hRichText, True)
If Mod ($q, 2) = 0 Then
RichText_SetColor($hRichText, $SuccessColor)
$dif = TimerDiff($begin)
RichText_AppendText($hRichText, "Успешно!" & $TABS)
ControlFocus ($GUI, '',$Button)
Else
RichText_SetColor($hRichText, $FailureColor)
$dif = TimerDiff($begin)
RichText_AppendText($hRichText, "Ошибка!" & $TABS)
ControlFocus ($GUI, '',$Button)
EndIf
RichText_SetColor($hRichText, $TimerColor)
RichText_SetBold($hRichText, False)
RichText_AppendText($hRichText, "(" & Round ($dif/1000, 2) & " сек.)" & @CRLF)
ControlFocus ($GUI, '',$Button)
Next
GUICtrlSetState ($Button, $GUI_ENABLE)
ControlFocus ($GUI, '',$Button)
EndFunc ;==> _Archive_Process
Func _IsHoveredControl ($hWnd, $text, $CtrlID)
Local $iRet = False
Local $aWin_Pos = WinGetPos($hWnd)
; _ArrayDisplay ($aWin_Pos, "координаты окна")
Local $clientSize = WinGetClientSize($hWnd)
Local $winBorder = ($aWin_Pos[2] - $clientSize[0]) / 2
Local $titleBarHeight = $aWin_Pos[3] - $clientSize[1] - $winBorder
Local $aControl_Pos = ControlGetPos ($hWnd, '', $CtrlID)
_ArrayDisplay ($aControl_Pos, "координаты контрола")
Local $aMouse_Pos = MouseGetPos()
; $controlPosAbsX = $aWin_Pos[0] + $winBorder + $aControl_Pos[0]
; $controlPosAbsY = $aWin_Pos[1] + $titleBarHeight + $aControl_Pos[1]
; $controlPosAbsX = $aWin_Pos[0] + $winBorder + 0
; $controlPosAbsY = $aWin_Pos[1] + $titleBarHeight + 0
; Local $aMouse_Pos = MouseGetPos()
; If $aMouse_Pos[0] >= $aWin_Pos[0] And $aMouse_Pos[0] <= ($aWin_Pos[0] + $aWin_Pos[2]) And _
; $aMouse_Pos[1] >= $aWin_Pos[1] And $aMouse_Pos[1] <= ($aWin_Pos[1] + $aWin_Pos[3]) Then $iRet = True
; Local $aRet = DllCall("user32.dll", "int", "WindowFromPoint", _
; "long", $aMouse_Pos[0], _
; "long", $aMouse_Pos[1])
; If Not WinActive($hWnd) Or ($aRet[0] <> $hWnd And Not $iRet) Then $iRet = False
; Return $iRet
EndFunc ;==> _IsHoveredControl