Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/21/2017 in all areas

  1. LarsJ

    Accessing AutoIt Variables

    What's next This was pretty much what I had planned for this example. I'll check my notes to see if there's anything I've forgotten. The next step is of course to utilize the UDF (AccessingVariables.au3) to create some fast array manipulation functions and to be able to deal with arrays with more elements. It's natural to try to optimize some of the functions in Array.au3. But it'll not be sensibly simply to optimize the existing code. Eg. to sort an array with many elements it would not be appropriate to sort the entire array. It would be much better to use some kind of index based sorting procedure. It's not my plan to create millions of lines of C++ or assembler kode. I'm particularly interested in functions where the AutoIt code contains a single central loop that is crucial for performance. Then, only the code in this loop has to be translated to compiled code. This is very well illustrated in the example above. Currently I'm only at a stage where I've made a few notes. So it'll take some time. It'll be a new project and I'll create a new example.
    3 points
  2. guinness

    ResourcesEx UDF.

    So if you haven't noticed Zedna's Resources UDF has been a very popular UDF over the last 7 years and was last updated in 2011, but now is the time to bring the UDF up to date with the current AutoIt language syntax (v3.3.14.2). So with the blessing of Zedna may I present to you ResourcesEx. It's built using the UDF standards I have tried to enforce around here, with improved documentation and an overall UDF structure. I please ask that you try and break the UDF, criticise, educate, whatever, just play around with the functions and example. I do ask that you just don't say "you've missed the point" and leave at that. Provide an alternative or constructive reason as to why I have "missed the point". Thanks. IMPORTANT: You must be using SciTE4AutoIt3, as this comes included with AutoItWrapper Changes between Zedna's UDF and guinness' UDF. _ResourceGet() => _Resource_Get() _ResourceGetAsString() => _Resource_GetAsString() with an additional param of whether to return ANSI. _ResourceGetAsStringW() => _Resource_GetAsString() _ResourceGetAsBytes() => _Resource_GetAsBytes() _ResourceGetAsImage() => _Resource_GetAsImage() _ResourceGetAsBitmap() => _Resource_GetAsBitmap() _ResourceSaveToFile() => _Resource_SaveToFile() _ResourceSetImageToCtrl() => _Resource_SetToCtrlID() _SetBitmapToCtrl() => _Resource_SetBitmapToCtrlID() As to JFX's question of what makes this different... Known problems/limitations: (Taken for Zedna's Resources UDF) _ResourceGet() returns resource size (in bytes) in @extended macro but not for resource type RT_BITMAP [FIXED] _ResourceSetImageToCtrl() works with "static/button" type of controls (picture,label,icon,button,checkbox,radiobutton,groupbox) [NO_ISSUE] _ResourcePlaySound() plays only WAV files (not MP3 files) [FIXED] _ResourceGetAsBytes() doesn't work for RT_BITMAP type because _ResourceGet() returns hBitmap instead of memory pointer in this case there could be used _ResourceGetAsImage() as workaround _ResourceGet() has potential memory leak releasing of resources UnlockResource, FreeResource (opposite of LoadResource, LockResource) is not done because it must be done after using of resources at the end and not inside UDF [FIXED] _GDIPlus_Startup() is called once at start of whole include --> no _GDIPlus_Shutdown() is called [FIXED] Download the ZIP and play around with the Example/UDF. ResourcesEx.zip Jos: 15-9-2022 Updated version replaced $__WINVER with _WinAPI_GetVersion() Jos: 27-4-2023 updated script as they required extra #include: ResourcesEx.zip Changelog: 2015/09/26 Changed: Comments throughout the UDF, removing trailing dot Fixed: Various cosmetic changes 2015/01/12 Fixed: Example directive using double equals sign Fixed: Delete functions not being cast as a bool value. (Thanks Synix) Fixed: @error and @extended not be passed back in nested functions e.g. _Resource_GetAsRaw() 2014/07/19 Added: _Resource_SetBitmapToCtrlID() formely known as _Resource_SetImageToCtrlID() Added: Note about using #AutoIt3Wrapper_Res_Icon_Add to the example. (Thanks Zedna) Added: Passing a blank string to _Resource_SetToCtrlID() through the $sResNameOrID parameter, will delete the image and previous handle Changed: _Resource_SetImageToCtrlID() now accepts a hBitmap not a HBITMAP object Fixed: _Resource_GetAsBitmap() now works the same way as _ResourceGetAsBitmap() did, by converting a jpg, png etc... to HBITMAP Fixed: Memory management of some functions 2014/07/18 Fixed: Destroying a cursor Fixed: Regression from loading the current of external module. (Thanks UEZ) 2014/07/17 Added: Additonal checks to destroy cursors and icons Added: Checking if the dll or exe filepath has a valid extension Added: Example of using an icon and image on a button control Fixed: Icons and cursors (finally) being re-sized to a control Fixed: Using GUIGetStyle() on a non-AutoIt handle would cause issue with controls Fixed: Variable naming of $sDLL to $sDllOrExePath for improved clarity Removed: Workaround for setting icons to AutoIt controls 2014/07/17 Added: Commented workaround in the example for re-sizing an icon control Added: ResourcesEx_PE.au3 created by PreExpand for all you constant variable haters out there!!! Fixed: Changelog comments and source code comments Fixed: Re-sizing icons when the control was different to the icon's size. (Thanks czardas for the MSDN link and Jon.) Fixed: Re-sizing cursors and icons in general 2014/07/15 Added: Comments about using SOUND for wav files and RT_RCDATA for mp3 files. (Thanks Melba23) Added: Option to relevant functions to re-size the image based on the control's dimensions. (Requested by kinch: http://www.autoitscript.com/forum/topic/51103-resources-udf/?p=1147525) Added: Using _Resource_LoadFont() example. (Thanks UEZ) Changed: Certain example resources to now use those found in %AUTOITDIR%\Examples\Helpfile\Extras Changed: Constants and enums readability. (Thank mLipok) Changed: Internal functions for destroying resources Changed: Removed changes made from the previous version for loading resources multiple times. The design needs to be re-thought Changed: Setting styles of controls using native AutoIt functions Fixed: Destroying control resource images would fail to show if reinstated again Fixed: Documentation comments Fixed: Missing certain users who helped with creating this UDF Fixed: Outdated SciTE files 2014/07/14: Added: _Resource_GetAsCursor(), for the loading of animated cursors and standard cursors which can then be used with _WinAPI_SetCursor() Added: _Resource_GetAsIcon(), for loading icon resource types Added: _Resource_LoadFont(), which retrieves a font resource and adds to the current memory of the associated module Added: _Resource_SetCursorToCtrlID() and _Resource_SetIconToCtrlID() Added: Additional resource types to destroy on exit, including $RT_FONT, $RT_ICON and $RT_MENU Added: Playing Mp3s to _Resource_LoadSound(). (Thanks to UEZ and Melba23 with changes made by me.) Changed: _Resource_GetAsBitmap() returns a HTBITMAP handle without converting from hBitmap to HBITMAP Changed: _Resource_PlaySound() to _Resource_LoadSound() Changed: _Resource_SetBitmapToCtrlID() to _Resource_SetImageToCtrlID() Changed: _SendMessage() to GUICtrlSendMsg() Changed: Example files Changed: Setting $iError in the internal get function Changed: Signature of _Resource_Destroy() Changed: Updated example to reflect major changes to the ResourcesEx UDF Changed: Various UDF tweaks that I didn't document because I simply couldn't keep track of all the playing around I did in the last week Fixed: _Resource_GetAsImage() not returning an error when a bitmap couldn't be found in the resource table Fixed: Retrieving length of a string Fixed: Using the current module instead of zero in _Resource_LoadSound() Fixed: Various comment changes. (Thanks mLipok) Fixed: Loading resources multiple times. This is fixed thanks to using the internal storage array 2014/07/07: Added: _Resource_Destroy() and _Resource_DestroyAll() to destroy a particular resource name or all resources Added: Checking if the resource name of id value is empty Added: Descriptions, though could do with a little tweaking Changed: _Resource_Get() to _Resource_GetAsRaw() Changed: Internal workings of __Resource_Storage() Changed: Re-size the storage array when destroyed or on shutdown Fixed: _Resource_GetAsString() with default encoding of ANSI Fixed: Calltips API referencing Resources.au3 and not ResourcesEx.au3 Removed: _Resource_Shudown() due to the addition of _Resource_Destroy() and _Resource_DestroyAll() 2014/07/06: Added: _Resource_Shudown() to free up those resources which aren't loaded using _WinAPI_LockResource(). UnlockResource is obsolete Added: Support for using $RT_STRING Changed: _Resource_GetAsString() now works correctly for most encodings. (Thanks Jos) Changed: _Resource_GetAsString() will now load as a string if the resource type requested is $RT_STRING 2014/07/04: Added: #Regions. (Thanks mLipok) Added: #Tidy_Parameters=/sort_funcs /reel (Thanks mLipok) Added: All optional params now accept the default keyword Added: Link to this thread. (Thanks mLipok) Added: Main header. (Thanks mLipok) Changed: $f.... >> $b..... (Thanks mLipok) 2014/07/03: Initial release
    1 point
  3. MattHiggs

    Neat "Window spy" tool

    Hey AutoIT scripters, I found a neat little application I wanted to share with you. SpyEx is a tool which enumerates all of the Windows for each process running on computer, gives you a detailed DOM structure of any open IE windows, Enumerate UI Automation and Active Accessibility tree, and "Spy" on a window to see a list of the windows messages and their parameters that it receives in real time. All from within a single, portable executable. The developer has also made some other interesting tools as well, so I would highly recommend checking them out.
    1 point
  4. Well I'm sure that locutus243 (last visited 2014) will be delighted to see his 11+ years old problem finally solved
    1 point
  5. ?? If $oPTag.ClassName = 'price' And $oPTag.ID = 'product-price-3445' Then edit: also, since an ID is "unique" within an html page maybe filtering only on the ID will suffice If $oPTag.ID = 'product-price-3445' Then
    1 point
  6. @mikell only until I figure out how to do it with stringmid and strenglen math, I have to do real work but in a few hours I shall undo that blasphemy.
    1 point
  7. @ViciousXUSMC How did you guess ? BTW the main idea here was to use \G to cause a 'forced failure' when the regex engine reaches the decimal dot This makes the expression able to work on any number with or without decimals @iamtheky Am I dreaming or you really did use regex ?
    1 point
  8. Subz

    Finding the latest file

    In the example above you could just use: Local $sLatestFileCreated = _FileVersion(@MyDocumentsDir, "*.xlsx", 1, False) ShellExecute($sLatestFileCreated)
    1 point
  9. That would be cheating. Too easy.
    1 point
  10. In fact, since I am playing around with it (I had completely forgotten doing this one), I would probably do something like this, rather than a ConsoleWrite. Hindsight #include <Array.au3> Local $aProperties[1][2] = [["Name", "Value"]] Local $oRecords, $oPropName, $oPropValue, $iCount = 0 Local $sMSI = FileOpenDialog("MSI Properties", @ScriptDir, "Windows Installer Files (*.msi)") Local $oInstaller = ObjCreate("WindowsInstaller.Installer") Local $oDB = $oInstaller.OpenDataBase($sMSI, 0) Local $oView = $oDB.OpenView("SELECT * FROM Property") $oView.Execute() While @error = 0 $oRecords = $oView.Fetch If Not (IsObj($oRecords)) Then ExitLoop $oPropName = $oRecords.StringData(1) $oPropValue = $oRecords.StringData(2) If $oPropName <> "" Then $iCount += 1 _ArrayAdd($aProperties, $oPropName & "|" & $oPropValue) EndIf WEnd _ArraySort($aProperties, 0, 1) _ArrayDisplay($aProperties)
    1 point
  11. EDIT: just answering the last question without regard to whether or not the output should be a 1D or 2D array. If you liked the output that @iamtheky created and just want it in an array then this should work it assigns the string to a variable that splits the string back into an array using carriage returns with line feeds as the delimiter. #include <array.au3> Local $aArray = [[1, 2, 3], ['', '', ''], [4, 5, 6], [7, 8, 9, 0], ['', '', 'a', 'b'], [''], ['last row first cell']] $newArray=StringSplit(stringstripWS(StringRegExpReplace(_ArrayToString($aArray) , "\|\|+" , " ") , 4),@CRLF) _ArrayDisplay($newArray)
    1 point
  12. Subz

    Finding the latest file

    Here is a simple function to return either an array sorted on the FT.. Flags or Filename #include <Array.au3> #include <File.au3> Local $sLatestFileCreated = _FileVersion(@MyDocumentsDir, "*.xlsx", 1, False) MsgBox(64, "Latest Created File Version", $sLatestFileCreated) Local $aLatestFileCreated = _FileVersion(@MyDocumentsDir, "*.xlsx", 1, True) _ArrayDisplay($aLatestFileCreated) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileVersion ; Description ...: ; Syntax ........: _FileVersion($sFilePath[, $sMask = "*.*"[, $iFlag = 0[, $bFormat = True]]]) ; Parameters ....: $sFilePath - Folder Path to Search ; $sMask - [optional] File Mask. Default is "*.*". ; $iFlag - [optional] Flag to indicate which timestamp ; - $FT_MODIFIED (0) = Last modified (default) ; - $FT_CREATED (1) = Created ; - $FT_ACCESSED (2) = Last accessed ; $bFormat - [optional] To specify type of return ; - True = Retrun an Array (default) ; - False = Return latest Filename for iFlag Type ; Return values .: An array or string ; Author ........: Subz ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _FileVersion($sFilePath, $sMask = "*.*", $iFlag = 0, $bFormat = True) Local $aFileList = _FileListToArrayRec($sFilePath, $sMask, 1, 0, 0, 2) If @error Then Return 0 Local $aFileVersion[0][4] _ArrayAdd($aFileVersion, UBound($aFileList) - 1 & "|Modified|Created|Accessed") For $i = 1 to $aFileList[0] _ArrayAdd($aFileVersion, $aFileList[$i] & "|" & FileGetTime($aFileList[$i], 0, 1) & "|" & FileGetTime($aFileList[$i], 1, 1) & "|" & FileGetTime($aFileList[$i], 2, 1)) Next Switch $iFlag Case 1 _ArraySort($aFileVersion, 1, 1, 0, 2) Case 2 _ArraySort($aFileVersion, 1, 1, 0, 3) Case Else _ArraySort($aFileVersion, 1, 1, 0, 1) EndSwitch Return $bFormat = True ? $aFileVersion : $aFileVersion[1][0] EndFunc
    1 point
  13. Another option is to add the SCI_ANNOTATIONCLEARALL to the user.shortcuts in sciteuser.properties. something like: user.shortcuts=\ Ctrl+?|2547|\ Ctrl+r|IDM_SAVEASRTF|\ Ctrl+Shift+V|IDM_PASTEANDDOWN|\ Ctrl+PageUp|IDM_PREVFILE|\ Ctrl+PageDown|IDM_NEXTFILE|\ Ctrl+Alt+f|IDM_TOGGLE_FOLDALL|\ Ctrl+Alt+x|IDM_TOGGLE_FOLDRECURSIVE|\ Ctrl+F1|IDM_HELP_SCITE| This will make Ctrl+? clear the inline error lines. This requires a restart of SciTE to become active. Jos
    1 point
  14. aleeksunder

    GetWildPath Function

    Hello! I've just finished a function and decided to share it. Maybe you know some better alternatives or can give some advices to optimize it, since finally it completely blows up my brain Function retruns array of paths that match the entire pattern. You pattern can be wild as you wish. Usage: ; Get <any files and folders that matches *.exe> inside <anydrive> \ <anyfolder that match 'W*nd*s'> \ <anyfolder that match 'Sys'> _ArrayDisplay( GetWildPath( '*:\W*nd*s\Sys*\*.exe' ) ) ; Get <anyfolder that match 'W*nd*s'> inside <anydrive> _ArrayDisplay( GetWildPath( '*:\Wind*s' , $FLTA_FOLDERS ) ) ; If pattern begins with '\' function interprets it as _root_ of a working directory's drive or directory passed as 3rd paramter _ArrayDisplay( GetWildPath( '\*Te*\*34.*t*t*' , $FLTA_FOLDERS ) ) ; If pattern not begins with '\' function interprets it as relative path to working directory or directory passed as 3rd paramter _ArrayDisplay( GetWildPath( '*Te*\*3*.*t*' , $FLTA_FILESFOLDERS , 'D:\' ) ) Function itself, maybe a bit hard-coded but as is: #include-once #include <script\autoit\AutoItConstants.au3> #include <script\autoit\StringConstants.au3> #include <script\autoit\File.au3> #include <script\autoit\Array.au3> Func GetWildPath( $s_pattern , $i_flag = $FLTA_FILESFOLDERS , $s_working_directory = @WorkingDir ) $s_working_directory = StringRegExpReplace( $s_working_directory , '[\\/]+$' , '' ) Local $a_split = StringSplit( $s_pattern , ':' ) If Not @error Then $s_drive = $a_split[1] $s_path = $a_split[2] Else $s_drive = StringSplit( $s_working_directory , ':' )[1] $s_path = $a_split[1] EndIf If $s_drive = '*' Then Local $a_drives = DriveGetDrive( $DT_ALL ) Else Local $a_drives[1] $a_drives[0] = _ArrayAdd( $a_drives , $s_drive & ':' ) EndIf Local $a_result = [] For $i_drive = 1 To $a_drives[0] If StringLeft( $s_path , 1 ) = '\' Or StringLeft( $s_path , 1 ) = '/' Then $s_path_root = StringUpper( $a_drives[ $i_drive ] ) & '\' $s_path_relative = StringTrimLeft( $s_path , 1 ) Else $s_path_root = StringUpper( $a_drives[ $i_drive ] ) & StringSplit( $s_working_directory , ':' )[2] $s_path_relative = $s_path EndIf Local $a_path = StringSplit( $s_path_relative , '\/' ) Local $a_final = [] If $a_path[ 0 ] > 1 Then Local $a_relative = _FileListToArray( $s_path_root , $a_path[ 1 ] , $FLTA_FOLDERS , True ) If Not @error Then For $i_path = 2 To $a_path[ 0 ] If $i_path < $a_path[ 0 ] Then Local $a_relative_result = [] For $i_relative = 1 To $a_relative[ 0 ] Local $a = _FileListToArray( $a_relative[ $i_relative ] , $a_path[ $i_path ] , $FLTA_FOLDERS , True ) If Not @error Then _ArrayConcatenate( $a_relative_result , $a , 1 ) EndIf Next $a_relative_result[0] = UBound( $a_relative_result ) - 1 $a_relative = $a_relative_result Else For $i_relative = 1 To $a_relative[0] Local $a = _FileListToArray( $a_relative[ $i_relative ] , $a_path[ $i_path ] , $i_flag , True ) If Not @error Then _ArrayConcatenate( $a_final , $a , 1 ) EndIf Next $a_final[0] = UBound( $a_final ) - 1 EndIf Next EndIf Else Local $a_final = _FileListToArray( $s_path_root , $a_path[ 1 ] , $i_flag , True ) EndIf _ArrayConcatenate( $a_result , $a_final , 1 ) $a_result[0] = UBound( $a_result ) - 1 Next Return $a_result EndFunc Since I'm new to AutoIt all of your comments and ideas are welcome
    1 point
  15. Here's my approach :)... #include <array.au3> Global $path = @ScriptDir Local $file, $sResult, $search = FileFindFirstFile($path & "\*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If Not @extended Or StringRegExp($file, "\D") Then ContinueLoop $sResult &= $path & "\" & $file & ";" WEnd FileClose($search) If $sResult Then $sResult = StringTrimRight($sResult, 1) $aResult = StringSplit($sResult, ";") _ArrayDisplay($aResult) Else MsgBox(0, "Error", "No Digit only Directories found...") EndIf
    1 point
  16. #include <array.au3> Local $aArray = [[1, 2, 3], ['', '', ''], [4, 5, 6], [7, 8, 9, 0], ['', '', 'a', 'b'], [''], ['last row first cell']] msgbox(0 , '' , stringstripWS(StringRegExpReplace(_ArrayToString($aArray) , "\|\|+" , " ") , 4)) yall don't #@$$$%# around nearly enough
    1 point
  17. Using one array is possible For $a = $aFolders[0] to 1 step -1 If StringRegExp($aFolders[$a], "\D") Then _ArrayDelete($aFolders, $a) $aFolders[0] -= 1 EndIf Next _ArrayDisplay($aFolders ) BTW your regex
    1 point
  18. It is no secret that regex makes my eyes bleed, so I am sure someone will venture forth to laugh at my attempt, but I would think you'd have to use two arrays: #include <Array.au3> #include <File.au3> Local $aFolders = _FileListToArray(@DesktopDir & "\Testing", "*", $FLTA_FOLDERS) Local $aFinal[0] For $a = 1 To $aFolders[0] If Not StringRegExp($aFolders[$a], "\D") Then _ArrayAdd($aFinal, $aFolders[$a]) Next _ArrayDisplay($aFinal) This works on a directory that looks like so:
    1 point
  19. #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $hMain = GUICreate("Test", 400, 400) Global $iActiveTimer = TimerInit() GUIRegisterMsg($WM_MOUSEMOVE, WM_MOUSEMOVE) GUIRegisterMsg($WM_KEYDOWN, Active) GUIRegisterMsg($WM_KEYUP, Active) GUIRegisterMsg($WM_LBUTTONDOWN, Active) GUIRegisterMsg($WM_LBUTTONUP, Active) GUIRegisterMsg($WM_RBUTTONDOWN, Active) GUIRegisterMsg($WM_RBUTTONUP, Active) GUIRegisterMsg($WM_MBUTTONDOWN, Active) GUIRegisterMsg($WM_MBUTTONUP, Active) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit 0 Case Else ToolTip("Inactive for " & Round(TimerDiff($iActiveTimer) / 1000, 0) & "s") If (Round(TimerDiff($iActiveTimer) / 1000, 0) >= 5) Then FunctionA() EndSwitch WEnd Func FunctionA() While (Round(TimerDiff($iActiveTimer) / 1000, 0) >= 5) ToolTip("FunctionA()") Sleep(100) WEnd ToolTip("") EndFunc Func Active($hWnd, $iMsg, $wParam, $lParam) $iActiveTimer = TimerInit() EndFunc Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam) Local Static $aLastPos[2] Local $iX = _WinAPI_LoWord($lParam) Local $iY = _WinAPI_HiWord($lParam) If ($iX <> $aLastPos[0] or $iY <> $aLastPos[1]) Then $iActiveTimer = TimerInit() $aLastPos[0] = $iX $aLastPos[1] = $iY EndIf EndFunc Give that a go.
    1 point
  20. GMib

    Sciter Dll UDF !

    Sciter is a HTML/CSS renderer and layout manager. you can make powerfull html gui. you need sciter-x.dll from Sciter SDK you can also download HtmLayout Demo for see lot of exemples of use. (run browse.exe in bin folder and open htm file in html_samples) #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Sciter-Constants.au3> #include-once Global $aHLelementsfound = 0 Global $Sciterdll = 0 Global $SciterRef = 0 Global $HandleWindowsAttachEvent = 0 Global $SciterEvHandler = 0 Global $aHLDOM_error[7] Global $sciterhtml $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 Sciter_UseElement()" $aHLDOM_error[4] = "parameter is invalid, e.g. pointer is null" $aHLDOM_error[5] = "operation failed, e.g. invalid html in SciterSetElementHtml()" $aHLDOM_error[6] = "Dllcall error" ; #FUNCTION# ==================================================================================================== ; Name...........: _StStartup ; Description....: Initialize Sciter ; Syntax.........: _StStartup($dll = "Sciter-x.dll") ; Parameters.....: $dll - Path to sciter DLL [Optional] ; ; Return values..: Success - 1 ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _StStartup($dll = "Sciter-x.dll") ;ok $SciterRef += 1 If $SciterRef > 1 Then Return 1 $Sciterdll = DllOpen($dll) If $Sciterdll = -1 Then Return SetError(1, 0, 0) Return 1 EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StCreate ; Description....: Create Sciter Windows ; Syntax.........: _StCreate($x = 0, $y = 0, $w = 100, $h = 50) ; Parameters.....: $x - [Optional] ; $y - [Optional] ; $w - [Optional] ; $h - [Optional] ; ; Return values..: Success - Sciter window handle. ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _StCreate($x = 0, $y = 0, $w = 100, $h = 50) ;ok If $x = -1 Then $x = @DesktopWidth / 2 - ($w/2) If $y = -1 Then $y = @DesktopHeight / 2 - ($h/2) $result = DllCall($Sciterdll, "wstr", "SciterClassNameW") If @error Then Return 0 $ClassName = $result[0] $SciterHwnd = _WinAPI_CreateWindowEx(BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW ), $ClassName, "", BitOR($WS_VISIBLE,$WS_popup,$WS_CLIPCHILDREN), $x, $y, $w, $h,0) Return $SciterHwnd EndFunc ;==>_StCreateGui ; #FUNCTION# ==================================================================================================== ; Name...........: _StIncGui ; Description....: Create Sciter Windows as child of $ParentGui ; Syntax.........: _StIncGui($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 - Sciter window handle. ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _StIncGui($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50) ;ok $result = DllCall($Sciterdll, "wstr", "SciterClassNameW") If @error Then Return 0 $ClassName = $result[0] $SciterHwnd = _WinAPI_CreateWindowEx(0, $ClassName, "", BitOR($WS_CHILD, $WS_VISIBLE,$WS_CLIPCHILDREN), $x, $y, $w, $h,$ParentGui) Return $SciterHwnd EndFunc ;==>_StIncGui ; #FUNCTION# ==================================================================================================== ; Name...........: _StLoadFile ; Description....: Load HTML file. ; Syntax.........: _StLoadFile($STHwnd, $file) ; Parameters.....: $STHwnd - Sciter window handle. ; $file - File name of an HTML file. ; ; Return values..: Success - 1 ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _StLoadFile($STHwnd, $file) ;ok $result = DllCall($Sciterdll, "BOOL", "SciterLoadFile", "HWND", $STHwnd, "wstr", $file) If @error Then Return 0 Return $result[0] EndFunc ;==>_StLoadFile ; #FUNCTION# ==================================================================================================== ; Name...........: _StLoadHtml ; Description....: Load HTML from memory. ; Syntax.........: _StLoadHtml($STHwnd, $String) ; Parameters.....: $STHwnd - Sciter window handle. ; $String - HTML to load. ; ; Return values..: Success - 1 ; Failure - 0 ; Remarks........: ; =============================================================================================================== Func _StLoadHtml($STHwnd, $String) ;ok $StringSize = StringLen($String) $result = DllCall($Sciterdll, "BOOL", "SciterLoadHtml", "HWND", $STHwnd, "str", $String, "UINT", $StringSize, "str", @ScriptDir) If @error Then Return SetError(@error,0,0) Return 1 EndFunc ;==>_StLoadHtml ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetRootElement ; Description....: Get root DOM element of HTML document. ; Syntax.........: _StGetRootElement($STHwnd) ; Parameters.....: $STHwnd - Sciter 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 _StGetRootElement($STHwnd) ;ok $result = DllCall($Sciterdll, "int", "SciterGetRootElement", "HWND", $STHwnd, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_StGetRootElement ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetElementHtml ; Description....: Get Html of the element. ; Syntax.........: _StGetElementHtml($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 _StGetElementHtml($el, $outer = 1) ;ok $sciterhtml = "" $LPCBYTE_RECEIVER = DllCallbackRegister("SciterByteCallback", "ptr", "str;UINT;ptr") $result = DllCall($Sciterdll, "int", "SciterGetElementHtmlCB", "ptr", $el, "BOOL", $outer, "ptr", DllCallbackGetPtr($LPCBYTE_RECEIVER), "ptr", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) DllCallbackFree($LPCBYTE_RECEIVER) Return $sciterhtml EndFunc Func SciterByteCallback($byte,$num,$prm) $sciterhtml = BinaryToString($byte,4) EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StSetElementHtml ; Description....: Set inner or outer html of the element. ; Syntax.........: _StSetElementHtml($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 _StSetElementHtml($el, $html, $where = 0) ;ok $htmllen = StringLen($html) $result = DllCall($Sciterdll, "int", "SciterSetElementHtml", "ptr", $el, "str", $html, "DWORD", $htmllen, "UINT", $where) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ;==>_StSetElementHtml ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetElementText ; Description....: Get inner text of the element ; Syntax.........: _StGetElementText($el) ; Parameters.....: $el - DOM element handle ; ; Return values..: Success - return text element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _StGetElementText($el) ;ok $sciterhtml = "" $LPCWSTR_RECEIVER = DllCallbackRegister("SciterWSTRCallback", "ptr", "wstr;UINT;ptr") $result = DllCall($Sciterdll, "int", "SciterGetElementTextCB", "ptr", $el, "ptr", DllCallbackGetPtr($LPCWSTR_RECEIVER), "ptr", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) DllCallbackFree($LPCWSTR_RECEIVER) Return $sciterhtml EndFunc Func SciterWSTRCallback($wstr,$num,$prm) $sciterhtml = $wstr EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StSetElementText ; Description....: Set inner text of the element. ; Syntax.........: _StSetElementText($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 _StSetElementText($el, $String) ;ok $len = StringLen($String) $result = DllCall($Sciterdll, "int", "SciterSetElementText", "ptr", $el, "wstr", $String, "UINT", $len) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ;==>_StSetElementText ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetChildrenCount ; Description....: Get number of child elements. ; Syntax.........: _StGetChildrenCount($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 _StGetChildrenCount($el) ;ok $result = DllCall($Sciterdll, "int", "SciterGetChildrenCount", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_StGetChildrenCount ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetFocusElement ; Description....: Get focused DOM element of HTML document. ; Syntax.........: _StGetFocusElement($hwnd) ; Parameters.....: $hwnd - Sciter windows handle ; ; Return values..: Success - Return focus element or 0 if no focus ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: To set focus on element use _StSetElementState($el, $STATE_FOCUS,0) ; =============================================================================================================== Func _StGetFocusElement($hwnd) ;ok $result = DllCall($Sciterdll, "int", "SciterGetFocusElement", "HWND", $hwnd, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetElementState ; Description....: Get state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3" ; Syntax.........: _StGetElementState($el) ; Parameters.....: $el - Dom element handle ; ; Return values..: Success - Return Statebits ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _StGetElementState($el) ;ok $result = DllCall($Sciterdll, "int", "SciterGetElementState", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StSetElementState ; Description....: Set state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3" ; Syntax.........: _StSetElementState($el, $stateToSet, $stateToClear = 0, $upt = 1) ; Parameters.....: $el - Dom handle element ; $stateToSet - ; $stateToClear - [Optional] ; $upt - [Optional] ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _StSetElementState($el, $stateToSet, $stateToClear = 0, $upt = 1) $result = DllCall($Sciterdll, "int", "SciterSetElementState", "ptr", $el, "UINT", $stateToSet, "UINT", $stateToClear, "BOOL", $upt) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetNthChild ; Description....: Get handle of Nth child element. ; Syntax.........: _StGetNthChild($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 _StGetNthChild($el, $nth) ;ok $result = DllCall($Sciterdll, "int", "SciterGetNthChild", "ptr", $el, "UINT", $nth-1, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_StGetNthChild ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetParentElement ; Description....: Get parent element. ; Syntax.........: _StGetParentElement($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 _StGetParentElement($el) ;ok $result = DllCall($Sciterdll, "int", "SciterGetParentElement", "ptr", $el, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_StGetParentElement ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetAttributeCount ; Description....: Get number of element's attributes. ; Syntax.........: _StGetAttributeCount($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 _StGetAttributeCount($el) ;ok $result = DllCall($Sciterdll, "int", "SciterGetAttributeCount", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_StGetAttributeCount ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetNthAttribute ; Description....: Get value of any element's attribute by attribute's number. ; Syntax.........: _StGetNthAttribute($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 _StGetNthAttribute($el, $nth);ok $result = DllCall($Sciterdll, "int", "SciterGetNthAttribute", "ptr", $el, "UINT", $nth, "str*", "", "wstr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Dim $aRet[2] $aRet[0] = $result[3] $aRet[1] = $result[4] Return $aRet EndFunc ;==>_StGetNthAttribute ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetAttributeByName ; Description....: Get value of any element's attribute by name. ; Syntax.........: _StGetAttributeByName($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 _StGetAttributeByName($el, $AttName);ok $result = DllCall($Sciterdll, "int", "SciterGetAttributeByName", "ptr", $el, "str", $AttName, "wstr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_StGetAttributeByName ; #FUNCTION# ==================================================================================================== ; Name...........: _StSetAttributeByName ; Description....: Set attribute's value. ; Syntax.........: _StSetAttributeByName($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 _StSetAttributeByName($el, $AttName, $value) ;ok $result = DllCall($Sciterdll, "int", "SciterSetAttributeByName", "ptr", $el, "str", $AttName, "wstr", $value) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ;==>_StSetAttributeByName ; #FUNCTION# ==================================================================================================== ; Name...........: _StClearAttributes ; Description....: Remove all attributes from the element. ; Syntax.........: _StClearAttributes($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 _StClearAttributes($el) ;ok $result = DllCall($Sciterdll, "int", "SciterClearAttributes", "ptr", $el) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ;==>_StClearAttributes ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetElementIndex ; Description....: Get element index. ; Syntax.........: _StGetElementIndex($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 _StGetElementIndex($el) ;ok $result = DllCall($Sciterdll, "int", "SciterGetElementIndex", "ptr", $el, "UINT*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_StGetElementIndex ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetElementType ; Description....: Get element's type. ; Syntax.........: _StGetElementType($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........: For <div> return will be set to "div". ; =============================================================================================================== Func _StGetElementType($el) ;ok $result = DllCall($Sciterdll, "int", "SciterGetElementType", "ptr", $el, "str*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[2] EndFunc ;==>_StGetElementType ; #FUNCTION# ==================================================================================================== ; Name...........: _StGetStyleAttribute ; Description....: Get element's style attribute. ; Syntax.........: _StGetStyleAttribute($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 _StGetStyleAttribute($el, $StyleName);ok $result = DllCall($Sciterdll, "int", "SciterGetStyleAttribute", "ptr", $el, "str", $StyleName, "wstr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_StGetStyleAttribute ; #FUNCTION# ==================================================================================================== ; Name...........: _StSetStyleAttribute ; Description....: Set element's style attribute. ; Syntax.........: _StSetStyleAttribute($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 _StSetStyleAttribute($el, $StyleName, $StyleValue);ok $result = DllCall($Sciterdll, "int", "SciterSetStyleAttribute", "ptr", $el, "str", $StyleName, "wstr", $StyleValue) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ;==>_StSetStyleAttribute ; #FUNCTION# ==================================================================================================== ; Name...........: _StCreateElement ; Description....: Create new element, the element is disconnected initially from the DOM. ; Syntax.........: _StCreateElement($tag, $txt = "") ; Parameters.....: $tag - html tag of the element e.g. "div", "option", etc. ; $txt - initial text of the element or "". text here is a plain text. [Optional] ; ; Return values..: Success - Return handle of element ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: ; =============================================================================================================== Func _StCreateElement($tag, $txt = "");ok If $txt <> "" Then $result = DllCall($Sciterdll, "int", "SciterCreateElement", "str", $tag, "wstr", $txt, "ptr*", "") Else $result = DllCall($Sciterdll, "int", "SciterCreateElement", "str", $tag, "ptr", "", "ptr*", "") EndIf If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[3] EndFunc ;==>_StCreateElement ; #FUNCTION# ==================================================================================================== ; Name...........: _StInsertElement ; Description....: Insert element at index position of parent. ; Syntax.........: _StInsertElement($el, $elparent, $index) ; Parameters.....: $el - Handle element ; $elparent - Handle element of parent ; $index - position of the element in parent collection. ; ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: It is not an error to provide index greater than elements count in parent - it will be appended. ; =============================================================================================================== Func _StInsertElement($el, $elparent, $index);ok $result = DllCall($Sciterdll, "int", "SciterInsertElement", "ptr", $el, "ptr", $elparent, "UINT", $index) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StSelectElements ; Description....: Return Array of elements in a DOM that meets specified CSS selectors. ; Syntax.........: _StSelectElements($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/Sciter/selectors.whtm ; =============================================================================================================== Func _StSelectElements($el, $CssSel);ok $handle = DllCallbackRegister("StElementsCallback", "BOOL", "ptr;ptr") Dim $aHLelementsfound[1] $result = DllCall($Sciterdll, "int", "SciterSelectElementsW", "ptr", $el, "wstr", $CssSel, "ptr", DllCallbackGetPtr($handle), "ptr", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) DllCallbackFree($handle) $HLelementsCount = UBound($aHLelementsfound) If $HLelementsCount = 1 Then Return 0 $aHLelementsfound[0] = $HLelementsCount-1 Return $aHLelementsfound EndFunc ;==>_StSelectElements Func StElementsCallback($el, $param) Local $iUBound = UBound($aHLelementsfound) ReDim $aHLelementsfound[$iUBound + 1] $aHLelementsfound[$iUBound] = $el EndFunc ;==>_StElementsCallback ; #FUNCTION# ==================================================================================================== ; Name...........: _StSelectParent ; Description....: Find parent of the element by CSS selector. ; Syntax.........: _StSelectParent($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 _StSelectParent($el, $CssSel, $depth = 0) ;ok $result = DllCall($Sciterdll, "int", "SciterSelectParentW", "ptr", $el, "wstr", $CssSel, "UINT", $depth, "ptr*", "") If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return $result[4] EndFunc ;==>_StSelectParent ; #FUNCTION# ==================================================================================================== ; Name...........: _StDeleteElement ; Description....: Delete element. ; Syntax.........: _StDeleteElement($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 _StDeleteElement($el) $result = DllCall($Sciterdll, "int", "SciterDeleteElement", "ptr", $el) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) Return 1 EndFunc ;==>_StDeleteElement ;~ EXTERN_C HLDOM_RESULT HLAPI SciterShowPopup (HELEMENT hePopup, HELEMENT heAnchor, UINT placement) ;~ Shows block element (DIV) in popup window. ;~ Func _StShowPopup($Sciterdll, $el, $anchor, $placement) ;~ $result = DllCall($Sciterdll, "int", "SciterShowPopup", "ptr", $el, "ptr", $anchor, "UINT", $placement) ;~ If @error Then Return 0 ;~ Return 1 ;~ EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _StWindowAttachEventHandler ; Description....: Attach/Detach ElementEventProc to the Sciter window. ; Syntax.........: _StWindowAttachEventHandler($hwnd, $func, $events) ; Parameters.....: $hwnd - HWND of Sciter windows ; $func - Function to receive events (need two params eg: $func($ev, $arrayparam) ; $events - Events you want receive (see remarks) ; 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. ;~ $HANDLE_METHOD_CALL : behavior specific methods ;~ $HANDLE_EXCHANGE : system drag-n-drop events ;~ $HANDLE_ALL : all of them ; Return values..: Success - Return 1 ; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details) ; Remarks........: For Uppercase type see "Sciter-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 _StWindowAttachEventHandler($hwnd, $func, $events) $HandleWindowsAttachEvent = DllCallbackRegister("HLEvHandler", "BOOL", "ptr;ptr;UINT;ptr") $result = DllCall($Sciterdll, "int", "SciterWindowAttachEventHandler", "HWND", $hwnd, "ptr", DllCallbackGetPtr($HandleWindowsAttachEvent), "ptr", "", "UINT", $DISABLE_INITIALIZATION+$events) If @error Then Return SetError(6,0,-1) If $result[0] <> 0 Then Return SetError($result[0],0,-1) $SciterEvHandler = $func Return 1 EndFunc ;==>_StWindowAttachEventHandler Func HLEvHandler($tag,$el,$ev,$prm) $ap = -1 $a = DllStructCreate("UINT cmd", $prm) $cmd = DllStructGetData($a, "cmd") $a = 0 If $cmd > 32768 Then Return 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 Execute ($SciterEvHandler&"("&$ev&",$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 changelog : 0.2 : Add _StDebug() for display css/html error in scite console. Correct some error in Sciter-constants Add taskbar and title param in _StCreate Add skin gui exemple 0.1 : First releaseCalltips: _StStartup ($dll = "Sciter-x.dll") Initialize Sciter (required: #include <Sciter-UDF.au3>) _StCreate ($x = 0, $y = 0, $w = 100, $h = 50) Create Sciter Windows (required: #include <Sciter-UDF.au3>) _StIncGui ($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50) Create Sciter Windows as child of $ParentGui (required: #include <Sciter-UDF.au3>) _StLoadFile ($STHwnd, $file) Load HTML file. (required: #include <Sciter-UDF.au3>) _StLoadHtml ($STHwnd, $String) Load HTML from memory. (required: #include <Sciter-UDF.au3>) _StGetRootElement ($STHwnd) Get root DOM element of HTML document. (required: #include <Sciter-UDF.au3>) _StGetElementHtml ($el, $outer = 1) Get Html of the element. (required: #include <Sciter-UDF.au3>) _StSetElementHtml ($el, $html, $where) Set inner or outer html of the element. (required: #include <Sciter-UDF.au3>) _StGetElementText ($el) Get inner text of the element (required: #include <Sciter-UDF.au3>) _StSetElementText ($el, $String) Set inner text of the element. (required: #include <Sciter-UDF.au3>) _StGetChildrenCount ($el) Get number of child elements. (required: #include <Sciter-UDF.au3>) _StGetFocusElement ($hwnd) Get focused DOM element of HTML document. (required: #include <Sciter-UDF.au3>) _StGetElementState ($el) Get state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3" (required: #include <Sciter-UDF.au3>) _StSetElementState ($el, $stateToSet, $stateToClear = 0, $upt = 1) Set state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3" (required: #include <Sciter-UDF.au3>) _StGetNthChild ($el, $nth) Get handle of Nth child element. (required: #include <Sciter-UDF.au3>) _StGetParentElement ($el) Get parent element. (required: #include <Sciter-UDF.au3>) _StGetAttributeCount ($el) Get number of element's attributes. (required: #include <Sciter-UDF.au3>) _StGetNthAttribute ($el, $nth) Get value of any element's attribute by attribute's number. (required: #include <Sciter-UDF.au3>) _StGetAttributeByName ($el, $AttName) Get value of any element's attribute by name. (required: #include <Sciter-UDF.au3>) _StSetAttributeByName ($el, $AttName, $value) Set attribute's value. (required: #include <Sciter-UDF.au3>) _StClearAttributes ($el) Remove all attributes from the element. (required: #include <Sciter-UDF.au3>) _StGetElementIndex ($el) Get element index. (required: #include <Sciter-UDF.au3>) _StGetElementType ($el) Get element's type. (required: #include <Sciter-UDF.au3>) _StGetStyleAttribute ($el, $StyleName) Get element's style attribute. (required: #include <Sciter-UDF.au3>) _StSetStyleAttribute ($el, $StyleName, $StyleValue) Set element's style attribute. (required: #include <Sciter-UDF.au3>) _StCreateElement ($tag, $txt = "") Create new element, the element is disconnected initially from the DOM. (required: #include <Sciter-UDF.au3>) _StInsertElement ($el, $elparent, $index) Insert element at index position of parent. (required: #include <Sciter-UDF.au3>) _StSelectElements ($el, $CssSel) Return Array of elements in a DOM that meets specified CSS selectors. (required: #include <Sciter-UDF.au3>) _StSelectParent ($el, $CssSel, $depth = 0) Find parent of the element by CSS selector. (required: #include <Sciter-UDF.au3>) _StDeleteElement ($el) Delete element. (required: #include <Sciter-UDF.au3>) _StWindowAttachEventHandler ($hwnd, $func, $events) Attach/Detach ElementEventProc to the Sciter window. (required: #include <Sciter-UDF.au3>)Sciter-UDF.7z
    1 point
  21. View --> Toogle all ... Mega
    1 point
×
×
  • Create New...