Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 05/11/2024 in Posts

  1. Here is the final reworked script taking care of UTF-8 encoding, so cyrillic characters shouldn't be a problem anymore. Now that all original text is always converted to UTF-8 (no matter they were Ascii characters, Ansi, Unicode, mix) then my initial issue with end of lines has disappeared as EOL's will be restored correctly at their right place, when the translation is done (no more workaround !) I notice the script needs the last version of AutoIt (because of Maps in Json.au3) Though some translations will work with older versions of AutoIt (because Maps aren't always used during translation, depending on the original text), it's better to use last version of AutoIt (3.3.16.1) to cover all cases. @AspirinJunkie I would like to know : this is what is found in your version of Json.au3 I found on the net : ; Title .........: JSON-UDF ; Version .......: 0.9 ; AutoIt Version : 3.3.16.1 ... ; Author(s) .....: AspirinJunkie ; Last changed ..: 2023-01-16 In case there is a newer version, could you please indicate where it can be downloaded ? Thanks to everybody involved in this script #include "Json.au3" ; (by @AspirinJunkie) #include <StringConstants.au3> ;======================== Local $sLangFROM = "auto" Local $sLangTO = "en" ; <===== change this line for the language of the translated text ;======================== Local $sInput, $sClipGet = StringToBinary(ClipGet(), $SB_UTF8) ; for example л (russian) becomes 0xD0BB For $i = 3 To StringLen($sClipGet) Step 2 ; start at 3 to bypass "0x" $sInput &= "%" & StringMid($sClipGet, $i, 2) Next Local $sTranslated = _GoogleAPITranslate($sInput, $sLangFROM, $sLangTO) ; If (Not @compiled) And ProcessExists("scite.exe") Then ; not 100% proof to bypass the 3 following ConsoleWrite, but better than nothing. If Not @compiled Then ; probably a bit faster than preceding line. It will be enough when script run from .a3x shortcut placed on Desktop. ConsoleWrite("ORIGINAL: " & BinaryToString($sClipGet, $SB_ANSI) & @crlf) ; in case of accented characters in Scite console. ConsoleWrite("----------------------------------------------------------------------------------------------------------------" & @crlf) ConsoleWrite(BinaryToString(StringToBinary($sTranslated, $SB_UTF8), $SB_ANSI) & @crlf) EndIf MsgBox(262144, "Translated From " & $sLangFROM & " To " & $sLangTO, $sTranslated) ; $MB_TOPMOST = 262144 ;============================================== Func _GoogleAPITranslate($sMytext, $sFrom, $sTo) Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $sUrl, False) $oHTTP.Send() $sResponse = $oHTTP.ResponseText $JSONData = _JSON_Parse($sResponse) If VarGetType($JSONData) = 'Array' Then $aData = $JSONData[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 $sOutput &= ($aData[$i])[0] Next EndIf EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate * Update May 11, 2024 : Added a test on @compiled to bypass (or not) all ConsoleWrite lines and the functions included in them. Though it's not 100% proof, it's better than nothing. Other ways to detect more precisely how the script was launched can be found on the Forum, for example by using _WinAPI_GetParentProcess and _WinAPI_GetProcessName, but do we really need all this just to bypass 3 ConsoleWrite lines ? Let's test on @compiled for the moment, we'll see...
    3 points
  2. The current version actually has a higher date in the comment. But this is also wrong 😉 - I obviously overlooked the date and didn't always adjust it. The current version can always be found in the github repository: https://github.com/Sylvan86/autoit-json-udf The last change there was on 21 February 2024.
    2 points
  3. In fact it's not that hard to translate from russian to english with the script. You just need to prepare a UTF-8 input string that the google api translator will recognize, for example with these few lines of script : #include <StringConstants.au3> Local $sInput, $sClipGet = StringToBinary(ClipGet(), $SB_UTF8) ; л (russian) becomes 0xD0BB For $i = 3 To StringLen($sClipGet) Step 2 ; forget "0x" at beginning $sInput &= "%" & StringMid($sClipGet, $i, 2) Next ConsoleWrite("ClipGet() = " & BinaryToString($sClipGet, $SB_ANSI) & @crlf & @crlf) ConsoleWrite("$sClipGet = " & $sClipGet & @crlf & @crlf) ConsoleWrite("$sInput = " & $sInput & @crlf) AutoIt console : ClipGet() = а если подумать в 99,9999999999% случаев $sClipGet = 0xD0B020D0B5D181D0BBD0B820D0BFD0BED0B4D183D0BCD0B0D182D18C2020D0B22039392C393939393939393939392520D181D0BBD183D187D0B0D0B5D0B2 $sInput = %D0%B0%20%D0%B5%D1%81%D0%BB%D0%B8%20%D0%BF%D0%BE%D0%B4%D1%83%D0%BC%D0%B0%D1%82%D1%8C%20%20%D0%B2%20%39%39%2C%39%39%39%39%39%39%39%39%39%39%25%20%D1%81%D0%BB%D1%83%D1%87%D0%B0%D0%B5%D0%B2 Then you use the variable $sInput for the google api translator, it will translate correctly : Same result as translating with the Browser, yes ! I'll have to rework a bit the original script to integrate in it these new lines of script.
    2 points
  4. @Melba23 & @Nine Deleting the menu control seems to do the job. It will position to the very left of the GUI all existing menuitem(s) control(s) . Does this work for you ? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $mDummymenu = GUICtrlCreateMenu("this menu control will be deleted") $menu1 = GUICtrlCreateMenuItem("click me", -1) $menu2 = GUICtrlCreateMenuItem("click me again", -1) GUICtrlDelete($mDummymenu) ; <====================== GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox($MB_TOPMOST ,'yes!', 'it works') Case $menu2 MsgBox($MB_TOPMOST,'yes!', 'it works again') EndSwitch WEnd
    2 points
  5. How can you be so sure, "findDuck" and translating the Vietnamese "Mother Duck has been found" and "Mother duck could not be found", but the code doesnt include any ducks to be found, it looks with pixelsearch to find some Ducks somewhere else.
    1 point
  6. I think that there are many types of first file. I think you need to specify the type of sorting you require then we can determine the first file sorted in such a way.
    1 point
  7. @rsnYou are right! Running my test with your tip, I used the wrong working directory. That's why it was failing. Rerunning the test with your piece of code succesfully, I decided to look at my code and find out that @tempdir was not working in my code I can now finish my "restart print spooler" tool for my users. Thanks for your help (and ofcourse all others who pitched in)
    1 point
  8. I took a quick look at the AutoIt part of the CEF code. the V8 engine has a eval function, so it is possible to inject JavaScript into the page. But i could not see any easy way to communicate to AutoIt from the JavaScript side, and that might be a deal breaker. Exactly right, i wanted to have easy UI and all computers have a browser that can handle all that AutoIt only handles the HTTP requests and au3 or PHP scripts (depending on how it is setup) No worries Your wish for a simple way to define styled windows and controls is something I am periodically looking into and have a few projects trying to solve this in different ways (most not yet ready for use). My HTTP server is one of them, and my Manga server project was a proof of concept
    1 point
  9. It's kinda simple. All arguments of a function are separated by a comma. Even if a variable is an array and contains multiple data it doesn't mean that when this variable it's passed to a function it takes up more than a single parameter. See example below: $Int = 48 $String = "This is a test" Dim $Array[3] = ["I can hold multiple data", "But I am a single variable", "And I am passed as a single parameter to a function"] Test($Int, $String, $Array) Func Test($Param1, $Param2, $Param3) ConsoleWrite(VarGetType($Param1) & @CRLF) ConsoleWrite(VarGetType($Param2) & @CRLF) ConsoleWrite(VarGetType($Param3) & @CRLF) EndFunc
    1 point
  10. No. These are dimensions of an array not arguments of a function.
    1 point
  11. In first example you are calling Clicking with a single parameter and below your function has at least 2 mandatory parameters ($x, $y) out of 4 parameters. Isn't this self explanatory? If you want to use the first example then your function should look like this: Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] Clicking($aClicks) Func Clicking($aClicks) ; Your code here EndFunc Or if you want to preserve your original function with 4 parameters you can do something like this: Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] ClickingArray($aClicks) Func ClickingArray($aClicks) For $Index = 0 To UBound($aClicks) - 1 Clicking($aClicks[$Index][0], $aClicks[$Index][1], $aClicks[$Index][2], $aClicks[$Index][3]) Next EndFunc Func Clicking($x, $y, $s = "", $z = 1000) ; Your original function EndFunc
    1 point
  12. @Jemboy The user you created and assigned permissions to control the spooler doesn't have to be in the administrators group. By not being in that group it adds the advantage of not being able to control any other service or admin level processes. And your script wouldn't need #RequireAdmin either. I'll run a couple extra tests today just in case I'm talking out of my butt I ran some tests. I created a local non-admin user and assigned Full Control to the spooler: Then ran the following: #include <AutoItConstants.au3> RunAs ( "testuser" , "." , "password" , $RUN_LOGON_NOPROFILE , @ComSpec & " /k sc.exe stop spooler" , "C:\windows\system32" , @SW_SHOWDEFAULT ) And the service stopped You can use any method you want but I chose SC.exe for simplicity in this example.
    1 point
  13. Bet it does. But I need to interact with a site and fake a user working in it. Nowadays the source loads a boatload of JS scripts and that is the page instead of the html in the source. Welcome to the future
    1 point
  14. ... ConsoleWrite(@CRLF & '--- >' & _WD_GetSource($__g_sSession) & '< ---' & @CRLF & @CRLF) ... That did it.
    1 point
  15. I used Sciter several times. You can make interesting user interfaces but it doesn't support all modern CSS. I am interested also to find a new way to embed a web application in a GUI without installing too many third party software.
    1 point
  16. Hi @SOLVE-SMART. The AutoIt-HTTP-Server will only work as a backend, but should be able to be used with CEF with no problem, i would think But depending on when CEF allows in terms of API with AutoIt, it may be sufficient just to inject HTML and JavaScript, and observe events or changes. I have never used CEF, and have not made a deep dive, so it would depend on how well AutoIt can interact with the Chrome instance created.
    1 point
  17. Make a server ? ( https://www.autoitscript.com/forum/topic/201673-json-http-post-serverlistener/page/2/#comment-1447447 ) Then with your own API do as you please. The server runs with your full admin rights. That would solve your problem.
    1 point
  18. Thanks for having a look and making a much cleaner and time saving version! Sadly it can't be used on conjunction with the GUI generators, but maybe that's just part of the limitation with the auto generated stuff and using both simply isn't an option.
    1 point
  19. #Region (=== GUI generated by argumentum 0.0.0.1 ===) Global $hGUI Global $Radio_1, $Radio_2, $Radio_3, $Group_1 Local $PosX Local $PosY_add = 25 Local $PosY_counter = 0 Local $PosY_Start = 85 ;------------------------------------------------------ ; Title...........: _guiCreate ; Description.....: Create the main GUI ;------------------------------------------------------ _guiCreate("MyGUI", 400, 350) Func _guiCreate($sTitle, $iWidth, $iHeight, $iLeft = -1, $iTop = -1) $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop) Local $idTemp For $n = 1 To 3 $idTemp = GUICtrlCreateRadio("Radio " & String($PosY_counter + 1), 160, $PosY_Start + $PosY_add * $PosY_counter, 91, 20) Assign("Radio_" & $PosY_counter + 1, $idTemp) $PosY_counter += 1 Next $Group_1 = GUICtrlCreateGroup("Group 1", 115, 55, 151, 151) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState() EndFunc ;==>_guiCreate #EndRegion (=== GUI generated by argumentum 0.0.0.1 ===) While 1 Switch GUIGetMsg() Case -3 GUIDelete() Exit Case $Radio_1 MsgBox(0, "", "$Radio_1", 1, $hGUI) Case $Radio_2 MsgBox(0, "", "$Radio_2", 1, $hGUI) Case $Radio_3 MsgBox(0, "", "$Radio_3", 1, $hGUI) EndSwitch WEnd I don't use anything other than my wish. No code generator.
    1 point
  20. donnyh13

    Understanding libraries

    Since those are built in AutoIt Libraries they are located in the install directory of AuotIt, for me it is: "C:\Program Files (x86)\AutoIt3\Include" , and if you have Scite editor installed, you can click on one of them so that your cursor is blinking in it, and press the button combo Alt+i to open the include, so you can see each of the functions inside, and how they work, but the better bet, perhaps, would be to look at the help file for each function used in the script, which you can easily open by placing your caret in the function name in question, and pressing F1 to open the help file for the function. Or just press F1 and use the built in search. As for adding Webdriver, you would do something like: #include "Path to WebDriverUDF\Webdriver udf File.au3" More info about #Include (also found in the AutoIt help file): https://www.autoitscript.com/autoit3/docs/keywords/include.htm
    1 point
  21. 1 point
  22. Here is a new version of the script, which outputs the translated text to an Edit control. Although the preceding version displayed the output in a MessageBox (and in Scite Console if run from Scite); it seems better to output the translated text to an Edit control. Advantages are : * If it's a very long text, then the MessageBox will not display it entirely (and its 'Ok' button won't show) * We can't copy-paste the translated text from a MessageBox (if we want to keep it) Here is an example of output in the Edit control, in its original GUI size (900 x 600) . The Gui can be maximized & resized. The Edit control can have its text wrapped or not (an eventual selection will be preserved when switching from Wrap to No Wrap) . Native scrollbars should work nicely in both cases (wrap / no wrap) . This example is the translation from a part of the AutoIt german introduction found in this webpage, copied to clipboard, then translated in english with the script below : #include "Json.au3" ; (by @AspirinJunkie) #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <StringConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_idEdit, $g_iGui_W = 900, $g_iGui_H = 600 ;======================== Local $sLangFROM = "auto" Local $sLangTO = "en" ; <===== change this line for the language of the translated text ;======================== Local $sInput, $sClipGet = StringToBinary(ClipGet(), $SB_UTF8) ; for example л (russian) becomes 0xD0BB For $i = 3 To StringLen($sClipGet) Step 2 ; start at 3 to bypass "0x" $sInput &= "%" & StringMid($sClipGet, $i, 2) Next Local $sTranslated = _GoogleAPITranslate($sInput, $sLangFROM, $sLangTO) If Not @compiled Then ConsoleWrite("ORIGINAL: " & BinaryToString($sClipGet, $SB_ANSI) & @crlf) ; in case of accented characters in Scite console. ConsoleWrite("----------------------------------------------------------------------------------------------------------------" & @crlf) ConsoleWrite(BinaryToString(StringToBinary($sTranslated, $SB_UTF8), $SB_ANSI) & @crlf) EndIf ; MsgBox(262144, "Clipboard translated From " & $sLangFROM & " To " & $sLangTO, $sTranslated) ; $MB_TOPMOST = 262144 _OutputInGui($sTranslated, $sLangFROM, $sLangTO) ;============================================== Func _GoogleAPITranslate($sMytext, $sFrom, $sTo) Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $sUrl, False) $oHTTP.Send() $sResponse = $oHTTP.ResponseText $JSONData = _JSON_Parse($sResponse) If VarGetType($JSONData) = 'Array' Then $aData = $JSONData[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 $sOutput &= ($aData[$i])[0] Next EndIf EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate ;=============================================================== Func _OutputInGui(Const ByRef $sTranslated, $sLangFROM, $sLangTO) $g_hGUI = GUICreate("Clipboard translated From " & $sLangFROM & " To " & $sLangTO, $g_iGui_W, $g_iGui_H, -1, -1, $WS_OVERLAPPEDWINDOW) _EditRecreate($sTranslated, True) ; True = word wrap (keep it True here, to match with the initial checked Menu item "Word Wrap") ; Menu Format Local $idFormatMenu = GUICtrlCreateMenu("F&ormat") ; Create the Format menu. Underline o when Alt is pressed. Local $idFormatMenu_WordWrap = GUICtrlCreateMenuItem("&Word Wrap" &@TAB& "", $idFormatMenu) ; Create the "Word Wrap" menu item. Underline W when Alt is pressed. GUICtrlSetState(-1, $GUI_CHECKED) GUISetState(@SW_SHOW, $g_hGUI) _GUICtrlEdit_SetSel($g_idEdit, -1, 0) ; deselects only when placed AFTER GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idFormatMenu_WordWrap _WordWrap($sTranslated, $idFormatMenu_WordWrap) EndSwitch WEnd EndFunc ;==>_OutputInGui ;============================================================== Func _WordWrap(Const ByRef $sTranslated, $idFormatMenu_WordWrap) If BitAND(GUICtrlRead($idFormatMenu_WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then ; turn off Word Wrap _EditRecreate($sTranslated, False) ; False = no Word Wrap GUICtrlSetState($idFormatMenu_WordWrap, $GUI_UNCHECKED) ; uncheck Word Wrap Else ; turn on Word Wrap _EditRecreate($sTranslated, True) ; True = Word Wrap GUICtrlSetState($idFormatMenu_WordWrap, $GUI_CHECKED) ; turn on Word Wrap and show checked EndIf EndFunc ;==>_WordWrap ;====================================================== Func _EditRecreate(Const ByRef $sTranslated, $bWordWrap) Local $idEdit_Old = $g_idEdit ; 0 at first passage If $idEdit_Old Then Local $aPos = ControlGetPos($g_hGUI, "", $idEdit_Old) Else ; 1st passage Local $aPos[4] = [20, 20, $g_iGui_W - 40, $g_iGui_H - 60] EndIf $g_idEdit = GUICtrlCreateEdit("", $aPos[0], $aPos[1], $aPos[2], $aPos[3], ($bWordWrap _ ? BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) _ : -1)) ; control ID ; GUICtrlSetFont(-1, 10, 400, 0, "Courier New") ; change default font GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") ; seems better than Courier New If $idEdit_Old Then _GUICtrlEdit_SetText($g_idEdit, GUICtrlRead($idEdit_Old)) Local $aSel = _GUICtrlEdit_GetSel($idEdit_Old) GUICtrlDelete($idEdit_Old) _GUICtrlEdit_SetSel($g_idEdit, $aSel[0], $aSel[1]) Else ; 1st passage _GUICtrlEdit_SetText($g_idEdit, $sTranslated) EndIf EndFunc ;==>_EditRecreate If you want the output to be displayed first in MessageBox, then in Edit control (really ?) then uncomment the MessageBox line in the script : ; MsgBox(262144, "Clipboard translated From " & $sLangFROM & " To " & $sLangTO, $sTranslated) ; $MB_TOPMOST = 262144 _OutputInGui($sTranslated, $sLangFROM, $sLangTO) Happy translations ! * Update May 15, 2024 : changed Font in Edit control (Lucida Console seems better than Courier New) Next update should indicate which language Google used for translation, when we indicated "auto" as Language From. Maybe they will be other updates as I got some ideas
    1 point
  23. sorry, Just now I get it, and I got it I am fuse... Thanks
    1 point
  24. Or you may want to try with WMI : #RequireAdmin #include <Constants.au3> #include <Array.au3> ; https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-service Opt("MustDeclareVars", 1) CheckService(@ComputerName, "Spooler") ; or replace with name of computer you can remotely access Func CheckService($sName, $sService) Local $oWMIService = ObjGet("winmgmts:\\" & $sName & "\root\CIMV2") Local $oItems = $oWMIService.ExecQuery('SELECT * FROM Win32_Service WHERE Name = "' & $sService & '"') If Not IsObj($oItems) Then Exit MsgBox($MB_OK, "Error", "Not an object") If Not $oItems.count Then Exit MsgBox($MB_OK, "Error", "Service not found") Local $aService[$oItems.count][5], $i = 0 For $oItem In $oItems $aService[$i][0] = $oItem.Caption $aService[$i][1] = $oItem.Started $aService[$i][2] = $oItem.StartMode $aService[$i][3] = $oItem.State $aService[$i][4] = $oItem.Status $i += 1 Next _ArrayDisplay ($aService) Local $oService = $oItems.itemIndex(0) ;$oService.StopService() ;$oService.StartService () EndFunc ;==>_CheckService
    1 point
  25. Nine

    AutoIt3 syntax mania

    If running from full Scite, you need to add : #AutoIt3Wrapper_Run_Au3Check=n
    1 point
  26. Werty

    AutoIt3 syntax mania

    Yes, 3.3.16.1, outputs "AU3" in the console. SciTE Lite is silent, dont know about full SciTE.
    1 point
  27. Thank you @Andreik 👌 , for that function. I extented the $aData Array a litte bit by some 04, 004, etc. entries and I share the result (as screenshot), or better the comparison of _ArraySort and NaturalCompare for the community here. Just to give a better understanding what's the effect/difference 😇 . Local $aData = StringSplit('2|3|4|4 Part|7|8|9|12|13|004 Part|15|0004|04|4|004|21|28|31|35|OB1|NORTH|SOUTH|BORDER|3 Part|4 Past', '|', 2) Best regards Sven
    1 point
  28. Something like this? #include <Array.au3> Local $aData = StringSplit('2|3|4|4 Part|7|8|9|12|13|15|21|28|31|35|OB1|NORTH|SOUTH|BORDER|3 Part|4 Past', '|', 2) NaturalCompare($aData) _ArrayDisplay($aData) Func NaturalCompare(ByRef $aData) Local $vTemp, $i, $j Local $hDll = DllOpen('Shlwapi.dll') For $i = 1 To UBound($aData) - 1 $j = $i While $j > 0 And DllCall($hDll, "int", "StrCmpLogicalW", "wstr", $aData[$j-1], "wstr", $aData[$j])[0] <> -1 $vTemp = $aData[$j] $aData[$j] = $aData[$j-1] $aData[$j-1] = $vTemp $j -= 1 WEnd Next DllClose($hDll) EndFunc
    1 point
  29. Thanks for sharing. Do add to your description that it uses AutoItObject.au3 and where to get it from.
    1 point
  30. ...moreover, a Function, plays a function that in turn can Return a value. Forget programming until you can get some reading comprehension as otherwise you would not know what is been presented in front of your eyes.
    1 point
  31. Accept Multiple Files UDF is inspired by this topic and this topic. Introduction if your app (compiled script) is launched from Windows Explorer context menu, then you've probably noticed that when multiple files are selected, only one file is passed to your app, so Windows starts multiple instances of your app, one for each file selected. few simple ways to overcome this issue are: 1) put a shortcut to your app on your "Send To..." context menu. this passes all the selected files as individual parameters to a single instance of your app. 2) put a shortcut to your app somewhere accessible, and drag the selected files to that shortcut. that will give you the same effect. (an accessible location might not include the task bar, unfortunately. but the Start menu for example is ok). 3) use an intermediate launcher, like this one (not tested by me). if none of these apply to you, then this UDF allows your app to handle this issue internally. Usage - yes, it is a one-liner: Global $aFiles = _AcceptMultipleFiles() Example Script - with comprehensive comments inside: #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Array.au3> ; this is needed only For the _ArrayDisplay later In this example script. #include 'AMF.au3' ; include the "Accept Multiple Files" UDF. #NoTrayIcon ; disable this interactive feature. Global $hTimer = TimerInit() ; for testing purposes Global $aFiles = _AcceptMultipleFiles() Global $fDiff = Round(TimerDiff($hTimer)) / 1000 ; determine how long the process took #cs calling _AcceptMultipleFiles makes the calling script accept all files passed as parameters to multiple instances of the calling script, typically invoked by Windows Explorer context menu. list of files is returned as an array. this is best performed as early as possible in your script, and definitely before any user interaction. it will either make this instance the 'master', that will accept multiple files to process (and continue running), or submit its file to the master instance if one is already active (and exit). *NOTE: if there are files to process, and if this is NOT the 'master' instance, then this line will never be reached. *NOTE: if only one file is selected - thus only one instance is invoked - then that instance becomes the 'master' and the files array contains only the one file. if your code made it this far, there are two possible scenarios: 1) there are files to process, and they are stored in the array. element zero and @extended both store the number of files. 2) your app was called with no parameters, or too many, or one that is not a file. in this case element zero = 0 and @extended = 0. hence, you can use element zero to decide on your next action. something like this: #ce If $aFiles[0] > 0 Then ; <<<<<<<<<< do your stuff with the files listed in $aFiles >>>>>>>>>> _ArrayDisplay($aFiles, 'AMF Example (' & $fDiff & ' sec)') Else ; <<<<<<<<<< do your stuff when no parameters were specified, or too many parameters, or a single parameter which is not a valid file >>>>>>>>>> MsgBox(0, 'AMF Example (' & $fDiff & ' sec)', 'This was the command line:' & @CRLF & $CmdLineRaw) EndIf UDF: #include-Once ; #INDEX# ======================================================================================================================= ; Title .........: Accept Multiple Files ; AutoIt Version : 3.3.16.1 ; UDF Version ...: 2.0 ; Status ........: Production ; Language ......: English ; Description ...: Allows a script to accept multiple files from Windows Explorer context menu, which invokes multiple instances. ; One instance becomes the 'master'. All other instanes submit their files to the master and exit, so only the ; 'master' instance remains active and can process all files. ; Author(s) .....: orbs ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== Global $__g_AMF_bDebug = False ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _AcceptMultipleFiles ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _AcceptMultipleFiles ; Description ...: Accepts multiple files given as parameters to multiple instances of the calling script. ; Syntax ........: _AcceptMultipleFiles([$iAttempts = 10[, $iInterval = 10[, $bDebug = False]]]) ; Parameters ....: $iAttempts - [optional] number of attempts of searching for submitted files. Default (and minimum) is 10. ; $iInterval - [optional] number of milliseconds between attempts. Default (and minimum) is 10. ; $bDebug - [optional] default is False. if True, log files are created in the temporary folder. ; Return values .: a 1-based array of all files submitted by all instances. @extended is set to file count. ; Author ........: orbs ; Modified ......: ; Remarks .......: - if no parameters were specified, or too many parameters, or a single parameter which is not a valid file, ; then the function returns an array with element [0]=0, and @extended is set to 0. ; - to improve reliability, the calling script may increase $iAttempts and/or $iInterval. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _AcceptMultipleFiles($iAttempts = 10, $iInterval = 10, $bDebug = False) ; process parameters If ($iAttempts = Default) Or ($iAttempts < 10) Then $iAttempts = 10 If ($iInterval = Default) Or ($iInterval < 10) Then $iInterval = 10 If $bDebug = Default Then $bDebug = False $__g_AMF_bDebug = $bDebug __AMF_Log('enter _AcceptMultipleFiles') __AMF_Log('attempts: ' & $iAttempts) __AMF_Log('interval: ' & $iInterval) ; initialize return data Local $aFiles[1] = [0] ; validate parameter If Not ($CmdLine[0] = 1 And FileExists($CmdLine[1])) Then Return SetExtended(__AMF_Log('invalid param => return empty array'), $aFiles) ; prepare variables and parent (root) folder Local Const $sAMF_Root = @LocalAppDataDir & '\AMF' __AMF_Log('AMF root: ' & $sAMF_Root) __AMF_Log('root DirCreate = ' & DirCreate($sAMF_Root)) Local Const $sAMF_Path = @LocalAppDataDir & '\AMF\' & __AMF_CreateGUID(StringRight(@ScriptFullPath, 16)) Local Const $sAMF_MasterFile = $sAMF_Path & '\master' __AMF_Log('AMF path: ' & $sAMF_Path) __AMF_Log('master file: ' & $sAMF_MasterFile) Local $iIteration = 0 Local $bFound Local $hSearch Local $sAMF_File Local $sFile ; determine if master While Not __AMF_TakeOver($sAMF_Path, $sAMF_MasterFile) ; see if this should become the master process. If __AMF_MasterIsActive($sAMF_MasterFile, $iAttempts, $iInterval) Then ;; if not, then check if there is already an active master process. __AMF_SubmitFile($sAMF_Path, $CmdLine[1]) ;;; if so, then submit the file to the master and exit. __AMF_Log('file submitted => exit') Exit Else __AMF_Cleanup($sAMF_Path) ;; if there is no active master, assume the past master has crashed. cleanup and repeat trying to take over. EndIf WEnd __AMF_Log('this instance is master') ; start with first file, submitted by the master ReDim $aFiles[UBound($aFiles) + 1] $aFiles[0] += 1 $aFiles[UBound($aFiles) - 1] = $CmdLine[1] ; process submitted files __AMF_Log('searching for submitted files') Do $iIteration += 1 $bFound = False __AMF_Log('start iteration #' & $iIteration) For $i = 1 To $iAttempts __AMF_Log('attempt #' & $i) FileClose($hSearch) $hSearch = FileFindFirstFile($sAMF_Path & '\PID_*') If @error Then __AMF_Log('FileFindFirstFile @error=' & @error & ' => next attempt') FileClose($hSearch) Sleep($iInterval) ContinueLoop EndIf $sAMF_File = FileFindNextFile($hSearch) If @error Then __AMF_Log('FileFindNextFile @error=' & @error & ' => next attempt') Sleep($iInterval) ContinueLoop EndIf $bFound = True __AMF_Log('$sAMF_File = ' & $sAMF_File) $sAMF_File = $sAMF_Path & '\' & $sAMF_File __AMF_Log('prefix full path = ' & $sAMF_File) __AMF_Log('FileGetAttrib = ' & FileGetAttrib($sAMF_File)) If StringInStr(FileGetAttrib($sAMF_File), 'R') Then __AMF_Log('Attrib R found') $sFile = FileReadLine($sAMF_File) __AMF_Log('FileReadLine = ' & $sFile) If $sFile = '' Then __AMF_Log('result is empty => repeat attempt') Sleep($iInterval) $i -= 1 ContinueLoop Else __AMF_Log('FileSetAttrib -R = ' & FileSetAttrib($sAMF_File, '-R')) __AMF_Log('FileDelete = ' & FileDelete($sAMF_File)) EndIf Else __AMF_Log('Attrib R not found => repeat attempt') Sleep($iInterval) $i -= 1 ContinueLoop EndIf ReDim $aFiles[UBound($aFiles) + 1] $aFiles[0] += 1 $aFiles[UBound($aFiles) - 1] = $sFile __AMF_Log('added to array => repeat attempt on next file') $i -= 1 Next __AMF_Log('iteration ended. files found = ' & $bFound) Until Not $bFound FileClose($hSearch) __AMF_Log('search for submitted files ended') __AMF_Cleanup($sAMF_Path) Return SetExtended(__AMF_Log('end _AcceptMultipleFiles => return array with @extended=' & $aFiles[0], $aFiles[0]), $aFiles) EndFunc ;==>_AcceptMultipleFiles ; #INTERNAL_USE_ONLY# =========================================================================================================== ; __AMF_CreateGUID ; __AMF_TakeOver ; __AMF_MasterIsActive ; __AMF_SubmitFile ; __AMF_Cleanup ; __AMF_Log ; =============================================================================================================================== Func __AMF_CreateGUID($sString) ; ref: https://www.autoitscript.com/forum/topic/147995-createguidfromstring-convert-a-string-to-a-valid-guid/ Return StringRegExpReplace(StringToBinary($sString) & "0000000000000000000000000000000000", "..(.{8})(.{4})(.{4})(.{4})(.{12}).*", "\{$1-$2-$3-$4-$5\}") EndFunc ;==>__AMF_CreateGUID Func __AMF_TakeOver($sAMF_Path, $sAMF_MasterFile) __AMF_Log('enter __AMF_TakeOver') Local $aResult = DllCall('kernel32.dll', 'bool', 'CreateDirectoryW', 'wstr', $sAMF_Path, 'struct*', 0) If @error Or ($aResult[0] = 0) Then Return __AMF_Log('cannot create folder => this instance is not the master. return 0') Else __AMF_Log('FileWriteLine = ' & FileWriteLine($sAMF_MasterFile, @AutoItPID)) __AMF_Log('FileSetAttrib +R = ' & FileSetAttrib($sAMF_MasterFile, '+R')) Return __AMF_Log('master file created => return 1', 1) EndIf EndFunc ;==>__AMF_TakeOver Func __AMF_MasterIsActive($sAMF_MasterFile, $iAttempts, $iInterval) __AMF_Log('enter __AMF_MasterIsActive') Local $iPID For $i = 1 To $iAttempts If StringInStr(FileGetAttrib($sAMF_MasterFile), 'R') Then $iPID = Number(FileReadLine($sAMF_MasterFile)) ExitLoop Else Sleep($iInterval) EndIf Next __AMF_Log('read PID = ' & $iPID) If $iPID = 0 Then Return __AMF_Log('PID=0 => return 0') If ProcessExists($iPID) Then Return __AMF_Log('process exists => return 1', 1) Return __AMF_Log('end __AMF_MasterIsActive => return 0') EndFunc ;==>__AMF_MasterIsActive Func __AMF_SubmitFile($sAMF_Path, $sFile) __AMF_Log('enter __AMF_SubmitFile') Local $sAMF_File = $sAMF_Path & '\PID_' & @AutoItPID __AMF_Log('FileDelete = ' & FileDelete($sAMF_File)) __AMF_Log('file to submit: ' & $sFile) __AMF_Log('FileWriteLine = ' & FileWriteLine($sAMF_File, $sFile)) __AMF_Log('FileSetAttrib +R = ' & FileSetAttrib($sAMF_File, 'R')) __AMF_Log('end __AMF_SubmitFile') EndFunc ;==>__AMF_SubmitFile Func __AMF_Cleanup($sAMF_Path) __AMF_Log('enter __AMF_Cleanup') __AMF_Log('dir to remove: ' & $sAMF_Path) __AMF_Log('FileSetAttrib -R = ' & FileSetAttrib($sAMF_Path, '-R', 1)) __AMF_Log('DirRemove = ' & DirRemove($sAMF_Path, 1)) __AMF_Log('end __AMF_Cleanup') EndFunc ;==>__AMF_Cleanup Func __AMF_Log($sString, $xRet = 0) If $__g_AMF_bDebug Then FileWriteLine(@TempDir & '\AMF_log_' & @AutoItPID & '.txt', @HOUR & ':' & @MIN & ':' & @SEC & '.' & @MSEC & ' (' & @AutoItPID & ') ' & $sString) Return $xRet EndFunc ;==>__AMF_Log Testing Instructions: 1) save the UDF as file "AMF.au3". 2) save the example script as file "AMF_Example.au3". 3) compile the example script as "AMF_Example.exe". 4) place the executable in the root of drive D (or anywhere else ,but adapt the following registry entry accordingly) 5) save this text as registry file "AMF_Example.reg" and import it: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\AMF Example] "MultiSelectModel"="Player" [HKEY_CLASSES_ROOT\*\shell\AMF Example\command] @="D:\\AMF_Example.exe \"%1\"" 6) open Windows Explorer, select multiple files, right click one of them and choose "AMF Example" from the context menu. 7) enjoy!
    1 point
  32. Ok, i didn't know this about the API. Thanks for the information. The powershell may have been shortened by a colleague who may have deleted some neccessary parts. I will investigate this. Maybe then it is better trying the webdriver. I will be back here when i have my first webdriver code done or when i fail with this task 🙂
    1 point
  33. Years ago, I made a program with Autoit3 to turn off the monitors of any PC I was connected to remotely, Autoit3 can turn off any one or more monitors on a PC natively with no third-party solution needed although, if I recall correctly, it will need to be run as administrator. I recommend this post to get started.
    1 point
  34. It's nothing technical, it looks like the application start without being aware of the passed argument. Try using numerical arguments (see the previous post).
    1 point
  35. I don't know if you are like me, but I am always searching for that specific code I wrote over the years, but cannot find it. It was way too exhausting to look at 1k+ scripts. And Windows Explorer is not the best tool to do such exploration. So I made this little script that save me tons of time. Hope you will find it useful too. You can adjust default search folders and type of files you want to search for, but you can also change it at runtime. To use multiple filters separate them with ";" Let me know if you have any suggestion to enhance the tool. Version 2023-12-27 * Code revision : 3.3.16.1 now required Version 2023-05-10 * Sets children flag on first drawn list Version 2021-04-06 * Context menu modified to allow clipping file name and line content Version 2020-11-21 * Allows only 1 running instance of the script * Added right-click support on Tray to exit script Version 2020-06-29 * Added Copy File Name to context menu (helps to copy include files names) Version 2020-04-22 * Added icons to main buttons * Added informative box to describe progress and results of a search * Increased robustness of the GUI * Open Button enabled only under the right conditions * Added Tooltip on filter field to describe how to enter multiple criteria * Forced a minimum Window size Version 2020-04-18 * Added support of Context Menu in Tree View * Added support of Tray * Minimizes on Tray Version 2020-04-12 * Added DPI awareness * Added Enter Key functionality to start a search Version 2020-04-09 * Changed base size of the GUI to make it wider * Made the window resizable * Added Reset button * Shown busy cursor more appropriately * Corrected bug of first line displayed Thanks all for your input. SearchContent.au3
    1 point
  36. The following script, thanks largely to @UEZ, displays the attached PNG image on the Windows Desktop. It perfectly renders the sticky note's shadow over whatever's in the background. But here's the catch: I would like to add a line of text, fetched from a variable and using a font of my choice, atop the sticky note. It needs to be part of the same GUI because the sticky note can be dragged and placed anywhere on the screen. Will someone here show me how to add just the additional code needed to accomplish my goal? I have tried sporadically for two years to merge in code from scripts that use GDI+ calls to display text over alpha channels but the challenge has proven beyond me. #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global $iW, $iH, $hImage, $hBitmap, $hGUI $hImage = _GDIPlus_BitmapCreateFromFile("Using-Note.png") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) GUISetState() _WinAPI_BitmapDisplayTransparentInGUI($hBitmap, $hGUI) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete() Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN
    1 point
  37. 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
  38. Here a GUI to enter the needed IP information. ;fast hack by UEZ 2013 #include <Array.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <StaticConstants.au3> Global Const $oMyError = ObjEvent("AutoIt.Error", "oMyError") ; Install a custom error handler $hGUI = GUICreate("IP Test", 423, 123) GUISetFont(9, 400, 0, "Arial") TrayTip("Information", "Reading network setting. Please wait...", 10, 1) $aNetworkAdapters = _WMI_GetNetworkAdapterNames() TrayTip("", "",0) $iComboBox = GUICtrlCreateCombo("", 220, 15, 180, 20, $CBS_DROPDOWN + $CBS_AUTOHSCROLL) Global $sNetworkAdapters, $z For $z = 0 To UBound($aNetworkAdapters) - 1 $sNetworkAdapters &= $aNetworkAdapters[$z][0] & "|" Next GUICtrlSetData($iComboBox, StringTrimRight($sNetworkAdapters, 1), $aNetworkAdapters[0][0]) $sCurrentIP = GUICtrlCreateLabel("Current IP:", 16, 18, 62, 19, $SS_RIGHT) $hCurrenIP = _GUICtrlIpAddress_Create($hGUI, 84, 16, 130, 21) _GUICtrlIpAddress_Set($hCurrenIP, $aNetworkAdapters[0][1]) $sNewIP = GUICtrlCreateLabel("New IP:", 16, 53, 62, 19, $SS_RIGHT) $hNewIP = _GUICtrlIpAddress_Create($hGUI, 84, 51, 130, 21) _GUICtrlIpAddress_Set($hNewIP, "0.0.0.0") $sDefaultGateway = GUICtrlCreateLabel("Gateway:", 16, 85, 62, 19, $SS_RIGHT) $hDefaultGateway = _GUICtrlIpAddress_Create($hGUI, 84, 83, 130, 21) _GUICtrlIpAddress_Set($hDefaultGateway, "0.0.0.254") $iBtnOK = GUICtrlCreateButton("OK", 232, 80, 75, 25) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_NOTIFY, "") GUIDelete() Exit Case $iBtnOK MsgBox(0, "Test", "Interface Name: " & $aNetworkAdapters[_ArraySearch($aNetworkAdapters, GUICtrlRead($iComboBox))][0] & @CRLF & _ "New IP: " & _GUICtrlIpAddress_Get($hNewIP) & @CRLF & _ "Default Gateway: " & _GUICtrlIpAddress_Get($hDefaultGateway)) Case $iComboBox _GUICtrlIpAddress_Set($hCurrenIP, $aNetworkAdapters[_ArraySearch($aNetworkAdapters, GUICtrlRead($iComboBox))][1]) EndSwitch WEnd Func _WMI_GetNetworkAdapterNames($sHost = ".") If $sHost = "." Then $sHost = @ComputerName Local $objWMI= ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2") Local $oItems1 = $objWMI.InstancesOf("Win32_NetworkAdapter WHERE NetEnabled=TRUE") Local $oItems2, $oTokens1, $oTokens2, $aIP, $sIPAddresses, $aResult[100][2], $i = 0 For $oTokens1 In $oItems1 $aResult[$i][0] = $oTokens1.NetConnectionID $oItems2 = $objWMI.InstancesOf('Win32_NetworkAdapterConfiguration WHERE Description="' & $oTokens1.Name & '"') For $oTokens2 In $oItems2 $aIP = $oTokens2.IPAddress For $j = 0 To UBound($aIP) - 1 If StringRegExp($aIP[$j], "(\d+\.\d+\.\d+\.\d+)", 0) Then $aResult[$i][1] = $aIP[$j] Next $i += 1 Next Next If $i > 0 Then ReDim $aResult[$i][2] Return $aResult EndIf Return SetError(1, 0, 0) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode, $tNMHDR Local $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hNewIP Switch $iCode Case $IPN_FIELDCHANGED Local $aIP = _GUICtrlIpAddress_GetArray($hNewIP) $aIP[3] = "254" _GUICtrlIpAddress_SetArray($hDefaultGateway, $aIP) EndSwitch Case $hDefaultGateway Switch $iCode Case $IPN_FIELDCHANGED Local $aIP = _GUICtrlIpAddress_GetArray($hDefaultGateway) $aIP[3] = "254" _GUICtrlIpAddress_SetArray($hDefaultGateway, $aIP) EndSwitch EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_NOTIFY Func oMyError() ConsoleWrite( @CRLF & @CRLF & _ "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.Description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.WinDescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.Number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.LastDllError & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.Scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.Source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.Helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.HelpContext & @CRLF & @CRLF) EndFunc To do: apply settings / save it to a ini file. Br, UEZ
    1 point
  39. EndFunc

    Set focus of a button

    Tried this and it wasn't very effective except once. Is there some sort of event handler that checks if you type anything in to the input it sets focus to the button. That sounds like what the style does but doesn't seem to work. $CheckID = GUICtrlCreateButton("Validate", 426, 140, 85, 21, 0) GUICtrlSetState($CheckID, $GUI_FOCUS)
    1 point
  40. Werty

    AutoIt3 syntax mania

    Weird $string = Chr(65)Chr(85)&1-+++-1-+++-1&&@crlf consolewrite($String)
    0 points
×
×
  • Create New...