Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/11/2015 in all areas

  1. SciTE 3.2.5.99 has been updated.
    2 points
  2. trancexx

    MailSlot

    This way of communication between processes very much resemble to the communication we do with our mail accounts. I would guess (smartly, no doubt) that was the key factor used for naming the functions when they were created. Information about mailslots can be found on microsoft's site, link. Summary could be that datagrams are used for communication and it's one-way and asynchronous. Attached zip file contains MailSlot.au3, AutoIt's implementation of these functions. Also there would be two scripts in there MailSlot_Sender.au3 and MailSlot_Reciever.au3. Both scripts are demos of the mailslot mechanism. Start both and use former to send mails to latter. Examples are basic and should show what's this about. MailSlot.zip Available functions are alphabetically: _MailSlotCheckForNextMessage_MailSlotClose_MailSlotCreate_MailSlotGetMessageCount_MailSlotGetTimeout_MailSlotSetTimeout_MailSlotRead_MailSlotWriteedit: New attachment. _MailSlotGetTimeout() function added to MailSlot.au3.
    1 point
  3. GMib

    HtmLayout DLL UDF !

    I finally managed to run HtmLayout.dll, HtmLayout is a fast, lightweight and embeddable HTML/CSS renderer and layout manager component. Download dll here : http://www.terrainformatica.com/htmlayout/HTMLayoutDLL.zip #include <WinAPI.au3> #include <WindowsConstants.au3> #include <HtmLayout Constants.au3> #include-once Global $aHLelementsfound = 0 Global $HtmLayoutdll = 0 Global $HtmLayoutRef = 0 Global $HandleWindowsAttachEvent = 0 Global $HtmLayoutEvHandler = 0 Global $aHLDOM_error[7] $aHLDOM_error[0] = "function completed successfully" $aHLDOM_error[1] = "invalid HWND" $aHLDOM_error[2] = "invalid HELEMENT" $aHLDOM_error[3] = "attempt to use HELEMENT which is not marked by HTMLayout_UseElement()" $aHLDOM_error[4] = "parameter is invalid, e.g. pointer is null" $aHLDOM_error[5] = "operation failed, e.g. invalid html in HTMLayoutSetElementHtml()" $aHLDOM_error[6] = "Dllcall error" ; #FUNCTION# ==================================================================================================== ; Name...........: _HLStartup ; Description....: Initialize HtmLayout ; Syntax.........: _HLStartup($dll = "HtmLayout.dll") ; Parameters.....: $dll - Path to HtmLayout DLL [Optional] ; ; Return values..: Success - 1 ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _HLStartup($dll = "HtmLayout.dll") $HtmLayoutRef += 1 If $HtmLayoutRef > 1 Then Return 1 $HtmLayoutdll = DllOpen($dll) If $HtmLayoutdll = -1 Then Return SetError(1, 0, 0) Return 1 EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _HLCreateGui ; Description....: Create HtmLayout Windows ; Syntax.........: _HLCreateGui($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50) ; Parameters.....: $ParentGui - Handle of parent Gui ; $x - [Optional] ; $y - [Optional] ; $w - [Optional] ; $h - [Optional] ; ; Return values..: Success - HTMLayout window handle. ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _HLCreateGui($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50) $result = DllCall($HtmLayoutdll, "wstr", "HTMLayoutClassNameW") If @error Then Return 0 $ClassName = $result[0] $HtmLayoutHwnd = _WinAPI_CreateWindowEx(0, $ClassName, "", BitOR($WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN), $x, $y, $w, $h, $ParentGui) Return $HtmLayoutHwnd EndFunc ;==>_HLCreateGui ; #FUNCTION# ==================================================================================================== ; Name...........: _HLLoadFile ; Description....: Load HTML file. ; Syntax.........: _HLLoadFile($HLHwnd, $file) ; Parameters.....: $HLHwnd - HTMLayout window handle. ; $file - File name of an HTML file. ; ; Return values..: Success - 1 ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _HLLoadFile($HLHwnd, $file) $result = DllCall($HtmLayoutdll, "BOOL", "HTMLayoutLoadFile", "HWND", $HLHwnd, "wstr", $file) Return $result[0] EndFunc ;==>_HLLoadFile ; #FUNCTION# ==================================================================================================== ; Name...........: _HLLoadHtml ; Description....: Load HTML from memory. ; Syntax.........: _HLLoadHtml($HLHwnd, $String) ; Parameters.....: $HLHwnd - HTMLayout window handle. ; $String - HTML to load. ; ; Return values..: Success - 1 ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _HLLoadHtml($HLHwnd, $String) $StringSize = StringLen($String) $result = DllCall($HtmLayoutdll, "BOOL", "HTMLayoutLoadHtml", "HWND", $HLHwnd, "str", $String, "UINT", $StringSize) Return $result[0] EndFunc ;==>_HLLoadHtml ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetRootElement ; Description....: Get root DOM element of HTML document. ; Syntax.........: _HLGetRootElement($HLHwnd) ; Parameters.....: $HLHwnd - HTMLayout window handle. ; ; Return values..: Success - Return root element. ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: Root DOM object is always a 'HTML' element of the document. ; =============================================================================================================== Func _HLGetRootElement($HLHwnd) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetRootElement", "HWND", $HLHwnd, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetRootElement ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetChildrenCount ; Description....: Get number of child elements. ; Syntax.........: _HLGetChildrenCount($el) ; Parameters.....: $el - DOM element handle which child elements you need to count ; ; Return values..: Success - Return number of child elements ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetChildrenCount($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetChildrenCount", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetChildrenCount ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetNthChild ; Description....: Get handle of Nth child element. ; Syntax.........: _HLGetNthChild($el, $nth) ; Parameters.....: $el - DOM element handle ; $nth - number of the child element ; ; Return values..: Success - Return handle of the child element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetNthChild($el, $nth) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetNthChild", "ptr", $el, "UINT", $nth-1, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_HLGetNthChild ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetParentElement ; Description....: Get parent element. ; Syntax.........: _HLGetParentElement($el) ; Parameters.....: $el - DOM element handle which parent you need ; ; Return values..: Success - Return handle of the parent element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetParentElement($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetParentElement", "ptr", $el, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetParentElement ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetElementHtml ; Description....: Get Html of the element. ; Syntax.........: _HLGetElementHtml($el, $outer = 1) ; Parameters.....: $el - DOM element handle ; $outer - BOOL, if TRUE will return outer HTML otherwise inner. [Optional] ; ; Return values..: Success - Return Html of element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetElementHtml($el, $outer = 1) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementHtml", "ptr", $el, "str*", "", "BOOL", $outer) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetElementHtml ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetElementInnerText ; Description....: Get inner text of the element. ; Syntax.........: _HLGetElementInnerText($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - Return innertext of element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetElementInnerText($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementInnerText", "ptr", $el, "str*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetElementInnerText ; #FUNCTION# ==================================================================================================== ; Name...........: _HLSetElementInnerText ; Description....: Set inner text of the element. ; Syntax.........: _HLSetElementInnerText($el, $String) ; Parameters.....: $el - DOM element handle ; $String - Innertext ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLSetElementInnerText($el, $String) $len = StringLen($String) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetElementInnerText", "ptr", $el, "str", $String, "UINT", $len) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return 1 EndFunc ;==>_HLSetElementInnerText ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetAttributeCount ; Description....: Get number of element's attributes. ; Syntax.........: _HLGetAttributeCount($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - Return number of element attributes. ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetAttributeCount($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetAttributeCount", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetAttributeCount ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetNthAttribute ; Description....: Get value of any element's attribute by attribute's number. ; Syntax.........: _HLGetNthAttribute($el, $nth) ; Parameters.....: $el - DOM element handle ; $nth - number of desired attribute ; ; Return values..: Success - Return Array with name and value of attribute. $return[0] = name, $return[1] = value ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetNthAttribute($el, $nth) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetNthAttribute", "ptr", $el, "UINT", $nth, "str*", "", "wstr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Dim $aRet[2] $aRet[0] = $result[3] $aRet[1] = $result[4] Return $aRet EndFunc ;==>_HLGetNthAttribute ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetAttributeByName ; Description....: Get value of any element's attribute by name. ; Syntax.........: _HLGetAttributeByName($el, $AttName) ; Parameters.....: $el - DOM element handle ; $AttName - attribute name ; ; Return values..: Success - Return attribute value ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetAttributeByName($el, $AttName) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetAttributeByName", "ptr", $el, "str", $AttName, "wstr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_HLGetAttributeByName ; #FUNCTION# ==================================================================================================== ; Name...........: _HLSetAttributeByName ; Description....: Set attribute's value. ; Syntax.........: _HLSetAttributeByName($el, $AttName, $value) ; Parameters.....: $el - DOM element handle ; $AttName - attribute name ; $value - new attribute value or 0 if you want to remove attribute. ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLSetAttributeByName($el, $AttName, $value) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetAttributeByName", "ptr", $el, "str", $AttName, "wstr", $value) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return 1 EndFunc ;==>_HLSetAttributeByName ; #FUNCTION# ==================================================================================================== ; Name...........: _HLClearAttributes ; Description....: Remove all attributes from the element. ; Syntax.........: _HLClearAttributes($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLClearAttributes($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutClearAttributes", "ptr", $el) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return 1 EndFunc ;==>_HLClearAttributes ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetElementIndex ; Description....: Get element index. ; Syntax.........: _HLGetElementIndex($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - Return index of element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetElementIndex($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementIndex", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetElementIndex ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetElementType ; Description....: Get element's type. ; Syntax.........: _HLGetElementType($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - Return Type of element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetElementType($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementType", "ptr", $el, "str*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_HLGetElementType ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetStyleAttribute ; Description....: Get element's style attribute. ; Syntax.........: _HLGetStyleAttribute($el, $StyleName) ; Parameters.....: $el - DOM element handle ; $StyleName - name of the style attribute ; ; Return values..: Success - Return value of the style attribute. ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLGetStyleAttribute($el, $StyleName) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetStyleAttribute", "ptr", $el, "wstr", $StyleName, "wstr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_HLGetStyleAttribute ; #FUNCTION# ==================================================================================================== ; Name...........: _HLSetStyleAttribute ; Description....: Set element's style attribute. ; Syntax.........: _HLSetStyleAttribute($el, $StyleName, $StyleValue) ; Parameters.....: $el - DOM element handle ; $StyleName - name of the style attribute ; $StyleValue - value of the style attribute. ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLSetStyleAttribute($el, $StyleName, $StyleValue) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetStyleAttribute", "ptr", $el, "str", $StyleName, "wstr", $StyleValue) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return 1 EndFunc ;==>_HLSetStyleAttribute ; #FUNCTION# ==================================================================================================== ; Name...........: _HLVisitElements ; Description....: Return Array of elements in a DOM that meets specified criteria. ; Syntax.........: _HLVisitElements($el, $TagName = "", $AttributeName = "", $AttributeValue = "", $depth = 0) ; Parameters.....: $el - DOM element handle ; $TagName - comma separated list of tag names to search, e.g. "div", "p", "div,p" etc. [Optional] ; $AttributeName - name of attribute, can contain wildcard characters. [Optional] ; $AttributeValue - value of attribute, can contain wildcard characters.[Optional] ; $depth - 0 means all descendants, 1 - direct children only, 2 - children and their children and so on. [Optional] ; ; Return values..: Success - Return array of element, $return[0] : number of element. ; Failure - Return 0 if no element found else Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLVisitElements($el, $TagName = "", $AttributeName = "", $AttributeValue = "", $depth = 0) $TagType = "str" $AttType = "str" $AttVType = "wstr" If $TagName = "" Then $TagType = "ptr" If $AttributeName = "" Then $AttType = "ptr" If $AttributeValue = "" Then $AttVType = "ptr" $handle = DllCallbackRegister("_HLElementsCallback", "BOOL", "ptr;ptr") Dim $aHLelementsfound[1] $result = DllCall($HtmLayoutdll, "int", "HTMLayoutVisitElements", "ptr", $el, $TagType, $TagName, $AttType, $AttributeName, $AttVType, $AttributeValue, "ptr", DllCallbackGetPtr($handle), "ptr", "", "DWORD", $depth) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) DllCallbackFree($handle) $HLelementsCount = UBound($aHLelementsfound) If $HLelementsCount = 1 Then Return 0 $aHLelementsfound[0] = $HLelementsCount-1 Return $aHLelementsfound EndFunc ;==>_HLVisitElements Func _HLElementsCallback($el, $param) Local $iUBound = UBound($aHLelementsfound) ReDim $aHLelementsfound[$iUBound + 1] $aHLelementsfound[$iUBound] = $el EndFunc ;==>_HLElementsCallback ; #FUNCTION# ==================================================================================================== ; Name...........: _HLSelectElements ; Description....: Return Array of elements in a DOM that meets specified CSS selectors. ; Syntax.........: _HLSelectElements($el, $CssSel) ; Parameters.....: $el - DOM element handle ; $CssSel - comma separated list of CSS selectors, e.g.: div, id, div[align="right"]. ; ; Return values..: Success - Return Array of elements, $return[0] : number of element. ; Failure - Return 0 if no element found else Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: See list of supported selectors: http://terrainformatica.com/htmlayout/selectors.whtm ; =============================================================================================================== Func _HLSelectElements($el, $CssSel) $handle = DllCallbackRegister("_HLElementsCallback", "BOOL", "ptr;ptr") Dim $aHLelementsfound[1] $result = DllCall($HtmLayoutdll, "int", "HTMLayoutSelectElements", "ptr", $el, "str", $CssSel, "ptr", DllCallbackGetPtr($handle), "ptr", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) DllCallbackFree($handle) $HLelementsCount = UBound($aHLelementsfound) If $HLelementsCount = 1 Then Return 0 $aHLelementsfound[0] = $HLelementsCount-1 Return $aHLelementsfound EndFunc ;==>_HLSelectElements ; #FUNCTION# ==================================================================================================== ; Name...........: _HLSelectParent ; Description....: Find parent of the element by CSS selector. ; Syntax.........: _HLSelectParent($el, $CssSel, $depth = 0) ; Parameters.....: $el - DOM element handle ; $CssSel - comma separated list of CSS selectors, e.g.: div, id, div[align="right"]. ; $depth - if depth == 1 then it will test only element itself. ; Use depth = 1 if you just want to test he element for matching given CSS selector(s). ; depth = 0 will scan the whole child parent chain up to the root. [Optional] ; ; Return values..: Success - Return parent of the element. ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _HLSelectParent($el, $CssSel, $depth = 0) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutSelectParent", "ptr", $el, "str", $CssSel, "UINT", $depth, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return $result[4] EndFunc ;==>_HLSelectParent ; #FUNCTION# ==================================================================================================== ; Name...........: _HLSetElementHtml ; Description....: Set inner or outer html of the element. ; Syntax.........: _HLSetElementHtml($el, $html, $where) ; Parameters.....: $el - DOM element handle ; $html - string containing html text ; $where - possible values are: ; 0: replace content of the element ; 1: insert html before first child of the element ; 2: insert html after last child of the element ; 3: replace element by html, a.k.a. element.outerHtml = "something" ; 4: insert html before the element ; 5: insert html after the element ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: Value 3,4 and 5 for $where do not work for inline elements like ; =============================================================================================================== Func _HLSetElementHtml($el, $html, $where) $htmllen = StringLen($html) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetElementHtml", "ptr", $el, "str", $html, "DWORD", $htmllen, "UINT", $where) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return 1 EndFunc ;==>_HLSetElementHtml ; #FUNCTION# ==================================================================================================== ; Name...........: _HLDeleteElement ; Description....: Delete element. ; Syntax.........: _HLDeleteElement($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: After call to this function $el will become invalid. ; =============================================================================================================== Func _HLDeleteElement($el) $result = DllCall($HtmLayoutdll, "int", "HTMLayoutDeleteElement", "ptr", $el) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) Return 1 EndFunc ;==>_HLDeleteElement ;~ EXTERN_C HLDOM_RESULT HLAPI HTMLayoutShowPopup (HELEMENT hePopup, HELEMENT heAnchor, UINT placement) ;~ Shows block element (DIV) in popup window. ;~ Func _HLShowPopup($HtmLayoutdll, $el, $anchor, $placement) ;~ $result = DllCall($HtmLayoutdll, "int", "HTMLayoutShowPopup", "ptr", $el, "ptr", $anchor, "UINT", $placement) ;~ If @error Then Return 0 ;~ Return 1 ;~ EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _HLWindowAttachEventHandler ; Description....: Attach/Detach ElementEventProc to the htmlayout window. ; Syntax.........: _HLWindowAttachEventHandler($hwnd, $func) ; Parameters.....: $hwnd - HWND of HtmLayout windows ; $func - Function to receive events (need two params eg: $func($ev, $prm) ; $events - Events you want receive (see remarks) ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: _HLGetParam must use for read param of event. ;~ Events can be : ;~ $HANDLE_INITIALIZATION : attached/detached ;~ $HANDLE_MOUSE : mouse events ;~ $HANDLE_KEY : key events ;~ $HANDLE_FOCUS : focus events, if this flag is set it also means that element it attached to is focusable ;~ $HANDLE_SCROLL : scroll events ;~ $HANDLE_SIZE : size changed event ;~ $HANDLE_DATA_ARRIVED : requested data () has been delivered ;~ $HANDLE_BEHAVIOR_EVENT : secondary, synthetic events: ;~ BUTTON_CLICK, HYPERLINK_CLICK, etc., ;~ a.k.a. notifications from intrinsic behaviors ;~ $HANDLE_METHOD_CALL : behavior specific methods ;~ $HANDLE_EXCHANGE : system drag-n-drop events ;~ $HANDLE_ALL : all of them ; =============================================================================================================== Func _HLWindowAttachEventHandler($hwnd, $func, $events) $HandleWindowsAttachEvent = DllCallbackRegister("HLEvHandler", "BOOL", "ptr;ptr;UINT;ptr") $result = DllCall($HtmLayoutdll, "int", "HTMLayoutWindowAttachEventHandler", "HWND", $hwnd, "ptr", DllCallbackGetPtr($HandleWindowsAttachEvent), "ptr", "", "UINT", $DISABLE_INITIALIZATION+$events) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then SetError($result[0],0,-1) $HtmLayoutEvHandler = $func Return 1 EndFunc ;==>_HLWindowAttachEventHandler Func HLEvHandler($tag,$el,$ev,$prm) $a = DllStructCreate("UINT cmd", $prm) $cmd = DllStructGetData($a, "cmd") $a = 0 If $cmd > 32768 Then Return Execute ($HtmLayoutEvHandler&"("&$ev&","&$prm&")") EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _HLGetParam ; Description....: Get parameter of events ; Syntax.........: _HLGetParam($ev, $prm) ; Parameters.....: $ev - Type of event see remarks of _HLWindowAttachEventHandler ; $prm - Parameter of event ; ; Return values..: Success - return an array depending of event ; Failure - Return -1 ; Remarks........: For Uppercase type see "HtmLayout Constants.au3" ; $HANDLE_MOUSE : $ret[12]=[MOUSE_EVENTS, target el, curs xpos el rel, curs ypos el rel, curs xpos doc rel, curs ypos doc rel, MOUSE_BUTTONS, KEYBOARD_STATES, CURSOR_TYPE, is on icon, el dragged, DRAGGING_TYPE] ; $HANDLE_KEY : $ret[4]=[KEY_EVENTS, target el, key code, KEYBOARD_STATES] ; $HANDLE_FOCUS : $ret[4]=[FOCUS_EVENTS, target el, focus by click, cancel] ; $HANDLE_SCROLL: $ret[4]=[SCROLL_EVENTS, target el, scroll pos, 1 if vert scroll] ; $HANDLE_BEHAVIOR_EVENT : $ret[5]=[BEHAVIOR_EVENTS, target el, source el, EVENT_REASON or EDIT_CHANGED_REASON, data] ;=============================================================================================================== Func _HLGetParam($ev, $prm) Local $ap = -1 If $ev = $HANDLE_MOUSE Then $str = "UINT cmd;ptr target;DWORD posx;DWORD posy;DWORD pos_documentx;DWORD pos_documenty;UINT button_state;UINT alt_state;UINT cursor_type;BOOL is_on_icon;ptr dragging;UINT dragging_mode" $ap = getstructdata($str,$prm) EndIf If $ev = $HANDLE_KEY Then $str = "UINT cmd;ptr target;UINT key_code;UINT alt_state" $ap = getstructdata($str,$prm) EndIf If $ev = $HANDLE_FOCUS Then $str = "UINT cmd;ptr target;BOOL by_mouse_click;BOOL cancel" $ap = getstructdata($str,$prm) EndIf If $ev = $HANDLE_SCROLL Then $str = "UINT cmd;ptr target;int pos;BOOL vertical" $ap = getstructdata($str,$prm) EndIf If $ev = $HANDLE_BEHAVIOR_EVENT Then $str = "UINT cmd;ptr heTarget;ptr he;UINT reason;ptr data" $ap = getstructdata($str,$prm) EndIf If $ev = $HANDLE_METHOD_CALL Then $str = "UINT cmd;ptr heTarget;ptr he;UINT reason;ptr data" $ap = getstructdata($str,$prm) EndIf Return $ap EndFunc Func getstructdata($str,$prm) $a = DllStructCreate($str, $prm) $b = StringSplit ( $str, ";") Dim $ret[$b[0]] For $i = 0 To $b[0]-1 $ret[$i] = DllStructGetData($a,$i+1) Next Return $ret EndFunc Edit: add some function. User calltips : _HLStartup ($dll = "HtmLayout.dll") Initialize HtmLayout (required: #include <HtmLayout UDF.au3>) _HLCreateGui ($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50) Create HtmLayout Windows (required: #include <HtmLayout UDF.au3>) _HLLoadFile ($HLHwnd, $file) Load HTML file. (required: #include <HtmLayout UDF.au3>) _HLLoadHtml ($HLHwnd, $String) Load HTML from memory. (required: #include <HtmLayout UDF.au3>) _HLGetRootElement ($HLHwnd) Get root DOM element of HTML document. (required: #include <HtmLayout UDF.au3>) _HLGetChildrenCount ($el) Get number of child elements. (required: #include <HtmLayout UDF.au3>) _HLGetGetFocusElement ($hwnd) Get focused DOM element of HTML document. (required: #include <HtmLayout UDF.au3>) _HLGetGetElementState ($el) Get state bits, see ELEMENT_STATE_BITS in "HtmLayout constats.au3" (required: #include <HtmLayout UDF.au3>) _HLSetElementState ($el, $stateToSet, $stateToClear = 0, $upt = 1) Set state bits, see ELEMENT_STATE_BITS in "HtmLayout constats.au3" (required: #include <HtmLayout UDF.au3>) _HLGetNthChild ($el, $nth) Get handle of Nth child element. (required: #include <HtmLayout UDF.au3>) _HLGetParentElement ($el) Get parent element. (required: #include <HtmLayout UDF.au3>) _HLGetElementHtml ($el, $outer = 1) Get Html of the element. (required: #include <HtmLayout UDF.au3>) _HLGetElementInnerText ($el) Get inner text of the element. (required: #include <HtmLayout UDF.au3>) _HLSetElementInnerText ($el, $String) Set inner text of the element. (required: #include <HtmLayout UDF.au3>) _HLGetAttributeCount ($el) Get number of element's attributes. (required: #include <HtmLayout UDF.au3>) _HLGetNthAttribute ($el, $nth) Get value of any element's attribute by attribute's number. (required: #include <HtmLayout UDF.au3>) _HLGetAttributeByName ($el, $AttName) Get value of any element's attribute by name. (required: #include <HtmLayout UDF.au3>) _HLSetAttributeByName ($el, $AttName, $value) Set attribute's value. (required: #include <HtmLayout UDF.au3>) _HLClearAttributes ($el) Remove all attributes from the element. (required: #include <HtmLayout UDF.au3>) _HLGetElementIndex ($el) Get element index. (required: #include <HtmLayout UDF.au3>) _HLGetElementType ($el) Get element's type. (required: #include <HtmLayout UDF.au3>) _HLGetStyleAttribute ($el, $StyleName) Get element's style attribute. (required: #include <HtmLayout UDF.au3>) _HLSetStyleAttribute ($el, $StyleName, $StyleValue) Set element's style attribute. (required: #include <HtmLayout UDF.au3>) _HLVisitElements ($el, $TagName = "", $AttributeName = "", $AttributeValue = "", $depth = 0) Return Array of elements in a DOM that meets specified criteria. (required: #include <HtmLayout UDF.au3>) _HLSelectElements ($el, $CssSel) Return Array of elements in a DOM that meets specified CSS selectors. (required: #include <HtmLayout UDF.au3>) _HLSelectParent ($el, $CssSel, $depth = 0) Find parent of the element by CSS selector. (required: #include <HtmLayout UDF.au3>) _HLSetElementHtml ($el, $html, $where) Set inner or outer html of the element. (required: #include <HtmLayout UDF.au3>) _HLDeleteElement ($el) Delete element. (required: #include <HtmLayout UDF.au3>) _HLWindowAttachEventHandler ($hwnd, $func) Attach/Detach ElementEventProc to the htmlayout window. (required: #include <HtmLayout UDF.au3>) _HLGetParam ($ev, $prm) Get parameter of events (required: #include <HtmLayout UDF.au3>)HtmLayout UDF.7z
    1 point
  4. iresolver, Yes - that is not valid syntax. I would use a RegEx on the returned value like this: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) $cButton = GUICtrlCreateButton("Test", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $sText = GUICtrlRead($cInput) If StringRegExp($sText, ".*\..*@gmail.com") Then MsgBox($MB_SYSTEMMODAL, "Match", $sText) Else MsgBox($MB_SYSTEMMODAL, "No Match", $sText) EndIf EndSwitch WEnd SER decode: .* - Any number of characters followed by... \. - a literal dot... .* - any other charaters... @gmail.com - and ended by the literal string M23
    1 point
  5. As I stated above. Try: $Result = _Excel_RangeRead($WBook, "Sheet2")
    1 point
  6. The little assembly code posted >here by Tekk to count how many @LF there are in a string is very fast. It can be easly modified to count any other char instead of only a @LF in this way: #include <Memory.au3> Local $sString, $char For $i = 1 To 100000 $sString &= "This line is line " & $i & @CRLF Next $char = "i" MsgBox(0, 'Count of "' & $char & '"', 'There are ' & StringCountChar($sString, $char) & ' occurrences of the char "' & $char & '"') Func StringCountChar(ByRef $g_sString, $sCHR) Local $pCountLF = _MemVirtualAlloc(Null, 25, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) $sCHR = StringLeft($sCHR, 1) DllStructSetData(DllStructCreate("BYTE[25]", $pCountLF), 1, "0x" _ & "8B4C2404" _ ;~ mov ecx, dword[esp+04h] & "31C0" _ ;~ xor eax, eax & "8A11" _ ;~ @@:mov dl, byte[ecx] & "80FA00" _ ;~ cmp dl, 00h & "7409" _ ;~ je @f & "41" _ ;~ inc ecx & "80FA" & Hex(Asc($sCHR), 2) _ ;~ cmp dl, NNh <-- modified here & "75F3" _ ;~ jne @b & "40" _ ;~ inc eax & "EBF0" _ ;~ jmp @b & "C20400" _ ;~ @@:ret 4 ) Local $nResult = DllCallAddress("INT", $pCountLF, "STR", $g_sString)[0] _MemVirtualFree($pCountLF, 0, $MEM_RELEASE) Return $nResult EndFunc ;==>StringCountChar That's all. edit: added ByRef to $g_sString in function
    1 point
  7. funkey

    getaddrinfo timeout

    Since the timeout parameter of GetAddrInfoEx() is only supported on Windows8 and 2012, I cannot test this function. But I hope this works. #include <Array.au3> Global Const $AF_UNSPEC = 0 Global Const $AF_INET = 2 Global Const $AF_INET6 = 23 Global Const $IPPROTO_TCP = 6 Global Const $IPPROTO_UDP = 17 Global Const $SOCK_STREAM = 1 Global Const $SOCK_DGRAM = 2 Global Const $NS_DNS = 12 Global Const $tagTimeVal = "long tv_sec;long tv_usec" Global Const $tagAddrInfoEx = "int ai_flags;int ai_family;int ai_socktype;int ai_protocol;UINT_PTR ai_addrlen;ptr ai_canonname;ptr ai_addr;ptr ai_blob;UINT_PTR ai_bloblen;ptr ai_provider;ptr ai_next" Global Const $tagSockAddr_In = "short sin_family;USHORT sin_port;ULONG sin_addr;char sin_zero[8]" Global Const $tagSockAddr_In6 = "short sin6_family;USHORT sin6_port;ULONG sin6_flowinfo;byte sin6_addr[16];ULONG sin6_scope_id" TCPStartup() Global $Timeout = 1000 ; 1 second timeout Global $aIP = _GetAddrInfoEx("..localmachine", $Timeout, $AF_INET) If @error Then MsgBox(0, "GetAddrInfoEx", "Error: " & @extended) Else _ArrayDisplay($aIP) EndIf TCPShutdown() ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms738518%28v=vs.85%29.aspx Func _GetAddrInfoEx($sNodeName = "..localmachine", $iTimeout = 0, $AddressFamily = $AF_UNSPEC, $SockType = $SOCK_STREAM, $IpProtocol = $IPPROTO_TCP, $NameSpace = $NS_DNS) ;funkey 2015.04.11 Local $pResult, $tAddrInfoEx, $sIP, $tName, $tTimeout, $pTimeout If $iTimeout <> 0 Then $tTimeout = DllStructCreate($tagTimeVal) $pTimeout = DllStructGetPtr($tTimeout) DllStructSetData($tTimeout, "tv_sec", Floor($iTimeout / 1000)) DllStructSetData($tTimeout, "tv_usec", ($iTimeout - DllStructGetData($tTimeout, "tv_sec") * 1000) * 1000) Else $pTimeout = 0 EndIf Local $hints = DllStructCreate($tagAddrInfoEx) DllStructSetData($hints, "ai_family", $AddressFamily) DllStructSetData($hints, "ai_socktype", $SockType) DllStructSetData($hints, "ai_protocol", $IpProtocol) Local $aRet = DllCall("ws2_32.dll", "int", "GetAddrInfoExW", "wstr", $sNodeName, "ptr", 0, "DWORD", $NameSpace, "ptr", 0, _ "struct*", $hints, "ptr*", 0, "ptr", $pTimeout, "ptr", 0, "ptr", 0, "ptr", 0) If $aRet[0] <> 0 Then Return SetError(1, $aRet[0], 0) $pResult = $aRet[6] Do $tAddrInfoEx = DllStructCreate($tagAddrInfoEx, $pResult) Switch DllStructGetData($tAddrInfoEx, "ai_family") Case $AF_INET If $AddressFamily = $AF_UNSPEC Or $AddressFamily = $AF_INET Then $tName = DllStructCreate($tagSockAddr_In, DllStructGetData($tAddrInfoEx, "ai_addr")) $sIP &= _InetNtop(DllStructGetPtr($tName, "sin_addr"), $AF_INET) & ";" EndIf Case $AF_INET6 If $AddressFamily = $AF_UNSPEC Or $AddressFamily = $AF_INET6 Then $tName = DllStructCreate($tagSockAddr_In6, DllStructGetData($tAddrInfoEx, "ai_addr")) $sIP &= _InetNtop(DllStructGetPtr($tName, "sin6_addr"), $AF_INET6) & ";" EndIf EndSwitch $pResult = DllStructGetData($tAddrInfoEx, "ai_next") Until $pResult = 0 _FreeAddrInfoEx($aRet[6]) Return StringSplit(StringTrimRight($sIP, 1), ";", 2) EndFunc ;==>_GetAddrInfoEx Func _FreeAddrInfoEx($pAddrInfoEx) DllCall("ws2_32.dll", "none", "FreeAddrInfoEx", "ptr", $pAddrInfoEx) EndFunc ;==>_FreeAddrInfoEx Func _InetNtop($tIn_Addr, $iFamily = $AF_INET) ;IPv4 and IPv6 --> Vista and above Local $tBuffer = DllStructCreate("wchar[46]") ;16 for IPv4, 46 for IPv6 Local $aRet = DllCall("ws2_32.dll", "wstr", "InetNtopW", "int", $iFamily, "struct*", $tIn_Addr, "struct*", $tBuffer, "int", DllStructGetSize($tBuffer) / 2) Return DllStructGetData($tBuffer, 1) EndFunc ;==>_InetNtop
    1 point
  8. TheSpannish

    _DIAC UDF

    Spannish!! case 0A return "Has hecho algo que no deberias" case 0A return "No puedes beneficiarte de un script robado, la culpabilidad te corroerá la mente, no hagas algo malo solo por diversión, Decide..." case 0A return "Por favor olvidame y haz lo correcto" case 0A return "Deja que cometa el crimen"
    1 point
  9. Gianni

    reading From the last

    .... your code has a bug, in some cases returns the same string... Local $original = "radar" Local $reversed = StringReverse($original) MsgBox(0, 0, "Originl:" & @TAB & $original & @CRLF & "Reversed:" & @TAB & $reversed)
    1 point
  10. Come on dude, just do some early high school math. You can do it. /edit: You copypasted the function straight from >here (or something related), and now you want others to do math and coding for you. Two people generously show you the math including a working code example, and instead of working with that, you just say "not what I meant, sadface, now can I get the exact code instead?" Maybe that's what you meant by being a freak.
    1 point
  11. oscar88

    reading From the last

    Thank you my friend
    1 point
  12. Replace the Sleep() with a timer loop. $time = 1 ; 1 millisecond $Timer = TimerInit() While $Trans > 0 WinSetTrans($Main_Gui, "", $Trans) $Trans -= 1 Do Until TimerDiff($Timer) >= $time $Timer = TimerInit() WEnd
    1 point
  13. @uomoragno88: Thx for info! Can you explain the part with the changelog a little bit more? (What you do and when it happen) @kcvinu: Oh..ok. I try to fix it next week. And about (), yes its on the to do list
    1 point
  14. It's such a small download size that I wouldn't expect a single comment. This is also quite a demanding comment and breaks forum etiquette. I don't use it as it doesn't fit my needs and I am not happy with the way you've used Global variables inside a function. Please don't get angry, but you did wanted a comment and I am being honest.
    1 point
  15. Pure guy. You (as many others) are victim of Microsoft, who need money for new and new versions of not needed and not wanted systems, so they every 2 years create new version of Windows just to get more money. The most changes in new Windows are to bad. People definitely are not more productive in newer Windows as you said! It's exactly opposite way! I hate all newer Windows after XP. Yes I can stand Windows7 as it's relatively normal but everything other is crap/shit (Vista,Win8). With each new Windows there is so much problems (cripled GUI, cripled compatibility, everything good changed to bad) so developers and users of applications have to solve many redundant tasks. Microsoft does all these changes not for improving OS but only just to have new changed/diferent version to get more money for new sold OS licences. They just synthetically create previous versions obsolete as soon as possible to force people paying for new licences.
    1 point
  16. mLipok

    Graphical AutoIt Debugger

    AutoIt_Debugger_Setup_v0.32.0.exe.7z Latest version which I have stored on my disc. mLipok
    1 point
  17. JLogan3o13

    _DIAC UDF

    After a thorough review, I'll take J1's version...
    1 point
  18. JohnOne

    _DIAC UDF

    Switch $iLang Case Else ContinueCase Case 0409 ; en-US Return "You done something which shouldn't be done" Case 0809 ; en-GB Return "You done something which shouldn't be done" EndSwitch Really? Does that even work? I normally have a lot of time for beginners, but you son, have got to be trolling. You know there is an age limit of 13 or over to join the forum?
    1 point
  19. MrCreatoR

    GUITFLabel UDF

    Hi, A long time ago i was looking for a way to set color/font for seperate parts inside label control. I even posted a Feature request about this issue, but back then i quickly realized (well, actualy it's Valik ho told me ) that this would be almost impossible to do (for my anyway). But today i found a tricky way to do that - I managed to build a function, that is kind of html-tag parser. It creates a label control for each text data that is wrapped with <font> tag (or not, but then the control is not formatted). Function Header: ; #FUNCTION# ==================================================================================================== ; Name...........: _GUICtrlTFLabel_Create ; Description....: Creates Text Formatted Label control(s). ; Syntax.........: _GUICtrlTFLabel_Create($sData, $iLeft, $iTop [, $iWidth = -1 [, $iHeight = -1 [, $nStyle = -1 [, $nExStyle = -1 ]]]]) ; ; Parameters.....: $sData - Formatted data. To set formatted data use <font></font> tag for data string. ; * This tag supports the following parameters (when used, they *can* be wrapped with quotes): ; Color - Text *Color* of data between the tags. ; Size - Text *Size*. ; Weight - Text *Weight* (the same values as used in GUICtrlSetFont()). ; Attrib - Text *Attributes* - The same values as used in GUICtrlSetFont(), ; or supported strings combined together: i(talic), u(nderlined), s(trike). ; Name - Text font *Name* (the same values as used in GUICtrlSetFont()). ; Style - Label control’s Style (applies for partial data between the tags). ; ExStyle - Label control’s ExStyle (applies for partial data between the tags). ; Cursor - Label control’s Cursor (can be cursor IDs, or strings, see description for MouseGetCursor). ; Top - Top position correction (relative to the global $iTop parameter). ; This is designed to avoid text corruption when using different font names/text's size. ; ; $iLeft - Left position (starting point in case when <font> tags are used) of label controls. ; $iTop - Top position of label controls. ; $iWidth - [Optional] Width of label control - Not used when <font> tags found in the data. ; $iHeight - [Optional] Height of label control - Not used when <font> tags found in the data. ; $nStyle - [Optional] (Forced) Style for entire label controls. Can be overridden by local Style parameter. ; $nExStyle - [Optional] (Forced) ExStyle for entire label controls. Can be overridden by local ExStyle parameter. ; ; Return values..: Success - Returns array of identifiers (Control IDs) of new created label controls. ; Failure - Returns 0. ; Author.........: G.Sandler (a.k.a MrCreatoR) ; Modified.......: ; Remarks........: ; Related........: ; Link...........: http://www.autoitscript.com/forum/index.php?showtopic=96986 ; Example........: Yes. ; =============================================================================================================== Example - Formatted Labels Editor: #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> #include "GUITFLabel.au3" Global $iEdit_Changed = 0, $aLabel_Ctrls $hGUI = GUICreate("Formatted Labels Editor", 650, 400) #Region Formate text panel GUICtrlCreateLabel("Size:", 10, 8, -1, 15) $nSize_Combo = GUICtrlCreateCombo("", 40, 5, 55, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|8|8.5|9|10|11|12|14|16|18|20|22|24|26|28|36|48|72", "None") GUICtrlCreateLabel("Weight:", 100, 8, -1, 15) $nWeight_Combo = GUICtrlCreateCombo("", 140, 5, 55, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|200|400|600|800|1000", "None") GUICtrlCreateLabel("Attrib:", 10, 33, -1, 15) $nAttrib_Combo = GUICtrlCreateCombo("", 40, 30, 155, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|italic|underlined|strike|italic+underlined+strike|italic+underlined|italic+strike|underlined+strike", "None") GUICtrlCreateLabel("Name:", 230, 15, 50, 15) $nName_Combo = GUICtrlCreateCombo("", 230, 30, 160, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|Arial|Comic Sans Ms|Tahoma|Times|Georgia|Lucida Sans Unicode|Verdana|Times New Roman|Courier New", "None") GUICtrlCreateLabel("Color:", 400, 15, 50, 15) $nColor_Combo = GUICtrlCreateCombo("", 400, 30, 60, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|Red|Green|Blue|Yellow|Orange|Gray|Brown|White", "None") GUICtrlCreateLabel("Bk Color:", 470, 15, 50, 15) $nBkColor_Combo = GUICtrlCreateCombo("", 470, 30, 60, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|Red|Green|Blue|Yellow|Orange|Gray|Brown|White", "None") GUICtrlCreateLabel("Cursor:", 540, 15, 50, 15) $nCursor_Combo = GUICtrlCreateCombo("", 540, 30, 100, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) GUICtrlSetData(-1, "None|POINTING|APPSTARTING|ARROW|CROSS|HELP|IBEAM|ICON|NO|SIZE|SIZEALL|SIZENESW|SIZENS|SIZENWSE|SIZEWE|UPARROW|WAIT|HAND", "None") #EndRegion Formate text panel GUICtrlCreateGroup("Select text and then select the formatting parameters from the above panel:", 10, 60, 630, 150) $nSrcText_Edit = GUICtrlCreateEdit("", 20, 80, 610, 120, $ES_NOHIDESEL) ;GUICtrlCreateLabel("Original text:", 20, 75, -1, 15) ;$nSrcText_Edit = GUICtrlCreateEdit("", 20, 90, 610, 40, $ES_NOHIDESEL) ;GUICtrlCreateLabel("Formatted text:", 20, 140, -1, 15) ;$nFormattedText_Edit = GUICtrlCreateEdit("", 20, 155, 610, 40, BitOR($ES_NOHIDESEL, $ES_READONLY)) GUICtrlCreateGroup("Preview:", 10, 230, 630, 130) GUICtrlSetFont(-1, 10, 800) $nClose_Button = GUICtrlCreateButton("Close", 10, 370, 60, 20) $nCopy_Button = GUICtrlCreateButton("Copy", 90, 370, 60, 20) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $nClose_Button Exit Case $nSize_Combo, $nWeight_Combo, $nAttrib_Combo, $nName_Combo, $nColor_Combo, $nBkColor_Combo, $nCursor_Combo Local $sParam = StringLower(StringRegExpReplace(GUICtrlRead($nMsg - 1), 'h+|:', '')) Local $sValue = GUICtrlRead($nMsg) _SetFormattedText_Proc($sParam, $sValue) Case $nCopy_Button Local $sText = GUICtrlRead($nSrcText_Edit) If $sText <> "" Then ClipPut($sText) EndIf EndSwitch If $iEdit_Changed Then $iEdit_Changed = 0 For $i = 1 To UBound($aLabel_Ctrls)-1 GUICtrlDelete($aLabel_Ctrls[$i]) Next $aLabel_Ctrls = _GUICtrlCreateTFLabel(GUICtrlRead($nSrcText_Edit), 20, 245, 610, 110) EndIf WEnd Func _SetFormattedText_Proc($sParam, $sValue) If $sParam = "attrib" And Not StringRegExp($sValue, '(?i)A(None)?z') Then $aSplit = StringSplit($sValue, "+") $sValue = "" For $i = 1 To $aSplit[0] $sValue &= StringLeft($aSplit[$i], 1) If $i < $aSplit[0] Then $sValue &= "+" EndIf Next EndIf Local $sSelectionData = ControlCommand($hGUI, "", $nSrcText_Edit, "GetSelected") Local $sAddParamValue = ' ' & $sParam & '="' & $sValue & '"' If $sSelectionData = '' Then Return EndIf If StringRegExp($sSelectionData, '(?i)<font.*>.*</font>') Then $sSelectionData = StringRegExpReplace($sSelectionData, '(?i)(<font.*)( ' & $sParam & '=".*?")(.*>.*</font>)', '13') If Not StringRegExp($sValue, '(?i)A(None)?z') Then $sSelectionData = StringRegExpReplace($sSelectionData, '(?i)(<font.*)(>.*</font>)', '1' & $sAddParamValue & '2') EndIf If StringRegExp($sSelectionData, '(?i)<fonth*>.*</font>') Then $sSelectionData = StringRegExpReplace($sSelectionData, '(?i)<font.*>(.*)</font>', '1') EndIf ElseIf $sAddParamValue <> '' Then $sSelectionData = '<font' & $sAddParamValue & '>' & $sSelectionData & '</font>' EndIf _GUICtrlEdit_ReplaceSel($nSrcText_Edit, $sSelectionData) Local $iStart = StringInStr(GUICtrlRead($nSrcText_Edit), $sSelectionData)-1 Local $iEnd = $iStart + StringLen($sSelectionData) GUICtrlSendMsg($nSrcText_Edit, $EM_SETSEL, $iStart, $iEnd) EndFunc Func WM_COMMAND($hWnd, $nMsg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Local $hCtrl = $lParam Switch $nID Case $nSrcText_Edit Switch $nNotifyCode Case $EN_CHANGE, $EN_UPDATE $iEdit_Changed = 1 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Screenshots: History version: Attachments: v1.5 GUITFLabel_UDF.zip v1.4 _GUICtrlCreateTFLabel_UDF.zip v1.3 _GUICtrlCreateTFLabel_UDF.zip v1.2 _GUICtrlCreateTFLabel_UDF.zip(Edited version - Previous downloads: 3 ) v1.1 _GUICtrlCreateTFLabel_UDF.zip v1.0 _GUICtrlCreateTFLabel_UDF.zip
    1 point
×
×
  • Create New...