#cs ----------------------------------------------------------------------------
File Ver .....: 03.04.15
Engine Ver ...: 2.0.0
AutoIt Ver ...: 3.3.12.0
Author .......: Firex
#ce ----------------------------------------------------------------------------
; FEngin: UI []
Global _ ;[0]: [0] - Count, [1] -
$__FE_UI_aTrig[99][7] = [[0]], _
$__FE_UI_CbMouse, _
$__FE_UI_hMouseHook, _
$__FE_UI_InputCount
Global Const $tagMSLLHOOK = 'long X; long Y; dword mouseData; dword flags; dword time; ulong_ptr dwExtraInfo'
; ##############################################################
#Include "WinAPI.au3"
; #FUNCTION# ;===============================================================================
; Name...........: _FEng_UI_TrigAdd
; Description ...:
; Remarks .......:
; ;==========================================================================================
Func _FEng_UI_TrigAdd($x, $y, $w, $h, $CallBack, $fState = 0, $vExtra = 0)
Local $Id, $Num = $__FE_UI_aTrig[0][0]
; ---
If $Num Then
For $Id = $Num To 1 Step -1
If $__FE_UI_aTrig[$Id][0] == '' Then _
ExitLoop
Next
EndIf
If Not $Id Then
$Id = $Num + 1
If $Id > ( UBound( $__FE_UI_aTrig ) - 1 ) Then _
Return 0
$__FE_UI_aTrig[0][0] = $Id
EndIf
$__FE_UI_aTrig[$Id][0] = Int( $fState )
_FEng_UI_TrigPosSet($Id, $x, $y, $w, $h)
$__FE_UI_aTrig[$Id][5] = $CallBack
$__FE_UI_aTrig[$Id][6] = $vExtra
; ---
Return $Id
EndFunc
; #FUNCTION# ;===============================================================================
; Name...........: _FEng_UI_TrigEnable
; Description ...:
; Remarks .......:
; ;==========================================================================================
Func _FEng_UI_TrigEnable($Id, $fEnable = 1)
If $Id > 0 Then
$__FE_UI_aTrig[$Id][0] = Int( $fEnable )
EndIf
EndFunc
; #FUNCTION# ;===============================================================================
; Name...........: _FEng_UI_TrigPosSet
; Description ...:
; Remarks .......:
; ;==========================================================================================
Func _FEng_UI_TrigPosSet($Id, $x, $y, $w , $h)
If $Id > 0 Then
$__FE_UI_aTrig[$Id][1] = $x
$__FE_UI_aTrig[$Id][2] = $y
$__FE_UI_aTrig[$Id][3] = $x + $w
$__FE_UI_aTrig[$Id][4] = $y + $h
EndIf
EndFunc
; #FUNCTION# ;===============================================================================
; Name...........: _FEng_UI_TrigDelete
; Description ...:
; Remarks .......:
; ;==========================================================================================
Func _FEng_UI_TrigDelete($Id)
If $Id > 0 Then
$__FE_UI_aTrig[$Id][0] = ''
$__FE_UI_aTrig[$Id][6] = 0
EndIf
EndFunc
; #FUNCTION# ;===============================================================================
; Name...........: _FEng_UI_AllowInput
; Description ...:
; Remarks .......:
; ;==========================================================================================
Func _FEng_UI_AllowInput($fState = 1)
$__FE_UI_InputCount += ( $fState ) ? 1 : -1
If $__FE_UI_InputCount = 1 Then
Local $hModule
; ---
$hModule = _WinAPI_GetModuleHandle(0)
$__FE_UI_hMouseHook = _WinAPI_SetWindowsHookEx( _
$WH_MOUSE_LL, _
DllCallbackGetPtr( $__FE_UI_CbMouse ), _
$hModule _
)
Return ( $__FE_UI_hMouseHook <> 0 )
ElseIf $__FE_UI_InputCount < 1 Then
_WinAPI_UnhookWindowsHookEx( $__FE_UI_hMouseHook )
$__FE_UI_hMouseHook = 0
EndIf
EndFunc
; ==============================================================
; ### Internals
; ==============================================================
Func __FEng_UI_Startup()
$__FE_UI_CbMouse = DllCallbackRegister("__UI_MouseHandler", "int", "int;ptr;ptr")
EndFunc
Func __FEng_UI_Shutdown()
$__FE_UI_InputCount = 0
If $__FE_UI_hMouseHook Then _
_FEng_UI_AllowInput(0)
DllCallbackFree( $__FE_UI_CbMouse )
EndFunc
Func __UI_MouseHandler($iCode, $wParam, $lParam)
Local $Ret = _WinAPI_CallNextHookEx( $__FE_UI_hMouseHook, $iCode, $wParam, $lParam )
; -
If $iCode = 0 Then ;HC_ACTION
Local $tMSLLHOOK = DllStructCreate( $tagMSLLHOOK, $lParam ) ;Not completed...
; ---
For $Id = 1 To $__FE_UI_aTrig[0][0] Step 1
If $__FE_UI_aTrig[$Id][0] And _
$tMSLLHOOK.X >= $__FE_UI_aTrig[$Id][1] And $tMSLLHOOK.X <= $__FE_UI_aTrig[$Id][3] And _
$tMSLLHOOK.Y >= $__FE_UI_aTrig[$Id][2] And $tMSLLHOOK.Y <= $__FE_UI_aTrig[$Id][4] _
Then
If $__FE_UI_aTrig[$Id][5] Then _
Return Call( $__FE_UI_aTrig[$Id][5], _
$Id, _
$wParam, _
$tMSLLHOOK, _
$__FE_UI_aTrig[$Id][6] _ ;Extra info
)
; *
ExitLoop
EndIf
Next
EndIf
; ---
Return $Ret
EndFunc