Global Const $HTML_ELEMENT_CLICK = 0x10
Global Const $HTML_ELEMENT_DBCLICK = 0x20
Global Const $HTML_ELEMENT_OVER = 0x30
Global Const $HTML_ELEMENT_OUT = 0x40
Global Const $HTML_ELEMENT_BLUR = 0x50
Global Const $HTML_ELEMENT_FOCUS = 0x60
Global $__obj_Control[1][2] = [[0, 0]], $__obj_ElementId = 0, $__obj_Error = 0, $__obj_Event = ObjEvent('AutoIt.Error', '__com_getError')
Func _GUIHtml_Create($iLeft, $iTop, $iWidth, $iHeight)
Local $oIE = ObjCreate('Shell.Explorer.2')
If (Not IsObj($oIE)) Then
Return SetError(1, 1, 0)
EndIf
$__obj_Control[0][0] += 1
ReDim $__obj_Control[$__obj_Control[0][0] + 1][UBound($__obj_Control, 2)]
$__obj_Control[$__obj_Control[0][0]][0] = $oIE
$__obj_Control[$__obj_Control[0][0]][1] = GUICtrlCreateObj($oIE, $iLeft, $iTop, $iWidth, $iHeight)
$oIE.Navigate('about:blank')
$oIE.Document.Write(__com_HtmlPage())
$oIE.Document.Close()
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 2, 0)
EndIf
Return $oIE
EndFunc
Func _GUIHtml_HeadInsertScriptFile(ByRef $oObj, $sScriptFile)
If (Not IsObj($oObj)) Then
Return SetError(1, 1, 0)
ElseIf (Not IsString($sScriptFile)) Then
Return SetError(1, 2, 0)
EndIf
Local $oHead = $oObj.document.all.tags('head').Item(0)
Local $oScript = $oObj.document.createElement('script')
With $oScript
.defer = True
.language = "jscript"
.type = "text/javascript"
.src = $sScriptFile
EndWith
$oHead.appendChild($oScript)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 3, 0)
EndIf
Return SetError(0, 0, 1)
EndFunc
Func _GUIHtml_HeadInsertCssFile(ByRef $oObj, $sCSSFile)
If (Not IsObj($oObj)) Then
Return SetError(1, 1, 0)
ElseIf (Not IsString($sCSSFile)) Then
Return SetError(1, 2, 0)
EndIf
Local $oHead = $oObj.document.all.tags('head').Item(0)
Local $oCSS = $oObj.document.createElement('link')
With $oCSS
.type = 'text/css'
.rel = 'stylesheet'
.href = $sCSSFile
.media = 'screen'
EndWith
$oHead.appendChild($oCSS)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(-2, 0, 0)
EndIf
Return SetError(0, 0, 1)
EndFunc
Func _GUIHtml_JScriptExec($oObj, $sCod)
If (Not IsObj($oObj)) Then
Return SetError(1, 1, 0)
ElseIf (Not IsString($sCod)) Then
Return SetError(1, 2, 0)
EndIf
$oObj.document.parentWindow.execScript($sCod)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 3, 0)
EndIf
Return SetError(0, 0, 1)
EndFunc
Func _GUIHtml_SetBorder($hObj, $iSize, $iColor = 0xFFFFFF)
$hObj.document.body.style.border = $iSize & 'px solid #' & Hex($iColor, 6)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetBkColor($hObj, $iColor)
$hObj.document.bgcolor = '#' & Hex($iColor, 6)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetGradient($hObj, $iStartColor, $iEndColor, $iType = 0)
$hObj.document.body.style.filter = 'progid:DXImageTransform.Microsoft.gradient(startColorstr="#' & Hex($iStartColor, 6) & '", endColorstr="#' & Hex($iEndColor, 6) & '", gradientType="' & $iType & '")'
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetCursor($hObj, $sCursor)
Switch $sCursor
Case 0
$sCursor = 'default'
Case 1
$sCursor = 'crosshair'
Case 2
$sCursor = 'help'
Case 3
$sCursor = 'move'
Case 4
$sCursor = 'pointer'
Case 5
$sCursor = 'progress'
Case 6
$sCursor = 'text'
Case 7
$sCursor = 'wait'
Case 8
$sCursor = 'n-resize'
Case 9
$sCursor = 'ne-resize'
Case 10
$sCursor = 'e-resize'
Case 11
$sCursor = 'se-resize'
Case 12
$sCursor = 's-resize'
Case 13
$sCursor = 'sw-resize'
Case 14
$sCursor = 'w-resize'
Case 15
$sCursor = 'nw-resize'
Case Else
$sCursor = 'url(' & $sCursor & ')'
EndSwitch
$hObj.document.body.style.cursor = $sCursor
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetScroll($hObj, $iFlag = True)
$hObj.document.body.scroll = __if($iFlag, 'yes', 'no')
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetContextMenu($hObj, $iState = True)
Local $oScript = $hObj.document.CreateElement('script')
With $oScript
.Defer = True
.Language = 'jscript'
.Type = 'text/javascript'
.HtmlFor = 'document'
.Event = 'oncontextmenu'
.Text = 'return ' & __if($iState, 'true', 'false')
EndWith
$hObj.document.all.tags('head').Item(0).AppendChild($oScript)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 2, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_CreateImage($hObj, $sImage, $iLeft, $iTop, $iWidth, $iHeight, $iBlock = 0)
$__obj_ElementId += 1
Local $tIMG = '<img src="' & $sImage & '" id="' & $__obj_ElementId & '" style="position: absolute; left: ' & $iLeft & 'px; top:' & $iTop & 'px; width: ' & $iWidth & 'px; height: ' & $iHeight & 'px;" ' & _
'onclick="document.title=' & BitOR($HTML_ELEMENT_CLICK, $__obj_ElementId) & '" ' & _
'ondblclick="document.title=' & BitOR($HTML_ELEMENT_DBCLICK, $__obj_ElementId) & '" ' & _
'onmouseover="document.title=' & BitOR($HTML_ELEMENT_OVER, $__obj_ElementId) & '" ' & _
'onmouseout="document.title=' & BitOR($HTML_ELEMENT_OUT, $__obj_ElementId) & '" ' & _
'onblur="document.title=' & BitOR($HTML_ELEMENT_BLUR, $__obj_ElementId) & '" ' & _
'onfocus="document.title=' & BitOR($HTML_ELEMENT_FOCUS, $__obj_ElementId) & '"></img>'
__block($hObj, $iBlock, __Inner($hObj, $iBlock) & $tIMG)
If @error Then
$__obj_ElementId -= 1
Return SetError(1, 1, 0)
EndIf
Return $__obj_ElementId
EndFunc
Func _GUIHtml_CreateDiv($hObj, $iLeft, $iTop, $iWidth, $iHeight, $iBlock = 0)
$__obj_ElementId += 1
Local $tDIV = '<div id="' & $__obj_ElementId & '" style="position: absolute; left: ' & $iLeft & 'px; top:' & $iTop & 'px; width: ' & $iWidth & 'px; height: ' & $iHeight & 'px;"></div>'
__block($hObj, $iBlock, __Inner($hObj, $iBlock) & $tDIV)
If @error Then
$__obj_ElementId -= 1
Return SetError(1, 1, 0)
EndIf
Return $__obj_ElementId
EndFunc
Func _GUIHtml_SetElementShadow($hObj, $Id, $iSize, $iColor)
$hObj.document.getElementById($Id).style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=#' & Hex($iColor, 6) & ', direction=25, strength=' & $iSize & ')' & _
'progid:DXImageTransform.Microsoft.Shadow(color=#' & Hex($iColor, 6) & ', direction=125, strength=' & $iSize & ')' & _
'progid:DXImageTransform.Microsoft.Shadow(color=#' & Hex($iColor, 6) & ', direction=225, strength=' & $iSize & ')' & _
'progid:DXImageTransform.Microsoft.Shadow(color=#' & Hex($iColor, 6) & ', direction=325, strength=' & $iSize & ')'
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetElementAlpha($hObj, $Id, $iAlpha)
$hObj.document.getElementById($Id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' & $iAlpha & ')'
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetElementCursor($hObj, $Id, $sCursor)
Switch $sCursor
Case 0
$sCursor = 'default'
Case 1
$sCursor = 'crosshair'
Case 2
$sCursor = 'help'
Case 3
$sCursor = 'move'
Case 4
$sCursor = 'pointer'
Case 5
$sCursor = 'progress'
Case 6
$sCursor = 'text'
Case 7
$sCursor = 'wait'
Case 8
$sCursor = 'n-resize'
Case 9
$sCursor = 'ne-resize'
Case 10
$sCursor = 'e-resize'
Case 11
$sCursor = 'se-resize'
Case 12
$sCursor = 's-resize'
Case 13
$sCursor = 'sw-resize'
Case 14
$sCursor = 'w-resize'
Case 15
$sCursor = 'nw-resize'
Case Else
$sCursor = 'url(' & $sCursor & ')'
EndSwitch
$hObj.document.getElementById($Id).style.cursor = $sCursor
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_SetElementBgColor($hObj, $Id, $iColor)
$hObj.document.getElementById($Id).style.backgroundColor = '#' & Hex($iColor, 6)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc
Func _GUIHtml_Event($hObj)
$iEvent = $hObj.document.title
If $__obj_Error Then
$__obj_Error = 0
Return SetError(-1, $hObj.document.title = -1, 0)
EndIf
Return SetError(0, $hObj.document.title = -1, $iEvent)
EndFunc
Func __event_Click($Id)
Return BitOR($HTML_ELEMENT_CLICK, $Id)
EndFunc
Func __event_DbClick($Id)
Return BitOR($HTML_ELEMENT_DBCLICK, $Id)
EndFunc
Func __event_Over($Id)
Return BitOR($HTML_ELEMENT_OVER, $Id)
EndFunc
Func __event_Out($Id)
Return BitOR($HTML_ELEMENT_OUT, $Id)
EndFunc
Func __event_Blur($Id)
Return BitOR($HTML_ELEMENT_BLUR, $Id)
EndFunc
Func __event_Focus($Id)
Return BitOR($HTML_ELEMENT_FOCUS, $Id)
EndFunc
Func __com_HtmlPage()
Local $sHtml = ''
$sHtml &= '<html>' & @CRLF
$sHtml &= ' <head>' & @CRLF
$sHtml &= ' <META Http-equiv="MSThemeCompatible" content="yes">' & @CRLF
$sHtml &= ' <title>-1</title>' & @CRLF
$sHtml &= ' <style type="text/css">' & @CRLF
$sHtml &= ' body {' & @CRLF
$sHtml &= ' border: 0px;' & @CRLF
$sHtml &= ' padding: 0px;' & @CRLF
$sHtml &= ' margin: 0px;' & @CRLF
$sHtml &= ' }' & @CRLF
$sHtml &= ' </style>' & @CRLF
$sHtml &= ' </head>' & @CRLF
$sHtml &= ' <body scroll="no">' & @CRLF
$sHtml &= ' </body>' & @CRLF
$sHtml &= '</html>'
Return $sHtml
EndFunc
Func __com_getError()
$__obj_Error = $__obj_Event.Number
EndFunc
Func __if($iCondition, $sTrue, $sFalse)
If $iCondition Then
Return $sTrue
Else
Return $sFalse
EndIf
EndFunc
Func __Inner($hObj, $iBlock)
Local $sHtml
If $iBlock Then
$sHtml = $hObj.document.getElementById($iBlock).InnerHTML
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Else
$sHtml = $hObj.document.body.InnerHTML
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
EndIf
If ($sHtml == 0) Then
Return ''
EndIf
Return $sHtml
EndFunc
Func __block($hObj, $iBlock, $sValue)
If $iBlock Then
$hObj.document.getElementById($iBlock).InnerHTML = $sValue
Else
$hObj.document.body.InnerHTML = $sValue
EndIf
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
Return 1
EndFunc