Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 03/24/2024 in Posts

  1. I ported half of the Cairo functions to Autoit. You can read more about the functions here: https://www.cairographics.org/documentation/ The probability is high that errors have crept in and I have only tested a fraction of the functions. Anyone who wants to can contribute examples. All needed files (DLLs, UDF and examples) can be download from my OneDrive: Cairo for Autoit If you find a mistake, I am sure you will, then please report it.
    8 points
  2. Hello guys. I just did another OCR wrapper for this nice library. What's AU3-RapidOCR? RapidOCR UDF is a simple wrapper for RapidOCR library. Features. Get Text From Image File. Easy to use. Usage: #include "RapidOCR.au3" _Example() Func _Example() MsgBox(0, "", _RapidOCR_ImageToText(@ScriptDir & "\images\Image1.png")) EndFunc Check RapidOCR UDF on GitHub. Saludos
    6 points
  3. Github repository link: https://github.com/genius257/Manga Long story short: I wanted a simple manga reader and this project also let me test my AutoIt3 HTTP server code with real usage. This serves mostly as an example on how my AutoIt-HTTP-Server could be used for letting the browser handle all the UI. It does work as a manga downloader and reader, but currently only supports taadd. Steps to try it: Download and extract repository: https://github.com/genius257/Manga/archive/refs/heads/main.zip Open settings.ini and change Path under [AU3] to match your autoit installation folder (Example: C:\Program Files (x86)\AutoIt3). You can also change the Port under [core] if port 80 is occupied. Run main.au3 and goto http://localhost (add your port if anything other than 80), or use the "Open in browser" option from the right click on the tray menu.
    3 points
  4. I have added a function and packed the whole thing into a speed comparison: #include <Array.au3> Global Const $aArrayRaw = Get_Array() Global $f_DecimalPlaces = 1 Global $iT, $a_Results[0][3] Func Get_Array() Local $aArray[1e6] For $i = 0 To UBound($aArray) - 1 $aArray[$i] = Random(0,2,1) = 2 ? " " : "x" Next Return $aArray EndFunc ;==>Get_Array ; the first measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "Andreik" $iT = TimerInit() $aArray = _strip_Andreik($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the second measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "SmOke_N" $iT = TimerInit() $aArray = _strip_SmOke_N($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the third measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "Nine 1" $iT = TimerInit() $aArray = _stripNine1($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the fourth measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "Nine 2" $iT = TimerInit() $aArray = _stripNine2($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the fifth measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "AspirinJunkie" $iT = TimerInit() _strip_AspirinJunkie($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; calculate results and print them out _ArraySort($a_Results, 0, 0, 0, 1) For $i = 0 To UBound($a_Results) - 1 $a_Results[$i][2] = Round($a_Results[$i][1] / $a_Results[0][1], 2) $a_Results[$i][1] = Round($a_Results[$i][1], $f_DecimalPlaces) Next _ArrayDisplay($a_Results, "Measurement Results", "", 16 + 64, Default, "name|time [ms]|factor") Func _strip_Andreik(ByRef $aData, $iStart = 0) If Not IsArray($aData) Then Return SetError(1, 0, False) Local $iElements = UBound($aData) If $iStart >= $iElements Then Return SetError(2, 0, False) Local $sResult For $Index = $iStart To $iElements - 1 $sResult &= (StringStripWS($aData[$Index], 8) ? $aData[$Index] & '|' : '') Next Return StringSplit(StringTrimRight($sResult, 1), '|', 2) EndFunc Func _stripNine1(ByRef $array, $iStart = 0) Local $sArray = StringRegExpReplace(_ArrayToString($array, Default, $iStart), "\|\s*$|(?<=\|)\s*\|", "") Return StringSplit(($iStart ? _ArrayToString($array, Default, 0, $iStart - 1) & "|" : "") & $sArray, "|", $STR_NOCOUNT) EndFunc Func _stripNine2(ByRef $array, $iStart = 0) Local $aTemp = _ArrayFindAll($array, "^\s*$", $iStart, Default, 0, 3) _ArrayInsert($aTemp, 0, UBound($aTemp)) _ArrayDelete($array, $aTemp) Return $array EndFunc ; $bNoWS = White spaces only count as empty element, true by default Func _strip_SmOke_N(ByRef $aArgs, $iStart = 0, $bNoWS = True) If UBound($aArgs, 2) Then Return SetError(1, 0, 0) ; out of bounds If $iStart = Default Or $iStart == -1 Then $iStart = 0 If $bNoWS = Default Or $bNoWS == -1 Then $bNoWS = True Local $iUB = UBound($aArgs) ; catch start out of bounds If $iStart < 0 Or $iStart > $iUB - 1 Then Return SetError(2, 0, 0) Local $aRet[$iUB] Local $iEnum = 0 ; build array without concatenation For $i = $iStart To $iUB - 1 If StringLen($aArgs[$i]) == 0 Then ContinueLoop If $bNoWS Then If StringRegExp($aArgs[$i], "(?m)^\s+$") Then ContinueLoop EndIf $aRet[$iEnum] = $aArgs[$i] $iEnum += 1 Next If $iEnum = 0 Then ; nothing found, but rather than return a false ; set error and return array where user can do what they want with it Return SetError(2, 0, $aArgs) EndIf ; resize return array ReDim $aRet[$iEnum] ; return extended as the ubound of new array Return SetExtended($iEnum, $aRet) EndFunc Func _strip_AspirinJunkie(ByRef $A, $iStart = 0, $iEnd = UBound($A) - 1) Local $x = $iStart For $i = $iStart To $iEnd If StringIsSpace($A[$i]) Then ContinueLoop $A[$x] = $A[$i] $x += 1 Next Redim $A[$x] EndFunc Nine`s first function performs best, but would still have to be adapted to certain special cases for which it currently does not work, depending on the type of data: 1. if first array element is empty it`s still in the array 2. only line breaks are not recognized as empty strings (which may be correct depending on the context) and 3. if pipes ("|") occur in the strings.
    3 points
  5. Another way less hacky maybe : #include <GUIConstantsEx.au3> #include <Misc.au3> If Not _Singleton("MyGui", 1) Then Exit WinSetState("gui V1.1.1", "", @SW_SHOW) + WinSetState("gui V1.1.1", "", @SW_RESTORE) $gui = GUICreate("gui V1.1.1", 445, 262, -1, -1, -1, -1) $button = GUICtrlCreateButton("Button", 60, 20, 100, 30, -1, -1) $bHide = GUICtrlCreateButton("Hide", 60, 60, 100, 30, -1, -1) $label = GUICtrlCreateLabel("My Text", 80, 100, 50, 15, -1, -1) $label2 = GUICtrlCreateLabel("My Text", 80, 130, 50, 15, -1, -1) GUISetState(@SW_SHOWMINIMIZED) WinSetState($gui, "", @SW_HIDE) $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button $counter += 1 GUICtrlSetData($label, $counter) Case $bHide WinSetState($gui, "", @SW_HIDE) EndSwitch WEnd Yes, it made me laugh too...
    3 points
  6. We had few zoom meetings witch give us a new look on each other.
    3 points
  7. First, I must sincerely apologize to @paw for being so stubborn in refusing to incorporate the notion of injection into my UDF. After careful consideration, I must admit my mistake. It was a very good idea, and I should have agreed to it. But to keep the UDF completely safe, it will be possible to authorize injection or refuse it. When the injection is authorized, the Send and Mouse* functions will operate normally even if manual inputs are rejected. New version available
    3 points
  8. @Werty I updated Just check out the example _GDIPlus_BitmapApplyFilter_Indexed.au3. This time I added also a x64 DLL but not fully tested. The result should look like this here with Floyd-Steinberg dithering:
    3 points
  9. SmOke_N

    Problem with SELECT

    That makes me giggle... Whatever the case, I know other mods are already fed up with his ignorantly posturized requests. No matter what people suggest, if they don't write the code for them specifically, this OP is never satisfied to do the work or research. I know others are (including mods) are already at their limit. To the OP, start posting really worked on problems, start researching the suggestions given to you with examples on how those suggestions are not working for you, starting reading some manuals, manuals not only on coding, but maybe how to request help. I'm locking this topic, I know his last topic was locked as well. Hopefully the OP gets the hint.
    3 points
  10. MattyD

    SNMP UDF rewrite

    I've recently been looking at the old SNMP UDP, and although it has served well over a long period of time it did look in need of a freshen up. So from the ground up, reintroducing SNMPv2. The UDF is still only community string stuff, so just SNMPv1 and SNMPv2c for now. V3 support is probably a ways off I'm affraid - the projects only about a week old, and theres a ton of work to be done before attacking that. The basic workflow is: Call the startup func Register a function to recieve incoming messages. (basically to recieve decoded OID/Value pairs.) or if you cant be bothered, an internal one will just write to the console! Open a device start querying devices and stuff The zip file attached has a bunch of demos scripts etc. to get you going. But here's an example script for post #1 anyhow. #include "SNMPv2.au3" ;-------------------------------------------------- Local $sIPAddress = "10.0.0.5" ;Device $__g_bRetTicksAsStr = True ;Return TimeTicks as human readable string (instead of int) ;There are few global params for now that you can set. - Check the demo scripts for details. ;-------------------------------------------------- Global Const $sOID_sysDescr = "1.3.6.1.2.1.1.1.0" Global Const $sOID_sysName = "1.3.6.1.2.1.1.5.0" Global Const $sOID_sysLocation = "1.3.6.1.2.1.1.6.0" Global Const $sOID_sysUpTime = "1.3.6.1.2.1.1.3.0" Global $mOIDLabMap[] $mOIDLabMap[$sOID_sysDescr] = "sysDescr" $mOIDLabMap[$sOID_sysName] = "sysName" $mOIDLabMap[$sOID_sysLocation] = "sysLocation" $mOIDLabMap[$sOID_sysUpTime] = "sysUpTime" ; Startup and register a handler for incoming messages. ; The function must accept 4 parameters - more on this futher down _SNMP_Startup("_CustomMsgHandler") ;Open device Local $iDevice = _SNMP_OpenDevice($sIPAddress) ;Get one specfic property. ;The community param is optional. (defaults to "public") _SNMP_GetRequest($iDevice, $sOID_sysDescr, "public") ;Or get multiple properties in one request. Local $aOids[3] $aOids[0] = $sOID_sysName $aOids[1] = $sOID_sysLocation $aOids[2] = $sOID_sysUpTime _SNMP_GetRequest($iDevice, $aOids) ;Temporarily keep the script alive! Sleep(500) ;Cleanup _SNMP_CloseDevice($iDevice) _SNMP_Shutdown() ; Handler Params: ; $iDevice - device that responded ; $dPacket - rawData ; $avHeader - metadata pulled from the response. Format: $array[6][2] (field, data) ; $avVarBinds - list of OID's and their associated data. Format: $array[n][6] (OID, Type, Value, RawType, RawValue) ; header feilds - "SNMP Version", "Community", "Request Index", "Error Message", "Error Code", "Error Index" Func _CustomMsgHandler($iDevice, $dRawPacket, $avHeaders, $avVarBinds) Local $sFeild, $vData For $i = 0 To UBound($avVarBinds) - 1 ; $avVarBinds[index][OID, Type, Value, RawType, RawValue] $sFeild = $mOIDLabMap[$avVarBinds[$i][0]] $vData = $avVarBinds[$i][2] ConsoleWrite(StringFormat("%15s: %s\r\n", $sFeild, $vData)) Next EndFunc SNMPv2c_1.0.zip
    3 points
  11. Not trying to re-invent the wheel here, but I found some examples that did A-L-O-T that I didn't think was necessary (like forcing owner-drawn), the sparse number of the web examples were failing miserably too. It looked like @argumentum was taking the path I was on, his is much more feature rich ( 😅 ) ... Anyway, I was going to add a font option using this subclass method (Thanks to @LarsJ for his subclass method, saved me some time) but I am out of time and if I don't post this now, I will probably forget to post it later (Yep, age is getting there). @LarsJ - GUIRegisterMsg20 - @argumentum ComboBox Set DROPDOWNLIST Colors/size UDF (Lots-O-Stuff) Here's my short and sweet (I don't think I ever code anything short.. or sweet) Edit 2024-04-10: Added the font change functions, pay attention to the fact that there are 3 different hwnds, the control hwnd, the edit hwnd as well as the listbox hwnd for the combo box. There are 4 functions, one changes all 3, the others change each of the other hwnds. Edit-2 2024-04-10: So I was going to use the forum members meticulous eyes to find issues, but I seemed to find a few that I didn't notice before myself. - Wrong array bounds in font au3 was fixed - Multi color (LB and Edit different colors) fixed (mistakenly used 1 brush ... oops) for color au3 - Missing edit color logic fixed for color au3 GUIComboBox.2024.04.10-002.zip
    3 points
  12. Yep, one of those moments where I forgot that \u or \l doesn't work with our PCRE engine 😞. So I *slap-sticked* some code together to achieve what I needed on the fly. This is truly ugly IMO, but if you're not doing a lot of string manipulation concatenations it's ok. I know I wrote some pcre funcs in a dll back in the day for my personal use to be able to do some things like this, but of course I can't find it... So native it is. Anyway, I added this to my personal chars au3, thus the name you'll see. Please test and criticize away, like I said, it was a quick mod and it's A-L-O-T of regex this and regex that ... but maybe it's useful for someone. #include <StringConstants.au3> #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _AutChars_RegExpReplaceEx ; Description ...: Allows StringRegExpReplace replace with pattern to do upper/lower ; Syntax ........: _AutChars_RegExpReplaceEx($sData, $sRegEx, $sReplace[, $iCount = 0]) ; Parameters ....: $sData - The string to check ; $sRegEx - The regular expression to compare. See StringRegExp for pattern definition characters. ; $sReplace - The text to replace the regular expression matching text with ; $iCount - Number of replacements. Default is 0 for global replacement ; Return values .: Success - an updated string based on regular expressions ; @extended = number of replacements performed ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com) ; Modified ......: ; Related .......: See StringRegExpReplace() ; Remarks .......: Will only work with \u or \l such as \u$2 in replace with pattern ; In my opinion, this is a pretty abusive way to achieve this, might be fine for small jobs ; but the overhead would be immense ; Example .......: _AutChars_RegExpReplaceEx("abcdAbcefg", "abc", "\u$0") will return ABCdAbcefg ; =============================================================================================================================== Func _AutChars_RegExpReplaceEx($sData, $sRegEx, $sReplace, $iCount = 0) ; work in progress Local Const $iGlobalMatch = $STR_REGEXPARRAYGLOBALMATCH Local $sRet = "" Local Const $sMatchRE = "[\\$](?:u|l)[\$\\]{?\d+\}?" If Not StringRegExp($sReplace, $sMatchRE) Then $sRet = StringRegExpReplace($sData, $sRegEx, $sReplace, $iCount) Return SetError(@error, @extended, $sRet) EndIf ; unique identifier Local $sUStart = "<" & Chr(1) & "@U@" & Chr(1) & ">" Local $sUEnd = "</" & Chr(1) & "@U@" & Chr(1) & ">" Local $sLStart = "<" & Chr(1) & "@L@" & Chr(1) & ">" Local $sLEnd = "</" & Chr(1) & "@L@" & Chr(1) & ">" ; modify replace string Local $sTmp = $sReplace $sTmp = StringRegExpReplace($sTmp, "(?i)([\\$]u)([\$\\]{?\d+\}?)", $sUStart & "$2" & $sUEnd) $sTmp = StringRegExpReplace($sTmp, "(?i)([\\$]l)([\$\\]{?\d+\}?)", $sLStart & "$2" & $sLEnd) Local $sRepStr = StringRegExpReplace($sData, $sRegEx, $sTmp, $iCount) Local $iExtended = @extended ; get upper and lower matches with unique identifier Local $aMatchUpper = StringRegExp($sRepStr, "(\Q" & $sUStart & "\E.*?\Q" & $sUEnd & "\E)", $iGlobalMatch) Local $aMatchLower = StringRegExp($sRepStr, "(\Q" & $sLStart & "\E.*?\Q" & $sLEnd & "\E)", $iGlobalMatch) ; no need to worry about case Local $aMUpUnique, $aMLrUnique If IsArray($aMatchUpper) Then $aMUpUnique = _ArrayUnique($aMatchUpper, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) EndIf If IsArray($aMatchLower) Then $aMLrUnique = _ArrayUnique($aMatchLower, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) EndIf $sRet = $sRepStr Local $sMatch For $i = 0 To UBound($aMUpUnique) - 1 $sMatch = StringRegExpReplace($aMUpUnique[$i], "\Q" & $sUStart & "\E|\Q" & $sUEnd & "\E", "") $sRet = StringReplace($sRet, $aMUpUnique[$i], StringUpper($sMatch), $iCount) Next For $i = 0 To UBound($aMLrUnique) - 1 $sMatch = StringRegExpReplace($aMLrUnique[$i], "\Q" & $sLStart & "\E|\Q" & $sLEnd & "\E", "") $sRet = StringReplace($sRet, $aMLrUnique[$i], StringLower($sMatch), $iCount) Next Return SetExtended($iExtended, $sRet) EndFunc
    3 points
  13. ioa747

    SmartNote

    SmartNote UWPOCR Edition: For those who don't want to install the tesseract . Using only the Windows Optical character recognition API (at least Windows 10 ) and the UWPOCR UDF ( Thanks to @Danyfirex ) from: uwpocr-windows-platform-optical-character-recognition-api-implementation otherwise it is a clone of the above SmartNote_UWPOCR.au3 ; https://www.autoitscript.com/forum/topic/208600-smartnote/?do=findComment&comment=1532353 ;---------------------------------------------------------------------------------------- ; Title...........: SmartNote_UWPOCR.au3 ; Description.....: SmartNote is a screen snip tool to take Screenshot with OCR ability from UWPOCR ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=mmcndmgr-106.ico #AutoIt3Wrapper_Res_Description=SmartNote is a screen snip tool to take Screenshot with OCR ability from UWPOCR #AutoIt3Wrapper_Res_Fileversion=0.0.2.20240331 #AutoIt3Wrapper_Res_ProductName=SmartNote_UWPOCR.au3 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon If WinExists(StringTrimRight(@ScriptName, 4) & "_STUB") Then Exit 5 AutoItWinSetTitle(StringTrimRight(@ScriptName, 4) & "_STUB") If @AutoItX64 Then Exit MsgBox(262144 + 64, StringTrimRight(@ScriptName, 4), "Please run as 32bit", 60) #include <MsgBoxConstants.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <Misc.au3> #include <Array.au3> #include <GDIPlus.au3> #include <Clipboard.au3> #include <String.au3> #include "UWPOCR.au3" ; * < -"https://www.autoitscript.com/forum/topic/207324-uwpocr-windows-platform-optical-character-recognition-api-implementation" ; Initialization DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2 Opt("MouseCoordMode", 1) ; 1=absolute, 0=relative, 2=client Opt("TrayMenuMode", 3) ; 0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Opt("GUIOnEventMode", 1) ; 0=disabled, 1=OnEvent mode enabled ; tray entry to exit script Global $TRAY_ExitScript = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TRAY_EVENT") ; separator TrayCreateItem("") ; tray entry to capture Global $TRAY_NewCapture = TrayCreateItem("Capture") TrayItemSetOnEvent(-1, "TRAY_EVENT") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TRAY_EVENT") TraySetIcon("mmcndmgr.dll", -106) TraySetClick(16) ; $TRAY_CLICK_SECONDARYUP = 16 TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("SmartNote" & @CRLF & "Double Click to take new note") Global $mPos, $aRecPos[4], $hGUICapture, $block_gui Global $hDLL = DllOpen("user32.dll") ; array to hold the Contextmenu data Global $NoteGui[1][18] $NoteGui[0][0] = 0 ; cnt, Note_Handle $NoteGui[0][1] = "jpgPath" $NoteGui[0][2] = "Gui_Size" $NoteGui[0][3] = "ID_PicCtrl" $NoteGui[0][4] = "ID_ContextMenu" $NoteGui[0][5] = "ID_cMenuCopy" $NoteGui[0][6] = "ID_cMenuShareX" $NoteGui[0][7] = "ID_cMenuSave" $NoteGui[0][8] = "ID_cMenuOpen" $NoteGui[0][9] = "ID_FutureUse" $NoteGui[0][10] = "ID_FutureUse" $NoteGui[0][11] = "ID_Lang1" $NoteGui[0][12] = "ID_Lang2" $NoteGui[0][13] = "ID_Lang3" $NoteGui[0][14] = "ID_Lang4" $NoteGui[0][15] = "ID_cMenuClose" $NoteGui[0][16] = "ID_Dummy_DeleteKey" $NoteGui[0][17] = "ID_Dummy_EnterKey" ; Check for leftover files Global $iFileExists = FileExists(@ScriptDir & "\tmp") If $iFileExists Then FileDelete(@ScriptDir & "\tmp\*.*") Else DirCreate(@ScriptDir & "\tmp") EndIf Global $aSupportedLanguages = _UWPOCR_GetSupportedLanguages() Global $iLanguagesCnt = UBound($aSupportedLanguages) - 1 ;~ HotKeySet("{PGUP}", "_Array_Gui_display") ; *** Debug _ArrayDisplay($NoteGui, "$NoteGui") <<- HotKey ; ℹ️ While Left Windows Key IsPressed, tap 2 times the Left SHIFT key to start NewCapture, ; is useful when Capture menu or contex menu. ; While start NewCapture point click anywhere to escape. (does not catch smaller than 9*9 px) ; While start NewCapture escape with ESC Global $iShift ; loop until program exit ;************************************************ While Sleep(100) $iShift = 0 While _IsPressed("5B", $hDLL) ; 5B Left Windows key Sleep(100) If _IsPressed("A0", $hDLL) Then ; A0 Left SHIFT key While _IsPressed("A1", $hDLL) Sleep(100) WEnd $iShift += 1 EndIf If $iShift = 2 Then NewCapture() ExitLoop EndIf WEnd WEnd ;************************************************ ;---------------------------------------------------------------------------------------- Func NewCapture() ; NewCapture Local $aRecPos[4], $aMPos[2], $tPos ;, $aTipPos[4], $iX, $iY Local $iDeskWidth, $iDeskHeight, $iDeskLeft, $iDeskTop Local $sDevice, $hMonitor, $sCurDevice, $aData, $Status = 0 ; make Capture gui $hGUICapture = GUICreate("Capture_gui", 1, 1, 1, 1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor("0xFFFF00", $hGUICapture) ; $COLOR_YELLOW WinSetTrans($hGUICapture, "", 50) ; make mouse block gui $block_gui = GUICreate("block_gui", 1, 1, 1, 1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) WinSetTrans($block_gui, "", 1) GUISetState(@SW_SHOW, $block_gui) GUISetCursor($MCID_CROSS, 1, $block_gui) Sleep(200) Local $iMaxLoop = 1200, $iCntLoop = 0 While Sleep(10) $iCntLoop += 1 If $iCntLoop = $iMaxLoop Then ExitLoop ; get mouse coordinates $tPos = _WinAPI_GetMousePos() $aMPos[0] = DllStructGetData($tPos, 1) $aMPos[1] = DllStructGetData($tPos, 2) ; get $hMonitor from previously defined Mouse coordinates $hMonitor = _WinAPI_MonitorFromPoint($tPos) ; get monitor $aData appropriate for previously defined coordinates $aData = _WinAPI_GetMonitorInfo($hMonitor) If Not @error Then $sDevice = $aData[3] $iDeskLeft = DllStructGetData($aData[0], 1) $iDeskTop = DllStructGetData($aData[0], 2) $iDeskWidth = DllStructGetData($aData[0], 3) $iDeskHeight = DllStructGetData($aData[0], 4) EndIf ;move the $block_gui to active monitor If $sCurDevice <> $sDevice Then $sCurDevice = $sDevice ;ConsoleWrite("- $sCurDevice=" & $sCurDevice & @CRLF) WinMove($block_gui, "", $iDeskLeft, $iDeskTop, $iDeskWidth, $iDeskHeight) EndIf ; whait Left_mouse_button _IsPressed If _IsPressed("01", $hDLL) Then $Status = 1 $aMPos = MouseGetPos() $aRecPos[0] = $aMPos[0] $aRecPos[1] = $aMPos[1] ; Wait until key is released. While _IsPressed("01", $hDLL) Sleep(50) $aMPos = MouseGetPos() $aRecPos[2] = $aMPos[0] $aRecPos[3] = $aMPos[1] ; show Capture gui GUISetState(@SW_SHOW, $hGUICapture) WinMove($hGUICapture, "", $aRecPos[0], $aRecPos[1], $aRecPos[2] - $aRecPos[0], $aRecPos[3] - $aRecPos[1]) WEnd ElseIf _IsPressed("1B", $hDLL) Then ;1B=ESC key - emergency exit GUIDelete($hGUICapture) GUIDelete($block_gui) Return SetError(1, 1, 0) EndIf If $Status = 1 Then ExitLoop WEnd GUIDelete($hGUICapture) GUIDelete($block_gui) ;ConsoleWrite($aRecPos[0] & ";" & $aRecPos[1] & ";" & $aRecPos[2] - $aRecPos[0] & ";" & $aRecPos[3] - $aRecPos[1] & @CRLF) ; if bigger from 9*9 px then create note If ($aRecPos[2] - $aRecPos[0]) > 9 And ($aRecPos[3] - $aRecPos[1]) > 9 Then CreateNew_NoteGui($aRecPos) ; create new note ;Return $FilePath EndFunc ;==>NewCapture ;---------------------------------------------------------------------------------------- Func CreateNew_NoteGui($aRecPos) ; create new note gui Local $n, $aSize[2] ReDim $NoteGui[UBound($NoteGui) + 1][18] $NoteGui[0][0] += 1 $n = $NoteGui[0][0] $aSize[0] = $aRecPos[2] - $aRecPos[0] ; width $aSize[1] = $aRecPos[3] - $aRecPos[1] ; height ; create note GUI $NoteGui[$n][0] = GUICreate($NoteGui[$n][1], $aSize[0], $aSize[1], $aRecPos[0], $aRecPos[1], $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_RESIZED, "GUI_EVENT", $NoteGui[$n][0]) ; jpg Path for _ScreenCapture_Capture $NoteGui[$n][1] = @ScriptDir & "\tmp\image_" & $NoteGui[$n][0] & ".jpg" _ScreenCapture_Capture($NoteGui[$n][1], $aRecPos[0], $aRecPos[1], $aRecPos[2], $aRecPos[3]) ; save the Gui_Size $NoteGui[$n][2] = $aSize ; set jpg Path as GUI title WinSetTitle($NoteGui[$n][0], "", $NoteGui[$n][1]) ; Creates a Picture control $NoteGui[$n][3] = GUICtrlCreatePic($NoteGui[$n][1], 0, 0, 0, 0, -1, $GUI_WS_EX_PARENTDRAG) ; Creates a Label control just for $SS_GRAYFRAME GUICtrlCreateLabel("", 0, 0, $aSize[0], $aSize[1], $SS_GRAYFRAME) ; Creates a context menu $NoteGui[$n][4] = GUICtrlCreateContextMenu($NoteGui[$n][3]) ; MenuItem for the context menu "Copy to Clipboard" $NoteGui[$n][5] = GUICtrlCreateMenuItem("Copy to Clipboard" & @TAB & "ENTER", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_CopyToClipboard") ; MenuItem for the context menu "ID_cMenuShareX" $NoteGui[$n][6] = GUICtrlCreateMenuItem("Send to ShareX", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_ShareX") ; MenuItem for the context menu "Save as..." $NoteGui[$n][7] = GUICtrlCreateMenuItem("Save as...", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_SaveAs") ; MenuItem for the context menu "Open" $NoteGui[$n][8] = GUICtrlCreateMenuItem("Open", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_Open") ; separator GUICtrlCreateMenuItem("", $NoteGui[$n][4]) ; Check for Language (maximal 4) ; $NoteGui[0][11] = "ID_Lang1" ; $NoteGui[0][12] = "ID_Lang2" ; $NoteGui[0][13] = "ID_Lang3" ; $NoteGui[0][14] = "ID_Lang4" For $i = 0 To $iLanguagesCnt ;UBound($aSupportedLanguages) - 1 If $i > 4 Then ExitLoop ; MenuItem for the context menu "OCR - Language $i" $NoteGui[$n][11 + $i] = GUICtrlCreateMenuItem("OCR - " & $aSupportedLanguages[$i][1], $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_OCR_Lang_" & $i + 1) ;ConsoleWrite($i & " - Language: " & $aSupportedLanguages[$i][1] & " - " & $aSupportedLanguages[$i][0] & @CRLF) Next ; separator GUICtrlCreateMenuItem("", $NoteGui[$n][4]) ; MenuItem for the context menu "Close" $NoteGui[$n][15] = GUICtrlCreateMenuItem("Close" & @TAB & "DELETE", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_Close") ; Display the GUI. GUISetState(@SW_SHOW, $NoteGui[$n][0]) $NoteGui[$n][16] = GUICtrlCreateDummy() $NoteGui[$n][17] = GUICtrlCreateDummy() Local $aAccelKeys[2][2] = [["{DELETE}", $NoteGui[$n][16]], ["{ENTER}", $NoteGui[$n][17]]] GUISetAccelerators($aAccelKeys) GUICtrlSetOnEvent($NoteGui[$n][16], "cm_Close") GUICtrlSetOnEvent($NoteGui[$n][17], "cm_CopyToClipboard") Return $NoteGui[$n][0] EndFunc ;==>CreateNew_NoteGui ;---------------------------------------------------------------------------------------- Func SaveFileDlg($Active_title) ; Save file Dialog ; Create a constant variable in Local scope of the message to display in FileSaveDialog. Local Const $sMessage = "Choose a filename." ; Display a save dialog to select a file. Local $sFileSaveDialog = FileSaveDialog($sMessage, @ScriptDir & "\SET\", "image (*.jpg)", $FD_PATHMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was saved.") Else ; Retrieve the filename from the filepath e.g. Example.jpg Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSEBASIC, -1)) ; Check if the extension .jpg is appended to the end of the filename. Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSEBASIC) ; If a period (dot) is found then check whether or not the extension is equal to .jpg If $iExtension Then ; If the extension isn't equal to .jpg then append to the end of the filepath. If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".jpg") Then $sFileSaveDialog &= ".jpg" Else ; If no period (dot) was found then append to the end of the file. $sFileSaveDialog &= ".jpg" EndIf ; Display the saved file. ;ConsoleWrite("You saved the following file:" & @CRLF & $sFileSaveDialog & @CRLF) FileCopy($Active_title, $sFileSaveDialog, $FC_OVERWRITE + $FC_CREATEPATH) EndIf EndFunc ;==>SaveFileDlg ;---------------------------------------------------------------------------------------- Func NoteGui_Delete($hWnd) ; NoteGui_Delete For $i = 1 To $NoteGui[0][0] If $NoteGui[$i][0] = $hWnd Then _ArrayDelete($NoteGui, $i) $NoteGui[0][0] -= 1 ExitLoop EndIf Next EndFunc ;==>NoteGui_Delete ;---------------------------------------------------------------------------------------- Func PicToClip($Path) ; put image to clipboard (Thanks to @Nine) _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($Path) Local $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Local $hBitmap2 = _WinAPI_CopyImage($hBitmap1, $IMAGE_BITMAP, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_Shutdown() _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmap2, $CF_BITMAP) _ClipBoard_Close() _WinAPI_DeleteObject($hBitmap2) EndFunc ;==>PicToClip ;---------------------------------------------------------------------------------------- Func PerformOCR($ImagePath, $lang = Default) ; perform ocr (Thanks to @Danyfirex) ;_GetTextFromFile($sFileName, $iBorder = 20, $dScale = 1, $sLanguageTagToUse = Default, $bUseOcrLine = False) Local $Result = _GetTextFromFile($ImagePath, 20, 1, $lang) Local $Msg = @CRLF & @CRLF & _StringRepeat(@TAB, 4) & "Copy to ClipBoard ?" Local $iMsgBoxAnswer = MsgBox(4, "OCR Result", $Result & $Msg) If $iMsgBoxAnswer = 6 Then ;Yes ClipPut($Result) ToolTip("The text was copied to the clipboard") Sleep(1000) ToolTip("") EndIf EndFunc ;==>PerformOCR ;---------------------------------------------------------------------------------------- Func TRAY_EVENT() ; TRAY_Event Switch @TRAY_ID ; Check the last tray item identifier. Case $TRAY_EVENT_PRIMARYDOUBLE, $TRAY_NewCapture NewCapture() Case $TRAY_ExitScript DllClose($hDLL) Exit EndSwitch EndFunc ;==>TRAY_EVENT ;---------------------------------------------------------------------------------------- Func GUI_EVENT() ; GUI_EVENT Select Case @GUI_CtrlId = $GUI_EVENT_RESIZED Local $aSize For $i = 1 To $NoteGui[0][0] If $NoteGui[$i][0] = @GUI_WinHandle Then $aSize = $NoteGui[$i][2] WinMove(@GUI_WinHandle, "", Default, Default, $aSize[0], $aSize[1]) ControlMove(@GUI_WinHandle, "", "Static1", 0, 0, $aSize[0], $aSize[1]) ControlMove(@GUI_WinHandle, "", "Static2", 0, 0, $aSize[0], $aSize[1]) ExitLoop EndIf Next EndSelect EndFunc ;==>GUI_EVENT ;---------------------------------------------------------------------------------------- Func cm_CopyToClipboard() ; ContextMenu "Copy to Clipboard" Local $Active_title = WinGetTitle(@GUI_WinHandle) ToolTip("Copied to clipboard") PicToClip($Active_title) Sleep(500) ToolTip("") EndFunc ;==>cm_CopyToClipboard ;---------------------------------------------------------------------------------------- Func cm_ShareX() ; ContextMenu "Send to ShareX"" Local $Active_title = WinGetTitle(@GUI_WinHandle) PicToClip($Active_title) Sleep(100) Local $strLen = StringLen(@ScriptDir & "\tmp\image_") If StringLeft($Active_title, $strLen) = @ScriptDir & "\tmp\image_" Then GUIDelete(@GUI_WinHandle) FileDelete($Active_title) NoteGui_Delete(@GUI_WinHandle) EndIf ShellExecute("C:\Program Files\ShareX\ShareX.exe", "-imageeditor ") ; ℹ️ Give your path * <- Local $hShareXImageEd = WinWait("[TITLE:ShareX - Image editor; REGEXPCLASS:WindowsForms10\.Window\..\.app\.0\..+_r\d+_ad1]", "", 2) While WinExists($hShareXImageEd) ControlClick($hShareXImageEd, "", "[NAME:btnLoadImageFromClipboard]") Sleep(300) WEnd $hShareXImageEd = WinWait("[TITLE:ShareX - Image editor; REGEXPCLASS:WindowsForms10\.Window\..\.app\.0\..+_r\d+_ad1]", "", 2) WinActivate($hShareXImageEd) WinSetState($hShareXImageEd, "", @SW_MAXIMIZE) EndFunc ;==>cm_ShareX ;---------------------------------------------------------------------------------------- Func cm_SaveAs() ; ContextMenu "Save as..." Local $Active_title = WinGetTitle(@GUI_WinHandle) SaveFileDlg($Active_title) EndFunc ;==>cm_SaveAs ;---------------------------------------------------------------------------------------- Func cm_Open() ; ContextMenu "Open" Local $Active_title = WinGetTitle(@GUI_WinHandle) ShellExecute($Active_title) EndFunc ;==>cm_Open ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_1() ; ContextMenu "OCR - Language 0" Local $Active_title = WinGetTitle(@GUI_WinHandle) PerformOCR($Active_title, $aSupportedLanguages[0][0]) EndFunc ;==>cm_OCR_Lang_1 ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_2() ; ContextMenu "OCR - Language 1" Local $Active_title = WinGetTitle(@GUI_WinHandle) If $iLanguagesCnt > 1 Then PerformOCR($Active_title, $aSupportedLanguages[1][0]) EndFunc ;==>cm_OCR_Lang_2 ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_3() ; ContextMenu "OCR - Language 2" Local $Active_title = WinGetTitle(@GUI_WinHandle) If $iLanguagesCnt > 2 Then PerformOCR($Active_title, $aSupportedLanguages[2][0]) EndFunc ;==>cm_OCR_Lang_3 ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_4() ; ContextMenu "OCR - Language 3" Local $Active_title = WinGetTitle(@GUI_WinHandle) If $iLanguagesCnt > 3 Then PerformOCR($Active_title, $aSupportedLanguages[3][0]) EndFunc ;==>cm_OCR_Lang_4 ;---------------------------------------------------------------------------------------- Func cm_Close() ; ContextMenu "Close" Local $Active_title = WinGetTitle(@GUI_WinHandle) Local $strLen = StringLen(@ScriptDir & "\tmp\image_") If StringLeft($Active_title, $strLen) = @ScriptDir & "\tmp\image_" Then GUIDelete(@GUI_WinHandle) FileDelete($Active_title) NoteGui_Delete(@GUI_WinHandle) ;ConsoleWrite("- WinClose " & @GUI_WinHandle & " & FileDelete " & $Active_title & @CRLF) EndIf EndFunc ;==>cm_Close ;---------------------------------------------------------------------------------------- Func _Array_Gui_display() ; *** Debug _ArrayDisplay($NoteGui) _ArrayDisplay($NoteGui, "$NoteGui") EndFunc ;==>_Array_Gui_display ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GetTextFromFile ; Description ...: reading text from a picture file ; Syntax.........: _GetText($sFileName [, $iBorder = 20 [, $dScale = 1 [, $sLanguageTagToUse = Default [, $bUseOcrLine = False]]]]) ; Parameters ....: $sFileName Full path and extension of the image file ; $iBorder [optional] Draw a border araunt, The color is taken from first pixel ; $dScale [optional] Scale factor ; $sLanguageTagToUse [optional] Gets the language being used for text recognition ; $bUseOcrLine [optional] Represents a single line of text recognized by the OCR engine and returned as part of the OcrResult. ; Return value...: Success: Contains the String results of Optical Character Recognition (OCR). ; Failure: "" Empty String otherwise. ; On Error: false ; ; Author ........: ioa747 ; Notes .........: https://www.autoitscript.com/forum/topic/211521-ocr-from-a-small-area ;-------------------------------------------------------------------------------------------------------------------------------- Func _GetTextFromFile($sFileName, $iBorder = 20, $dScale = 1, $sLanguageTagToUse = Default, $bUseOcrLine = False) Local $hHBitmap, $hBitmap, $hImage, $hImageCtxt, $sOCRTextResult, $iBmpW, $iBmpH, $iBorderColor _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile($sFileName) $iBmpW = $dScale * _GDIPlus_ImageGetWidth($hBitmap) $iBmpH = $dScale * _GDIPlus_ImageGetHeight($hBitmap) ; Add Border If $iBorder > 0 Then $iBorderColor = _GDIPlus_BitmapGetPixel($hBitmap, 1, 1) ;get pixel color from 1,1 $hImage = _GDIPlus_BitmapCreateFromScan0($iBmpW + (2 * $iBorder), $iBmpH + (2 * $iBorder)) ;create an empty bitmap If @error Then Return SetError(3, 0, False) $hImageCtxt = _GDIPlus_ImageGetGraphicsContext($hImage) ;get the graphics context of the bitmap _GDIPlus_GraphicsSetSmoothingMode($hImageCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hImageCtxt, $iBorderColor) ;clear bitmap with color white _GDIPlus_GraphicsDrawImage($hImageCtxt, $hBitmap, $iBorder, $iBorder) _GDIPlus_ImageDispose($hBitmap) Else $hImage = $hBitmap EndIf $sOCRTextResult = _UWPOCR_GetText($hImage, $sLanguageTagToUse, $bUseOcrLine) If @error Then Return SetError(4, 0, False) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return $sOCRTextResult EndFunc ;==>_GetTextFromFile ;-------------------------------------------------------------------------------------------------------------------------------- Snipe new note Double Click the tray icon to start NewCapture or While Left Windows Key IsPressed, tap 2 times the Left Shift key (is useful when Capture menu or context menu). While start NewCapture point click anywhere to escape. (Does not catch smaller than 9*9 px) While start NewCapture escape with ESC Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    3 points
  14. Melba23

    furian

    I do hope this does not become a habit.... When, in your opinion, your thread is unfairly locked, the Mod team are always open to receiving a courteous and well-argued PM from you explaining why you felt your thread should not been. But sending a diatribe, incorrectly interpreting the forum rules, and trying to bully us into reopening it will not work. If you then send further meassages in the same vein you cannot really expect anything other then the inevitable. Particularly when challenging the Mod in question to ban you. M23
    3 points
  15. You can't directly connect to your wifi through the command prompt (eg. netsh), however there's always some work around. I've never worked with NETSH before, but I played around for a while with it. I'll be honest, I've never been a fan of using the command prompts of apps, for some reason I feel like I have less control. These are make-shift udfs I just put together, some were my practice funcs, but if you look at the ones I point out at the top, they may help you. The last one, if the first two function calls fail, is one where you can create a tmp xml file, add that profile, run the netsh command then delete the tmp xml file. All of these worked on the my Windows 10 machine. Should work on Windows 11 too from what I was reading. ;~ #RequireAdmin ; may need to have admin priviliges #include-once #include <AutoItConstants.au3> #include <StringConstants.au3> #include <FileConstants.au3> Global $gsMySSID_WifiName = "MyNetwork" ; obviously change it to your own network name If Not _AutNETSH_WLan_IsConnectedBy("SSID", $gsMySSID_WifiName) Then ConsoleWrite("Going to attempt to connect.." & @CRLF) _AutNETSH_WLan_ConnectionRequest($gsMySSID_WifiName) Sleep(5000) ; give it 5 seconds and check if it worked If Not _AutNETSH_WLan_IsConnectedBy("SSID", $gsMySSID_WifiName) Then ConsoleWrite("Still not connected, does the profile exist yet?" & @CRLF & _ "If the profile doesn't exist, or the password/username changes often, try using: " & @CRLF & _ "_AutNETSH_WLan_AddConnectionRequest() below somwwhere..." & @CRLF) EndIf EndIf Func _AutNETSH_WLan_IsConnectedBy($sType, $sFind, $sWkDir = Default) ; because @error may return error text ; we'll just return yes or no string If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = Run("netsh wlan show interface", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf ; escape type and value to find $sType = __AutNETSH_WLan_EscapeDelimiters($sType) $sFind = __AutNETSH_WLan_EscapeDelimiters($sFind) Local $sStRE = "(*UCP)(?mi)\h*" & $sType & "\h*\:\h*" & $sFind & "\h*$" Return (StringRegExp($aRead[0], $sStRE) <> 0) EndFunc Func _AutNETSH_WLan_IsConnected($sWkDir = Default) ; because @error may return error text ; we'll just return yes or no string If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = Run("netsh wlan show interface", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local Const $sStRE = "(*UCP)(?mi)\h*state\h*\:\h*(\w+)" Local $aRet = StringRegExp($aRead[0], $sStRE, $STR_REGEXPARRAYGLOBALMATCH) If Not IsArray($aRet) Then Return SetError(2, 0, "") EndIf Return $aRet[0] EndFunc Func _AutNETSH_WLan_ConnectionRequest($sSSID, $sWkDir = Default) If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf ; connect to profile Local $iPID = Run('netsh wlan connect name="' & $sSSID & '"', $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Return $aRead[0] EndFunc Func _AutNETSH_WLan_AddConnectionRequest($sSSID, $sPassword, $sConnectionType = Default, _ $sConnectionMode = Default, $sAuthentication = Default, _ $sEncryption = Default, $sUseOneX = Default, $sKeyType = Default, _ $sProtected = Default, $sEnableRandomization = Default, _ $sWkDir = Default, $sTmpPath = Default) If $sConnectionType = Default Or $sConnectionType = -1 Then $sConnectionType = "ESS" EndIf If $sConnectionMode = Default Or $sConnectionMode = -1 Then $sConnectionMode = "auto" EndIf If $sAuthentication = Default Or $sAuthentication = -1 Then $sAuthentication = "WPA2PSK" EndIf If $sEncryption = Default Or $sEncryption = -1 Then $sEncryption = "AES" EndIf If $sUseOneX = Default Or $sUseOneX = -1 Then $sUseOneX = "false" EndIf If $sKeyType = Default Or $sKeyType = -1 Then $sKeyType = "passPhrase" EndIf If $sProtected = Default Or $sProtected = -1 Then $sProtected = "false" EndIf If $sEnableRandomization = Default Or $sEnableRandomization = -1 Then $sEnableRandomization = "false" EndIf If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf If $sTmpPath = Default Or $sTmpPath = -1 Or Not FileExists($sTmpPath) Then $sTmpPath = @ScriptDir EndIf Local $sXMLFile = "WLAN." & StringRegExpReplace($sSSID, "(*UCP)\W", "") $sXMLFile &= ".tmp(" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC & ").xml" Local $sOutXML = StringRegExpReplace($sTmpPath, "[\\/]+$", "") & "\" & $sXMLFile Local $sXML = "" $sXML &= '<?xml version="1.0"?>' & @CRLF $sXML &= ' <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">' & @CRLF $sXML &= ' <name>' & $sSSID & '</name>' & @CRLF $sXML &= ' <SSIDConfig>' & @CRLF $sXML &= ' <SSID>' & @CRLF $sXML &= ' <name>' & $sSSID & '</name>' & @CRLF $sXML &= ' </SSID>' & @CRLF $sXML &= ' </SSIDConfig>' & @CRLF $sXML &= ' <connectionType>' & $sConnectionType & '</connectionType>' & @CRLF $sXML &= ' <connectionMode>' & $sConnectionMode & '</connectionMode>' & @CRLF $sXML &= ' <MSM>' & @CRLF $sXML &= ' <security>' & @CRLF $sXML &= ' <authEncryption>' & @CRLF $sXML &= ' <authentication>' & $sAuthentication & '</authentication>' & @CRLF $sXML &= ' <encryption>' $sEncryption & '</encryption>' & @CRLF $sXML &= ' <useOneX>' & $sUseOneX & '</useOneX>' & @CRLF $sXML &= ' </authEncryption>' & @CRLF $sXML &= ' <sharedKey>' & @CRLF $sXML &= ' <keyType>' & $sKeyType & '</keyType>' & @CRLF $sXML &= ' <protected>' & $sProtected & '</protected>' & @CRLF $sXML &= ' <keyMaterial>' & $sPassword & '</keyMaterial>' & @CRLF $sXML &= ' </sharedKey>' & @CRLF $sXML &= ' </security>' & @CRLF $sXML &= ' </MSM>' & @CRLF $sXML &= ' <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">' & @CRLF $sXML &= ' <enableRandomization>' & $sEnableRandomization & '</enableRandomization>' & @CRLF $sXML &= ' </MacRandomization>' & @CRLF $sXML &= '</WLANProfile>' Local $hOpen = FileOpen($sOutXML, $FO_OVERWRITE) FileWrite($hOpen, $sXML) FileClose($hOpen) ; add profile to cache Local $iPID = Run('netsh wlan add profile filename="' & $sOutXML & '"', $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then FileDelete($sOutXML) Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local $sRet = $aRead[0] ; connect to profile $iPID = Run('netsh wlan connect name="' & $sSSID & '"', $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then FileDelete($sOutXML) Return SetError(2, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf FileDelete($sOutXML) $sRet &= " : " & $aRead[0] Return $sRet EndFunc Func _AutNETSH_WLan_ShowNetworks($sWkDir = Default) ; return network array If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = Run("netsh wlan show networks", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Or Not IsArray($aRead) Then Return SetError(1, @error, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local Const $sSSIDRE = "(?si)(SSID\h*\d+\h*\:\h*.+?)(?:\v{3,}|$)" Local $aSSIDs = StringRegExp($aRead[0], $sSSIDRE, $STR_REGEXPARRAYGLOBALMATCH) If @error Or Not IsArray($aSSIDs) Then Return SetError(2, @error, "") EndIf Local $aHeaders = __AutNETSH_WLan_stdoutgetheader($aSSIDs) If @error Then Return SetError(3, @error, "") EndIf Local $aHData = __AutNETSH_WLan_stdoutgethdata($aSSIDs, $aHeaders) If @error Then Return SetError(4, @error, "") EndIf Return $aHData EndFunc ; See RunAs() in help file, may need to sign on as admin acct Func _AutNETSH_WLan_ShowNetworksAsUser($sUserName, $sDomain, $sPassword, $sLogonFlag, $sWkDir = Default) ; return network array If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = RunAs($sUserName, $sDomain, $sPassword, $sLogonFlag, _ "netsh wlan show networks", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Or Not IsArray($aRead) Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local Const $sSSIDRE = "(?si)(SSID\h*\d+\h*\:\h*.+?)(?:\v{3,}|$)" Local $aSSIDs = StringRegExp($aRead[0], $sSSIDRE, $STR_REGEXPARRAYGLOBALMATCH) If @error Or Not IsArray($aSSIDs) Then Return SetError(2, @error, "") EndIf Local $aHeaders = __AutNETSH_WLan_stdoutgetheader($aSSIDs) If @error Then Return SetError(3, @error, "") EndIf Local $aHData = __AutNETSH_WLan_stdoutgethdata($aSSIDs, $aHeaders) If @error Then Return SetError(4, @error, "") EndIf Return $aHData EndFunc Func _AutNETSH_WLan_STDRead($iPID) $iPID = ProcessExists($iPID) If Not $iPID Then Return SetError(1, 0, 0) EndIf Local $sTmp, $sORead, $sOErr While ProcessExists($iPID) $sTmp = StdoutRead($iPID) If @error Then $sOErr = StderrRead($iPID) ExitLoop EndIf $sORead &= $sTmp WEnd ; clean up leading and traling $sORead = StringRegExpReplace($sORead, "(?s)^\s*|\s*$", "") $sOErr = StringRegExpReplace($sOErr, "(?s)^\s*|\s*$", "") Local $aRet[2] = [$sORead, $sOErr] If StringLen($sORead) = 0 Then Return SetError(1, 0, $aRet) EndIf Return $aRet EndFunc Func __AutNETSH_WLan_stdoutgetheader(ByRef $aData) If Not IsArray($aData) Then Return SetError(1, 0, 0) EndIf ; how many heades, some will have more/less based on connection type Local $iExt, $iHeaderCount = 0, $aHeaders For $i = 0 To UBound($aData) - 1 StringRegExpReplace($aData[$i], "(?m)\h+\:", "") $iExt = @extended If $iExt > $iHeaderCount Then $iHeaderCount = $iExt $aHeaders = StringRegExp($aData[$i], "(?m)\h*(.+?)\h+\:", $STR_REGEXPARRAYGLOBALMATCH) If IsArray($aHeaders) Then For $j = 0 To UBound($aHeaders) - 1 If StringInStr($aHeaders[$j], "SSID") Then $aHeaders[$j] = "SSID" ExitLoop EndIf Next EndIf EndIf Next If $iHeaderCount = 0 Then Return SetError(2, 0, 0) EndIf Return SetExtended($iHeaderCount, $aHeaders) EndFunc Func __AutNETSH_WLan_stdoutgethdata(ByRef $aData, ByRef $aHeaders) If Not IsArray($aData) Then Return SetError(1, 0, 0) EndIf If Not IsArray($aHeaders) Then Return SetError(2, 0, 0) EndIf ; [0][n] = headers Local $aRet[UBound($aData) + 1][UBound($aHeaders)] ; fill headers into ret array For $i = 0 To UBound($aHeaders) - 1 $aRet[0][$i] = $aHeaders[$i] ; turn headers into escaped chars $aHeaders[$i] = __AutNETSH_WLan_EscapeDelimiters($aHeaders[$i]) Next Local $aFound, $aLines, $iEnum, $iColCount = 0 ; start at 1, 0 is headers For $i = 0 To UBound($aData) - 1 $iEnum = 0 ; split into individual rows $aLines = StringRegExp($aData[$i], "\h*(.+?)\h*(\v+|$)", $STR_REGEXPARRAYGLOBALMATCH) For $x = 0 To UBound($aLines) - 1 For $j = 0 To UBound($aHeaders) - 1 If StringRegExp($aLines[$x], "(?i)^\h*" & $aHeaders[$j]) Then $aFound = StringRegExp($aLines[$x], "(?mi)\h*" & $aHeaders[$j] & ".*?\:\h*(.+?)\h*$", $STR_REGEXPARRAYGLOBALMATCH) If @error Or Not IsArray($aFound) Then ContinueLoop $aRet[$i + 1][$j] = $aFound[0] $iEnum += 1 ExitLoop EndIf Next Next If $iEnum > 0 Then $iColCount += 1 Next If $iColCount < UBound($aData) Then ; oops EndIf Return $aRet EndFunc Func __AutNETSH_WLan_EscapeDelimiters($sData) Local Const $sRE = "([\\\.\^\$\|\[|\]\(\)\{\}\*\+\?\#])" Local Const $sRep = "\\$1" Return StringRegExpReplace($sData, $sRE, $sRep) EndFunc If you're going to do this across a private network, you may want to look into RunAs(), I have one example function in there with that that you can kind of get the idea from. Anyway, I did more than I thought I would for something I can never see myself using... so hope it helps. Edit: You may need to change this section for enterprise: $sXML &= ' <authEncryption>' & @CRLF $sXML &= ' <authentication>WPA2PSK</authentication>' & @CRLF $sXML &= ' <encryption>AES</encryption>' & @CRLF $sXML &= ' <useOneX>false</useOneX>' & @CRLF $sXML &= ' </authEncryption>' & @CRLF I'm to lazy to make something that does it atm. Edit2: Changed _AutNETSH_WLan_AddConnectionRequest() so you can customize all the xml options if needed. I'm not 100% on WPA2 Enterprise, but it looks like you can change Authentication = WPA2 and Encryption to TKIP... anyway, really really really done this time
    3 points
  16. In my experience on this forum, both in the "old days" and now, I've found the people warm and welcoming and very helpful. As a guy who was generally the smartest guy in the room at almost every job I've held, I'm humbled by how much smarter the regulars are here. If @Nine @argumentum @Melba23 and some of the others comment on your thread, they are top talent, not just rando forum trolls on power trips. With that in mind, you do get what you put in: if you're willing to put in the effort, you'll get effort in return. If you're bitter/angry/combative/a dick because of your frustration, you'll get shut down. Frustration happens when you're banging you head against a thing that appears to make no sense, but please strip that out when you post your code That aside, AutoIt syntax is similar to VB (and because of that I've been able to learn a tiny bit of VB along the way but that's beside the point). The brackets are nested and denote optional arguments: for every "[" you have to have a matching, ending "]" to close it. Each argument is bracketed because they are independent. A single set of brackets would mean they all need to be included. The samples in the help really are a lifesaver. Run them, make changes, re-run them; learn and see how it works. When I started getting ahold on the fundamentals it was an exciting light bulb moment for me. I hope you'll have the same. As I said above, these are a great bunch of smart people and are very willing to help if you're showing the effort and leaving the most negative feelings on your side of the keyboard.
    3 points
  17. This UDF provides algorithms for fuzzy string comparison and the associated similarity search in string arrays. It offers functions for character-based comparisons, comparing the phonetics of words and the geometric distance of characters on a keyboard. In this way, typing errors can be recognized, similar-sounding words can be detected and other spellings of words can be included in further processing. The current function list of the UDF: --------- fuzzy array handling: _FS_ArraySearchFuzzy - finds similar entries for a search value in an array _FS_ArrayToPhoneticGroups - groups the values of an array according to their phonetics --------- character-based metrics: _FS_Levenshtein - calculate the levenshtein distance between two strings _FS_OSA - calculate the OSA ("optimal string alignment") between two strings _FS_Hamming - calculate the hamming distance between two strings --------- phonetic metrics: _FS_Soundex_getCode - calculate the soundex code for a given word to represent the pronounciation in english _FS_Soundex_distance - calculate the soundex-pattern for both input values _FS_SoundexGerman_getCode - calculate the modified soundex code for german language for a given word to represent the pronounciation in german _FS_SoundexGerman_distance - calculate the soundexGerman-pattern for both input values _FS_Cologne_getCode - calculate the cologne phonetics code for german language for a given word to represent the pronounciation in german _FS_Cologne_distance - calculate the cologne phonetics distance between both input values --------- key-position based metrics: _FS_Keyboard_GetLayout - return a map with coordinates for the characters for using in _FS_Keyboard_Distance_Chars() _FS_Keyboard_Distance_Chars - calculates the geometric key spacing between two characters on a keyboard _FS_Keyboard_Distance_Strings - calculate the keyboard-distance between two strings >>sourcecode and download on github<<
    3 points
  18. The tests previously conducted to assess the performance of the UDFs AutoItObject.au3 and AutoItObject_Internal.au3 under various conditions have highlighted discernible differences, albeit subtle. The analysis of the collected data underscores the slight preference in terms of speed for AutoItObject.au3. While this difference may not be considerable, it remains non-negligible in certain usage contexts. It is important to note that each UDF has its own advantages and disadvantages, which can influence their selection depending on the specific project requirements. The comparative table provided by @genius257 while informative, may spark debates and additional nuances regarding the evaluation of the performance and features of each UDF. Unfortunately, I no longer have the test code available.
    2 points
  19. ; This works. -> because it's a button, and $BM_SETIMAGE = 0xF7 is ButtonConstants GUICtrlSendMsg ($idButton, $BM_SETIMAGE, $IMAGE_ICON, DllStructGetData ($tResIcons, 1, 297)) GUICtrlCreateLabel ("This works.", 50, 100) Sleep (1000) ; Does not work. -> because it's not a button, -> $STM_SETIMAGE = 0x0172 is StaticConstants -> Now works GUICtrlSendMsg ($idIcon, $STM_SETIMAGE, $IMAGE_ICON, DllStructGetData ($tResIcons, 1, 297)) GUICtrlCreateLabel ("Now works.", 50, 220) https://learn.microsoft.com/en-us/windows/win32/controls/individual-control-info #include <ButtonConstants.au3> ; C:\Program Files (x86)\AutoIt3\Include\ButtonConstants.au3 #include <StaticConstants.au3> ; C:\Program Files (x86)\AutoIt3\Include\StaticConstants.au3
    2 points
  20. btw. Used several times today. It worked like a charm.
    2 points
  21. Nine

    Read controlID from INI file

    Well since radio buttons are mutually exclusive, there is no need to write the state of all radios, you just want the one checked within each group. I believe OP wants to have multiple groups of radio buttons. So the ini file would list the one button checked within each group. I agree there is other ways to perform what OP wants, and using actual names is not the best.
    2 points
  22. Ty @rsn for nudging me in correct direction https://newbedev.com/can-t-change-tel-protocol-handler-in-windows-10 did it Edit: something like this writeReg("HKEY_CURRENT_USER\SOFTWARE\Classes\callto", "", "URL:callto") writeReg("HKEY_CURRENT_USER\SOFTWARE\Classes\callto", "URL Protocol", "") writeReg("HKEY_CURRENT_USER\SOFTWARE\Classes\tel", "", "URL:tel") writeReg("HKEY_CURRENT_USER\SOFTWARE\Classes\tel", "URL Protocol", "") writeReg("HKEY_CURRENT_USER\SOFTWARE\Classes\dialer.callto\Shell\Open\Command", "", '"' & @ScriptDir & '\' & $appName & '.exe" "%1" /phone') writeReg("HKEY_CURRENT_USER\SOFTWARE\Dialer\Capabilities", "ApplicationDescription", "Dialer") writeReg("HKEY_CURRENT_USER\SOFTWARE\Dialer\Capabilities", "ApplicationName", "Dialer") writeReg("HKEY_CURRENT_USER\SOFTWARE\Dialer\Capabilities\URLAssociations", "callto", "dialer.callto") writeReg("HKEY_CURRENT_USER\SOFTWARE\Dialer\Capabilities\URLAssociations", "tel", "dialer.callto") writeReg("HKEY_CURRENT_USER\SOFTWARE\RegisteredApplications", "Dialer", "Software\Dialer\Capabilities") Func writeReg($p, $n, $v) If @error Or RegRead($p, $n) <> $v Then RegWrite($p, $n, "REG_SZ", $v) EndFunc ;==>writeReg
    2 points
  23. Jos

    SciTE and my script version

    What about this version: -- Perform before each save function PersonalTools:OnBeforeSave(path) local VersionPrefix = ";Version:" -- define the prefix for version line. needs to be the first string on a line if editor.Lexer == SCLEX_AU3 and path ~= "" then -- find version prefix in sourcecode local spos, epos = editor:findtext('^\\s*' .. VersionPrefix .. '\\s*[\\d\\.]*', SCFIND_REGEXP, 0) -- Update when found if spos then local dline = editor:textrange(spos, epos) -- get the text found local curversion = dline:match(VersionPrefix .. '%s*([%d%.]*)') -- retrive portion containing the number local orgpos = editor.CurrentPos -- save current pos local firstvisible = editor.FirstVisibleLine -- save first visible line of script olen = epos - spos -- calculate length of found version string local newversion = VersionPrefix .. string.format(" %.3f", curversion + 0.001) nlen = newversion:len() -- calculate length of new version string editor:SetSel(spos, epos) -- Set text to replace editor:ReplaceSel(newversion) -- replace old version string with new if epos <= editor.CurrentPos then editor:GotoPos(orgpos) -- set caret back to saved pos when we were before the xhanged text else editor:GotoPos(orgpos + nlen - olen) -- set caret back to saved pos when we were after the changed text end editor.FirstVisibleLine = firstvisible -- reset first visible line of script end end end
    2 points
  24. https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Lua/SciTE%20Pane%20API.htm My first .lua commands -- Update version of line with this format: -- ;Version: 1.001 -- on each save function PersonalTools:OnBeforeSave(path) if editor.Lexer == SCLEX_AU3 and path ~= "" then local spos, epos = editor:findtext('^\\s*;Version:\\s*[\\d\\.]*', SCFIND_REGEXP, 0) if spos then local dline = editor:textrange(spos, epos) local curversion = dline:match('Version:%s*([%d%.]*)') local cpos = editor.CurrentPos -- Sets the position of the caret. newversion = curversion + 0.001 editor:SetSel(spos, epos) editor:ReplaceSel(";Version: " .. string.format("%.3f", newversion)) editor:GotoPos(cpos) -- Set caret to a position and ensure it is visible. end end end
    2 points
  25. Hi, the reason for these "artefacts" is the accumulation of all rounding errors caused by the use of byte "colours" aka AARRGGBB. You will get better results when you calculate only with floating numbers. Unfortunately AutoIt is not able to "cast" a hex value into a float number (or i cannot remember it ^^), DEC() is able to cast hex into double but double is 64bit and does`nt fit into a 32bit "Pixel" AARRGGBB First to do is to store "floats" instead of AARRGGBB within the whole image Get the pixel value via _GDIPlus_BitmapGetPixel(), write this value into a dword struct which is on the same address as a float struct and read the dword (aka float) $floatstruct = DllStructCreate("float") $dwordstruct = DllStructCreate("dword", DllStructGetPtr($floatstruct)) ;AARRGGBB to float For $y = 0 To $Height - 1 For $x = 0 To $Width - 1 $oldPixel = Dec(Hex(_GDIPlus_BitmapGetPixel($Image, $x, $y), 2)) / 255 ;get float number between 0 and 1 DllStructSetData($floatstruct, 1, $oldPixel) ;write into float struct $oldPixel = DllStructGetData($dwordstruct, 1) ;read as dword (aka "pixel" AARRGGBB) _GDIPlus_BitmapSetPixel($Image, $x, $y, $oldPixel) ;store the float number as "pixel" AARRGGBB Next Next Now the "image" is an array of floats. In the next step you have to read the floating point numbers (aka oldpixel) via _GDIPlus_BitmapGetPixel(), calculate if more or less than 0.5 and set the newpixel value and set the the black or white pixel in the image and the quant_error For $y = 0 To $Height - 1 For $x = 0 To $Width - 1 $oldPixel = _GDIPlus_BitmapGetPixel($Image, $x, $y) ;pixel as dword DllStructSetData($dwordstruct, 1, $oldPixel) ;write into dwordstruct (place of floatstruct) $oldPixel = DllStructGetData($floatstruct, 1) ;read float If $oldPixel <= 0.5 Then $newpixel = 0 Else $newpixel = 1 EndIf _GDIPlus_BitmapSetPixel($Image, $x, $y, String("0xFF" & Hex($newpixel * 255, 2) & Hex($newpixel * 255, 2) & Hex($newpixel * 255, 2))) $quant_error = $oldPixel - $newpixel Now Floyd-Steinberg: As mentioned before, other languages can handle images and floating point numbers, I transferred dwords and floats via DllStructs. ;-------Floyd-Steinberg $pixel = _GDIPlus_BitmapGetPixel($Image, $x + 1, $y);get pixel integer/DWORD AARRGGBB DllStructSetData($dwordstruct, 1, $pixel) ;set into DWORD struct $col = DllStructGetData($floatstruct, 1) ;read float from DWORD $float = $col + (7 / 16 * $quant_error) ;calculate with float DllStructSetData($floatstruct, 1, $float) ;write into float struct $pixel = DllStructGetData($dwordstruct, 1) ;get dword from float and _GDIPlus_BitmapSetPixel($Image, $x + 1, $y, $pixel) ;write the "float" as a "pixel" which leads to the script: ;$aligncomment=60 #include <GDIPlus.au3> HotKeySet("{ESC}", "_exit") _GDIPlus_Startup() Global $Image = _GDIPlus_BitmapCreateFromFile("graytest.png") ;~ Global $Image = _GDIPlus_BitmapCreateFromFile("dithercompare.png") ;~ Global $Image = _GDIPlus_BitmapCreateFromFile("test50.png") Global $Width = _GDIPlus_ImageGetWidth($Image), $Height = _GDIPlus_ImageGetHeight($Image) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Height = ' & $Height & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Width = ' & $Width & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Gui = GUICreate("Floyd-Steinberg Dithering", $Width, $Height) GUISetState() $Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui) _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) $floatstruct = DllStructCreate("float") $dwordstruct = DllStructCreate("dword", DllStructGetPtr($floatstruct)) ;AARRGGBB to float For $y = 0 To $Height - 1 For $x = 0 To $Width - 1 $oldPixel = Dec(Hex(_GDIPlus_BitmapGetPixel($Image, $x, $y), 2)) / 255 ;get float number between 0 and 1 DllStructSetData($floatstruct, 1, $oldPixel) ;write into float struct $oldPixel = DllStructGetData($dwordstruct, 1) ;read as dword (aka "pixel" AARRGGBB) _GDIPlus_BitmapSetPixel($Image, $x, $y, $oldPixel) ;store the float number as "pixel" AARRGGBB Next Next _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) ;show image with "floats" For $y = 0 To $Height - 1 For $x = 0 To $Width - 1 $oldPixel = _GDIPlus_BitmapGetPixel($Image, $x, $y) ;pixel as dword DllStructSetData($dwordstruct, 1, $oldPixel) ;write into dwordstruct (place of floatstruct) $oldPixel = DllStructGetData($floatstruct, 1) ;read float If $oldPixel <= 0.5 Then $newpixel = 0 Else $newpixel = 1 EndIf _GDIPlus_BitmapSetPixel($Image, $x, $y, String("0xFF" & Hex($newpixel * 255, 2) & Hex($newpixel * 255, 2) & Hex($newpixel * 255, 2))) $quant_error = $oldPixel - $newpixel ;-------Floyd-Steinberg $pixel = _GDIPlus_BitmapGetPixel($Image, $x + 1, $y);get pixel integer/DWORD AARRGGBB DllStructSetData($dwordstruct, 1, $pixel) ;set into DWORD struct $col = DllStructGetData($floatstruct, 1) ;read float from DWORD $float = $col + (7 / 16 * $quant_error) ;calculate with float DllStructSetData($floatstruct, 1, $float) ;write into float struct $pixel = DllStructGetData($dwordstruct, 1) ;get dword from float and _GDIPlus_BitmapSetPixel($Image, $x + 1, $y, $pixel) ;write the "float" as a "pixel" $pixel = _GDIPlus_BitmapGetPixel($Image, $x - 1, $y + 1) DllStructSetData($dwordstruct, 1, $pixel) ;set into DWORD struct $col = DllStructGetData($floatstruct, 1) ;read float from DWORD $float = $col + (3 / 16 * $quant_error) ;calculate with float DllStructSetData($floatstruct, 1, $float) ;write into float struct $pixel = DllStructGetData($dwordstruct, 1) ;get dword from float and _GDIPlus_BitmapSetPixel($Image, $x - 1, $y + 1, $pixel) $pixel = _GDIPlus_BitmapGetPixel($Image, $x, $y + 1) DllStructSetData($dwordstruct, 1, $pixel) ;set into DWORD struct $col = DllStructGetData($floatstruct, 1) ;read float from DWORD $float = $col + (5 / 16 * $quant_error) ;calculate with float DllStructSetData($floatstruct, 1, $float) ;write into float struct $pixel = DllStructGetData($dwordstruct, 1) ;get dword from float and _GDIPlus_BitmapSetPixel($Image, $x, $y + 1, $pixel) $pixel = _GDIPlus_BitmapGetPixel($Image, $x + 1, $y + 1) DllStructSetData($dwordstruct, 1, $pixel) ;set into DWORD struct $col = DllStructGetData($floatstruct, 1) ;read float from DWORD $float = $col + (1 / 16 * $quant_error) ;calculate with float DllStructSetData($floatstruct, 1, $float) ;write into float struct $pixel = DllStructGetData($dwordstruct, 1) ;get dword from float and _GDIPlus_BitmapSetPixel($Image, $x + 1, $y + 1, $pixel) Next _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) ; to see the errors quick instead of waiting for the whole image Next _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) While GUIGetMsg <> -3 Sleep(10) WEnd Func _exit() Exit EndFunc ;==>_exit Interesting side effect: If an image is filled with 50% gray the result of Floyd-Steinberg should be a checkboard pattern. In the "real world", floating point numbers have restrictions, mentioned hundrets of thousands of times here in this forum.... So at the end, in the "real world" (of floating point numbers) there is an error which shows some artefacts in the "checkboard" pattern ( 50% gray as test50.png). These errors are inevitably and independant of the used computer language. Floyd Steinberg dithering.zip
    2 points
  26. ioa747

    Round buttons

    collection of round buttons ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RoundButtons.au3 ; Description.....: collection of round buttons ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $MyGui, $aBtn[7][2] Example() Func Example() $MyGui = GUICreate(" My GUI Icons", 300, 500) $aBtn[0][0] = 6 ; cnt of buttons $aBtn[1][1] = "red" $aBtn[1][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[1][1] & "_normal.ico", 0, 20, 20, 64, 64, $SS_NOTIFY) $aBtn[2][1] = "yellow" $aBtn[2][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[2][1] & "_normal.ico", 0, 20, 100, 64, 64, $SS_NOTIFY) $aBtn[3][1] = "green" $aBtn[3][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[3][1] & "_normal.ico", 0, 20, 180, 64, 64, $SS_NOTIFY) $aBtn[4][1] = "turquoise" $aBtn[4][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[4][1] & "_normal.ico", 0, 20, 260, 64, 64, $SS_NOTIFY) $aBtn[5][1] = "cyan" $aBtn[5][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[5][1] & "_normal.ico", 0, 20, 340, 64, 64, $SS_NOTIFY) $aBtn[6][1] = "magenta" $aBtn[6][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[6][1] & "_normal.ico", 0, 20, 420, 64, 64, $SS_NOTIFY) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $aBtn[1][0] ConsoleWrite($aBtn[1][1] & @CRLF) Case $aBtn[2][0] ConsoleWrite($aBtn[2][1] & @CRLF) Case $aBtn[3][0] ConsoleWrite($aBtn[3][1] & @CRLF) Case $aBtn[4][0] ConsoleWrite($aBtn[4][1] & @CRLF) Case $aBtn[5][0] ConsoleWrite($aBtn[5][1] & @CRLF) Case $aBtn[6][0] ConsoleWrite($aBtn[6][1] & @CRLF) EndSwitch _IsOver() WEnd GUIDelete() EndFunc ;==>Example Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_normal.ico") EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then If $iClicked = 0 Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_click.ico") $iClicked = 1 Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") $iClicked = 0 EndIf EndIf Next EndIf EndFunc ;==>_IsOver Extract buttons folder in @ScriptDir Buttons.zip Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    2 points
  27. ioa747

    Round buttons

    Method for Colorful Rectangle Buttons ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RectButtonsSpecial.au3 ; Description.....: collection of rectangles buttons - Special Edition ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; ~~~~~~~~~~~~~~~~~ Example - what is ColorLight() Global $test = ColorLight(0xC800C8, 50) ConsoleWrite($test & @CRLF) $test = ColorLight(0xC800C8, 50, 1) ConsoleWrite($test & @CRLF) $test = ColorLight(0xC800C8, 50, 2) ConsoleWrite(StringFormat("RGB(%d,%d,%d)", $test[0], $test[1], $test[2]) & @CRLF & @CRLF) ; ~~~~~~~~~~~~ End of Example - what is ColorLight() Global $MyGui, $aBtn[6][2], $btnColor = 0xC800C8 $MyGui = GUICreate(@ScriptName, 180, 220) GUISetBkColor(0x000000) $aBtn[0][0] = 5 ; cnt of buttons $aBtn[1][0] = GUICtrlCreateLabel("Button1", 10, 20, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[1][1] = 0xA64500 GUICtrlSetBkColor(-1, $aBtn[1][1]) $aBtn[2][0] = GUICtrlCreateLabel("Button2", 10, 60, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[2][1] = 0x826E00 GUICtrlSetBkColor(-1, $aBtn[2][1]) $aBtn[3][0] = GUICtrlCreateLabel("Button3", 10, 100, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[3][1] = 0x268000 GUICtrlSetBkColor(-1, $aBtn[3][1]) $aBtn[4][0] = GUICtrlCreateLabel("Button4", 10, 140, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[4][1] = 0x0094FF GUICtrlSetBkColor(-1, $aBtn[4][1]) $aBtn[5][0] = GUICtrlCreateLabel("Button5", 10, 180, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[5][1] = 0x9600D5 GUICtrlSetBkColor(-1, $aBtn[5][1]) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch _IsOver() WEnd ;-------------------------------------------------------------------------------------------------------------------------------- Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], 30)) ;hover Else GUICtrlSetBkColor($aBtn[$i][0], $aBtn[$i][1]) ;normal EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then If $iClicked = 0 Then GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], -30)) ;click GUICtrlSetFont($aBtn[$i][0], 10, 800, 2, "MS Sans Serif") GUICtrlSetColor($aBtn[$i][0], 0xCCCCCC) $iClicked = 1 Else GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], 30)) ;hover GUICtrlSetFont($aBtn[$i][0], 10, 800, 0, "MS Sans Serif") GUICtrlSetColor($aBtn[$i][0], 0xFFFFFF) $iClicked = 0 _ButtonCaller($aBtn[$i][0]) EndIf EndIf Next EndIf EndFunc ;==>_IsOver ;-------------------------------------------------------------------------------------------------------------------------------- Func _ButtonCaller($Btn) Switch $Btn Case $aBtn[1][0] ConsoleWrite(GUICtrlRead($aBtn[1][0]) & @CRLF) Case $aBtn[2][0] ConsoleWrite(GUICtrlRead($aBtn[2][0]) & @CRLF) Case $aBtn[3][0] ConsoleWrite(GUICtrlRead($aBtn[3][0]) & @CRLF) Case $aBtn[4][0] ConsoleWrite(GUICtrlRead($aBtn[4][0]) & @CRLF) Case $aBtn[5][0] ConsoleWrite(GUICtrlRead($aBtn[5][0]) & @CRLF) Case $aBtn[6][0] ConsoleWrite(GUICtrlRead($aBtn[6][0]) & @CRLF) EndSwitch EndFunc ;==>_ButtonCaller ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: ColorLight() ; Description....: Returns a new color that is a combination of the $HexColor plus the amount of $Lightness it adds to all three RGB channels. ; Syntax.........: ColorLight($HexColor [, $Lightness [,$output]]) ; Parameters.....: $HexColor - The start color to be combined. ; $Lightness - The amount it adds to all three RGB channels. Negative number to subtract (darker) ; $output - Optional: The format of the output string: ; 0 = "0x" followed by the hexadecimal value of the new color (default) ; 1 = "#" followed by the hexadecimal value of the new color ; 2 = an array containing the red, green and blue values of the new color ; Return values..: The new color as a string or an array. ; Author ........: ioa747 ; Notes .........: ;-------------------------------------------------------------------------------------------------------------------------------- Func ColorLight($HexColor, $Lightness = 0, $sOutput = 0) If StringLeft($HexColor, 1) = "#" Then $HexColor = StringReplace($HexColor, "#", "0x") Local $sHexColor = Hex($HexColor, 6) ;ConsoleWrite("$sHexColor=" & $sHexColor & @CRLF) Local $aSplit = StringSplit($sHexColor, "") Local $aRGB[3] If $aSplit[0] = 6 Then $aRGB[0] = Dec($aSplit[1] & $aSplit[2], 0) $aRGB[1] = Dec($aSplit[3] & $aSplit[4], 0) $aRGB[2] = Dec($aSplit[5] & $aSplit[6], 0) ;ConsoleWrite(StringFormat("aRGB(%d,%d,%d)", $aRGB[0], $aRGB[1], $aRGB[2]) & @CRLF) Else ConsoleWrite("Something wrong $aSplit[0]=" & $aSplit[0] & @CRLF) Return SetError(1, 0, -1) EndIf Local $aNewRGB[] = [$aRGB[0] + $Lightness, $aRGB[1] + $Lightness, $aRGB[2] + $Lightness] If $aNewRGB[0] < 0 Then $aNewRGB[0] = 0 If $aNewRGB[0] > 255 Then $aNewRGB[0] = 255 If $aNewRGB[1] < 0 Then $aNewRGB[1] = 0 If $aNewRGB[1] > 255 Then $aNewRGB[1] = 255 If $aNewRGB[2] < 0 Then $aNewRGB[2] = 0 If $aNewRGB[2] > 255 Then $aNewRGB[2] = 255 ;ConsoleWrite(StringFormat("aNewRGB(%d,%d,%d)", $aNewRGB[0], $aNewRGB[1], $aNewRGB[2]) & @CRLF) Local $sColor ;$sOutput: 0:="0x" | 1:="#" | 2:=aRGB[R,G,B] Switch $sOutput Case 0, 1 $sColor = ($sOutput = 1 ? "#" : "0x") $sColor &= Hex(String($aNewRGB[0]), 2) $sColor &= Hex(String($aNewRGB[1]), 2) $sColor &= Hex(String($aNewRGB[2]), 2) ;ConsoleWrite("$sColor=" & $sColor & @CRLF & @CRLF) Case 2 $sColor = $aNewRGB EndSwitch Return $sColor EndFunc ;==>ColorLight ;-------------------------------------------------------------------------------------------------------------------------------- have fun Thank you very much
    2 points
  28. Finally I found what was the culprit: a very old FF window which got shifted at the extreme corner of a desktop, making it essentially invisible. The only tab it carried was the one I was after in another tab of another FF window, but was set to a different part of the website. I confess having permanently 15-30 FF windows and many tabs each, all always open. Hard for me to do with much less. So everything works with the initial simple code and I flatly apologize for the noise and for wasting your time.
    2 points
  29. You must be aware of bit fields declarations. For InterfaceAndOperStatusFlags it will be used one byte, not 8 bytes: struct { BOOLEAN HardwareInterface : 1; BOOLEAN FilterInterface : 1; BOOLEAN ConnectorPresent : 1; BOOLEAN NotAuthenticated : 1; BOOLEAN NotMediaConnected : 1; BOOLEAN Paused : 1; BOOLEAN LowPower : 1; BOOLEAN EndPointInterface : 1; } InterfaceAndOperStatusFlags; Local $sTAG_InterfaceAndOperStatusFlags = "boolean HardwareInterface;boolean FilterInterface;boolean ConnectorPresent;boolean NotAuthenticated;boolean NotMediaConnected;boolean Paused;boolean LowPower;boolean EndPointInterface;" Local $tInterfaceAndOperStatusFlags = DllStructCreate($sTAG_InterfaceAndOperStatusFlags) ConsoleWrite(DllStructGetSize($tInterfaceAndOperStatusFlags) & @CRLF)
    2 points
  30. I can share the code, no problem dude, it's just a bunch of methods and clicks. BIG WARNING: I put up the fastest and ugliest code to make the thing work because I needed to upload a lot of stuff. Even if it's horrible code, it still saved me a TON of time and I uploaded in an afternoon what would have took me 2 weeks. So I'm happy for the result anyway. That said, I also need to tell you that it needs a lot of polishing and testing. If you wish I can post more as I progress into developing it, but I do it in my free time and it will take some time to add missing features and refactor the code in a more ordered and organized way. It's far from perfect and completed and I plan to add a ton of stuff, but here you go: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> ;TODO ;F-01 Filtro lista file? ;F-02 Gestione cartelle ;DONE - F-03 Flag resetta numero file dopo caricamento cartella ;F-04 Btn selezione deseleziona tutte le opzioni ;F-05 Flag scrivi lista dei file ;F-06 Eventuale index per corsi caricati a topic singolo ;BUGS ;B-01: Alcune immagini sono renderizzate nel popup di upload diversamente (vedi corso L1 Calimove) e questo fa saltare l'upload, andrebbe considerato un detect ;grafico del bottone save visto che la UI non si riesce a catturare? ;B-02 BIG FIX: I made a lot of mess for finding "Send" button in upload screen. Instead ;it's just sufficient to send {ENTER} and no detection at all is needed. Damn :D Opt('GUIOnEventMode', '1') HotKeySet('!p', '_Exit') #Region ### START Koda GUI section ### Form= ;CREATE FORM $TgUpperForm = GUICreate("TGUpper", 713, 677, 192, 124) ;CREATE LISTVIEW $ListView1 = GUICtrlCreateListView("", 208, 32, 490, 574) _GUICtrlListView_InsertColumn($ListView1, 0, "File", 380) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 400) ;CREATE TOP BUTTONS $btnSelectFolder = GUICtrlCreateButton("Select Folder", 8, 8, 195, 25) $btnSelectFile = GUICtrlCreateButton("Select File", 8, 40, 195, 25) $btnCreateTopic = GUICtrlCreateButton("Create Topic", 8, 72, 195, 25) $btnSelectAll = GUICtrlCreateButton("Select All", 8, 104, 195, 25) ;CREATE GRUP FOLDER PROGRESSIVE $grpFolderProgressive = GUICtrlCreateGroup("Folder Progressive", 8, 136, 193, 209) $txtPrefixFolderProgressive = GUICtrlCreateInput("", 16, 272, 49, 21) $btnIncreaseFolderProgressiveCounter = GUICtrlCreateButton("+", 16, 176, 43, 25) $txtPostfixFolderProgressive = GUICtrlCreateInput("", 144, 272, 49, 21) $btnDecreaseFolderProgressiveCounter = GUICtrlCreateButton("-", 64, 176, 43, 25) $txtCounterFolderProgressive = GUICtrlCreateInput("0", 80, 272, 49, 21) $btnResetFolderProgressiveCounter = GUICtrlCreateButton("Reset", 112, 176, 75, 25) $chkEnableFolderProgressive = GUICtrlCreateCheckbox("Enable Folder Progressive", 16, 152, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAutoIncrementFolderProgressiveCounter = GUICtrlCreateCheckbox("Autoincrement", 16, 208, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) $lblPrefixFolderProgressive = GUICtrlCreateLabel("Prefix", 16, 248, 30, 17) $lblCounterFolderProgressive = GUICtrlCreateLabel("Counter", 80, 248, 41, 17) $lblPostfixCounterprogressive = GUICtrlCreateLabel("Postfix", 144, 248, 35, 17) $lblFolderProgressiveSeparator = GUICtrlCreateLabel("Separator", 128, 208, 50, 17) $txtFolderProgressiveSeparator = GUICtrlCreateInput(" ", 128, 224, 57, 21) $txtReplaceTextInTopicName = GUICtrlCreateInput("", 16, 312, 177, 21) $lblReplaceTextInTopicName = GUICtrlCreateLabel("Text to replace in topic name", 16, 296, 141, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) ;CREATE GROUP FILE PROGRESSIVE $grpFileProgressive = GUICtrlCreateGroup("File Progressive", 8, 352, 193, 193) $txtPrefixFileProgressive = GUICtrlCreateInput("", 16, 488, 49, 21) $btnIncreaseFileProgressiveCounter = GUICtrlCreateButton("+", 16, 392, 43, 25) $txtPostfixFileProgressive = GUICtrlCreateInput("", 144, 488, 49, 21) $btnDecreaseFileProgressiveCounter = GUICtrlCreateButton("-", 64, 392, 43, 25) $txtCounterFileProgressive = GUICtrlCreateInput("1", 80, 488, 49, 21) $btnResetFileProgressiveCounter = GUICtrlCreateButton("Reset", 112, 392, 75, 25) $chkEnableFileProgressive = GUICtrlCreateCheckbox("Enable File Progressive", 16, 368, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAutoIncrementFileProgressiveCounter = GUICtrlCreateCheckbox("Autoincrement", 16, 424, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $lblPrefixFileProgressive = GUICtrlCreateLabel("Prefix", 16, 464, 30, 17) $lblCounterFileProgressive = GUICtrlCreateLabel("Counter", 80, 464, 41, 17) $lblPostfixFileProgressive = GUICtrlCreateLabel("Postfix", 144, 464, 35, 17) $txtFileProgressiveSeparator = GUICtrlCreateInput(" ", 128, 440, 57, 21) $lblFileProgressiveSeparator = GUICtrlCreateLabel("Separator", 128, 424, 50, 17) $chkResetFileProgressiveCounterOnReopenFolderOrdFile = GUICtrlCreateCheckbox("Reset count after file/folder open", 16, 520, 177, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;CREATE BOTTOM BUTTONS $chkRefocusFormAfterTopicCreation = GUICtrlCreateCheckbox("Refocus form after creating topic", 16, 555, 177, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAutoLoadFilesAfterTopic = GUICtrlCreateCheckbox("Autoload files after topic creation", 16, 577, 185, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAskEveryFile = GUICtrlCreateCheckbox("Ask confirmation for every file", 16, 619, 185, 17) $chkElaborateAllFolders = GUICtrlCreateCheckbox("Elaborate all folders automatically", 16, 598, 177, 17) $btnProcessFiles = GUICtrlCreateButton("Process selected files", 8, 640, 195, 25) GUICtrlSetState($btnProcessFiles, $GUI_DISABLE) ;CREATE UPPER LISTVIEW LABELS $lblCurrentFolderDesc = GUICtrlCreateLabel("Current folder", 208, 8, 67, 17) $lblNextFolderDesc = GUICtrlCreateLabel("Next folder", 456, 8, 55, 17) $txtCurrentFolder = GUICtrlCreateInput("-", 280, 5, 169, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $txtNextFolder = GUICtrlCreateInput("-", 512, 5, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;CREATE LOWER LISTVIEW BUTTONS/LABELS $chkNextFolderAutoSwap = GUICtrlCreateCheckbox("Auto swap next folder", 224, 616, 121, 17) $btnOpenFolder = GUICtrlCreateButton("Open Folder", 352, 612, 139, 25) $btnSwapNextFolder = GUICtrlCreateButton("Next Folder", 504, 612, 195, 25) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $actionsdelay = 2200 Global $actionsdelay_short = 700 Global $actionsdelay_very_short = 400 Global $lastButtonClicked = "" Global $folder = "" Global $nextFolder = "" GUICtrlSetOnEvent($btnSelectFolder, "SelectFolder") GUICtrlSetOnEvent($btnSelectFile, "SelectFile") GUICtrlSetOnEvent($btnCreateTopic, "CreateTopic") GUICtrlSetOnEvent($btnIncreaseFolderProgressiveCounter, "IncreaseFolderProgressiveCounter") GUICtrlSetOnEvent($btnDecreaseFolderProgressiveCounter, "DecreaseFolderProgressiveCounter") GUICtrlSetOnEvent($btnResetFolderProgressiveCounter, "ResetFolderProgressiveCounter") GUICtrlSetOnEvent($btnIncreaseFileProgressiveCounter, "IncreaseFileProgressiveCounter") GUICtrlSetOnEvent($btnDecreaseFileProgressiveCounter, "DecreaseFileProgressiveCounter") GUICtrlSetOnEvent($btnResetFileProgressiveCounter, "ResetFileProgressiveCounter") GUICtrlSetOnEvent($btnProcessFiles, "ProcessFiles") GUICtrlSetOnEvent($btnSelectAll, "SelectAll") GUICtrlSetOnEvent($btnSwapNextFolder, "SwapNextFolder") GUICtrlSetOnEvent($chkNextFolderAutoSwap, "_chkNextFolderAutoSwap") GUICtrlSetOnEvent($chkAutoLoadFilesAfterTopic, "_chkAutoLoadFilesAfterTopic") While 1 Sleep(100) WEnd Func SelectFolder() $folder = FileSelectFolder("Select a folder", "") If @error Then MsgBox($MB_OK, "Error", "No folder selected.") Return EndIf $files = _FileListToArray($folder, "*", 1) If @error Then MsgBox($MB_OK, "Error", "No files found in the selected folder.") Return EndIf UpdateFileList($files) $lastButtonClicked = "SelectFolder" If GUICtrlRead($chkResetFileProgressiveCounterOnReopenFolderOrdFile) = $GUI_CHECKED Then ResetFileProgressiveCounter() EndIf UpdateCurrentFolderDisplay() UpdateNextFolderDisplay() UpdateSwapNextFolderButton() UpdateProcessFilesButton() SelectAll() EndFunc Func SelectFile() $selectedFile = FileOpenDialog("Select a file", @WorkingDir, "All files (.)", 1) If @error Then MsgBox($MB_OK, "Error", "No file selected.") Return EndIf $files = StringSplit($selectedFile, "|", 1) UpdateFileList($files) $lastButtonClicked = "SelectFile" If GUICtrlRead($chkResetFileProgressiveCounterOnReopenFolderOrdFile) = $GUI_CHECKED Then ResetFileProgressiveCounter() EndIf UpdateCurrentFolderDisplay() UpdateNextFolderDisplay() UpdateSwapNextFolderButton() UpdateProcessFilesButton() EndFunc Func UpdateFileList($files) _GUICtrlListView_DeleteAllItems($ListView1) For $i = 1 To UBound($files) - 1 If Not StringIsDigit($files[$i]) Then _GUICtrlListView_AddItem($ListView1, $files[$i]) EndIf Next EndFunc Func IncreaseFolderProgressiveCounter() $folderCounter = Int(GUICtrlRead($txtCounterFolderProgressive)) + 1 GUICtrlSetData($txtCounterFolderProgressive, $folderCounter) EndFunc Func DecreaseFolderProgressiveCounter() $folderCounter = Int(GUICtrlRead($txtCounterFolderProgressive)) If $folderCounter > 0 Then $folderCounter -= 1 GUICtrlSetData($txtCounterFolderProgressive, $folderCounter) EndIf EndFunc Func ResetFolderProgressiveCounter() GUICtrlSetData($txtCounterFolderProgressive, 0) EndFunc Func IncreaseFileProgressiveCounter() $fileCounter = Int(GUICtrlRead($txtCounterFileProgressive)) + 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndFunc Func DecreaseFileProgressiveCounter() $fileCounter = Int(GUICtrlRead($txtCounterFileProgressive)) If $fileCounter > 0 Then $fileCounter -= 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndIf EndFunc Func ResetFileProgressiveCounter() GUICtrlSetData($txtCounterFileProgressive, 1) EndFunc Func ProcessFiles() Local $selectedFiles[0] For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1 If _GUICtrlListView_GetItemChecked($ListView1, $i) Then _ArrayAdd($selectedFiles, _GUICtrlListView_GetItemText($ListView1, $i)) EndIf Next If UBound($selectedFiles) = 0 Then MsgBox($MB_OK, "Error", "No files selected.") Return EndIf $askConfirmation = (GUICtrlRead($chkAskEveryFile) = $GUI_CHECKED) For $i = 0 To UBound($selectedFiles) - 1 $filePath = $selectedFiles[$i] If $askConfirmation Then $confirmResult = MsgBox($MB_OKCANCEL, "Confirmation", "Process file:" & @CRLF & $filePath) If $confirmResult = $IDCANCEL Then Return ; Abort the whole process EndIf EndIf If $lastButtonClicked = "SelectFolder" Then ProcessFolderFile($filePath) ElseIf $lastButtonClicked = "SelectFile" Then ProcessSingleFile($filePath) EndIf Next If GUICtrlRead($chkNextFolderAutoSwap) = $GUI_CHECKED Then SwapNextFolder() WinActivate($TgUpperForm) EndIf EndFunc Func ProcessFolderFile($filePath) $folderName = GetFolderName($folder) $fileName = GetFileName($filePath) $fileFullPath = $folder & "\" & $filePath $filePrefix = GUICtrlRead($txtPrefixFileProgressive) $fileCounter = GUICtrlRead($txtCounterFileProgressive) $filePostfix = GUICtrlRead($txtPostfixFileProgressive) $fileSeparator = GuiCtrlRead($txtFileProgressiveSeparator) If GUICtrlRead($chkEnableFileProgressive) = $GUI_CHECKED Then $finalFileName = $filePrefix & $fileCounter & $filePostfix & $fileSeparator & $fileName Else $finalFileName = $fileName EndIf If GUICtrlRead($chkAutoIncrementFileProgressiveCounter) = $GUI_CHECKED Then $fileCounter = Int($fileCounter) + 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndIf UploadFile($fileFullPath, $finalFileName) EndFunc Func ProcessSingleFile($filePath) $folderName = GetFolderName($folder) $fileName = GetFileName($filePath) $fileFullPath = $folder & "" & $filePath $filePrefix = GUICtrlRead($txtPrefixFileProgressive) $fileCounter = GUICtrlRead($txtCounterFileProgressive) $filePostfix = GUICtrlRead($txtPostfixFileProgressive) If GUICtrlRead($chkEnableFileProgressive) = $GUI_CHECKED Then $finalFileName = $filePrefix & $fileCounter & $filePostfix & " - " & $fileName Else $finalFileName = $fileName EndIf $folderPrefix = GUICtrlRead($txtPrefixFolderProgressive) $folderCounter = GUICtrlRead($txtCounterFolderProgressive) $folderPostfix = GUICtrlRead($txtPostfixFolderProgressive) If GUICtrlRead($chkEnableFolderProgressive) = $GUI_CHECKED Then $finalFolderName = $folderPrefix & $folderCounter & $folderPostfix & " - " & $folderName Else $finalFolderName = $folderName EndIf MsgBox($MB_OK, "Processing Single File", "Folder Name: " & $finalFolderName & @CRLF & "File Full Path: " & $fileFullPath & @CRLF & "File Name: " & $finalFileName) If GUICtrlRead($chkAutoIncrementFileProgressiveCounter) = $GUI_CHECKED Then $fileCounter = Int($fileCounter) + 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndIf EndFunc Func GetFolderNameFromPath($path) Return StringRegExpReplace($path, "^.*\\", "") EndFunc Func GetFolderName($folderPath) Local $folderName = StringRegExpReplace($folderPath, "^.*\", "") Return $folderName EndFunc Func GetFileName($filePath) Local $fileName = StringRegExpReplace($filePath, "^.*\", "") Return $fileName EndFunc Func SelectAll() For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1 _GUICtrlListView_SetItemChecked($ListView1, $i) Next EndFunc Func _Exit() Exit EndFunc Func CreateTopic() If _GUICtrlListView_GetItemCount($ListView1) < 1 Then MsgBox($MB_OK, "Error", "No files selected.") Return EndIf $TopicName = GetFolderName($folder) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($folder, $sDrive, $sDir, $sFileName, $sExtension) $folderPrefix = GUICtrlRead($txtPrefixFolderProgressive) $folderCounter = GUICtrlRead($txtCounterFolderProgressive) $folderPostfix = GUICtrlRead($txtPostfixFolderProgressive) $folderSeparator = GuiCtrlRead($txtFolderProgressiveSeparator) $folderName = $aPathSplit[3] If GUICtrlRead($chkEnableFolderProgressive) = $GUI_CHECKED Then $topicName = $folderPrefix & $folderCounter & $folderPostfix & $folderSeparator & $folderName Else $topicName = $folderName EndIf If GUICtrlRead($chkAutoIncrementFolderProgressiveCounter) = $GUI_CHECKED Then $folderCounter = Int($folderCounter) + 1 GUICtrlSetData($txtCounterFolderProgressive, $folderCounter) EndIf $replaceText = GUICtrlRead($txtReplaceTextInTopicName) If $replaceText <> "" Then $topicName = StringReplace($topicName, $replaceText, "") $topicName = StringStripWS($topicName, 3) EndIf ;click on 3 dots MouseClick("left", 310, 50, 1, $actionsdelay) ;click on Create Topic MouseClick("left", 230, 85, 1, $actionsdelay) ;click on Create Topic MouseClick("left", 890, 360, 1, $actionsdelay) Send($TopicName, 1) ;click on Create Topic MouseClick("left", 1080, 755, 1, $actionsdelay) $filesList = _FileListToArray($folder, "*", 1) $fileListMessage = $topicName & @LF & "Files: " & _ArrayToString($filesList, @LF) WriteMessage($fileListMessage) If GUICtrlRead($chkRefocusFormAfterTopicCreation) = $GUI_CHECKED Then Sleep($actionsdelay_very_short) WinActivate($TgUpperForm) EndIf If GUICtrlRead($chkAutoLoadFilesAfterTopic) = $GUI_CHECKED Then ProcessFiles() EndIf ElaborateAllFolders() ; Call the new function EndFunc Func UploadFile($Path, $Filename) $chooseFilesWindowTitle = "Choose Files" ;click on clip icon to open file upload MouseClick("left", 355, 1010, 1, $actionsdelay_short) WinWait($chooseFilesWindowTitle) Sleep($actionsdelay) ;click on path textbox of upload file window ControlClick($chooseFilesWindowTitle, "", 1148) Sleep($actionsdelay_short) ;Inputs file path on the textbox Send($Path, 1) Sleep($actionsdelay_short) ;Click open to start uploading file on telegram ControlClick($chooseFilesWindowTitle, "", 1) ;Longer wait for telegram file upload window Sleep($actionsdelay) ;click on textbox for telegram file ;if Mp4 preview moves buttons down $extension = StringUpper(StringRight($Filename, 4)) If $extension = ".MP4" Then MouseClick("left", 865, 630, 1) ElseIf $extension = ".JPG" Or $extension = ".PNG" Or StringUpper(StringRight($Filename, 5)) = ".JPEG" Or StringUpper(StringRight($Filename, 5)) = ".JFIF" Then MouseClick("left", 865, 700, 1) Else MouseClick("left", 865, 560, 1) EndIf Sleep($actionsdelay_short) ;Write file name Send($Filename, 1) Sleep($actionsdelay_short) ;Clicks Send If $extension = ".mp4" Then MouseClick("left", 1100, 675, 1) ElseIf $extension = ".JPG" Or $extension = ".PNG" Or StringUpper(StringRight($Filename, 5)) = ".JPEG" Or StringUpper(StringRight($Filename, 5)) = ".JFIF" Then MouseClick("left", 1100, 745, 1) Sleep($actionsdelay_short) ;temp fix for smaller/different resolution images that move up the Send button ;Will be solved with pixelchecksum method While PixelGetColor(785,320) = 16777215 Sleep($actionsdelay_short) MouseClick("left",1100,720,1) WEnd Else MouseClick("left", 1100, 610, 1) EndIf EndFunc Func UpdateCurrentFolderDisplay() GUICtrlSetData($txtCurrentFolder, GetFolderName($folder)) EndFunc Func UpdateNextFolderDisplay() $nextFolder = GetNextFolderInAlphabeticalOrder($folder) GUICtrlSetData($txtNextFolder, GetFolderName($nextFolder)) EndFunc Func GetNextFolderInAlphabeticalOrder($currentFolder) Local $folderList = _FileListToArray($currentFolder & "\..", "*", 2) If @error Then Return "" EndIf Local $currentFolderName = GetFolderNameFromPath($currentFolder) Local $currentFolderIndex = _ArraySearch($folderList, $currentFolderName, 1) ; If folder is the last one then no next folder If $currentFolderIndex = UBound($folderList) - 1 Then Return "END-FOLDERS" EndIf Return _PathFull($currentFolder & "\..") & "\" & $folderList[$currentFolderIndex + 1] EndFunc Func SwapNextFolder() If $nextFolder = "" Or $nextFolder = "END-FOLDERS" Then MsgBox($MB_OK, "Info", "This was the last folder to process. No more folders to open.") Return EndIf $folder = $nextFolder $files = _FileListToArray($folder, "*", 1) If @error Then MsgBox($MB_OK, "Error", "No files found in the selected folder.") Return EndIf UpdateFileList($files) $lastButtonClicked = "SelectFolder" If GUICtrlRead($chkResetFileProgressiveCounterOnReopenFolderOrdFile) = $GUI_CHECKED Then ResetFileProgressiveCounter() EndIf UpdateCurrentFolderDisplay() UpdateNextFolderDisplay() UpdateSwapNextFolderButton() UpdateProcessFilesButton() SelectAll() EndFunc Func _chkNextFolderAutoSwap() If GUICtrlRead($chkNextFolderAutoSwap) = $GUI_CHECKED Then GUICtrlSetState($btnSwapNextFolder, $GUI_DISABLE) Else GUICtrlSetState($btnSwapNextFolder, $GUI_ENABLE) EndIf EndFunc Func _chkAutoLoadFilesAfterTopic() If GUICtrlRead($chkAutoLoadFilesAfterTopic) = $GUI_CHECKED Then GUICtrlSetState($btnProcessFiles, $GUI_DISABLE) Else GUICtrlSetState($btnProcessFiles, $GUI_ENABLE) EndIf EndFunc Func UpdateSwapNextFolderButton() If GUICtrlRead($chkNextFolderAutoSwap) = $GUI_CHECKED Then GUICtrlSetState($btnSwapNextFolder, $GUI_DISABLE) Else GUICtrlSetState($btnSwapNextFolder, $GUI_ENABLE) EndIf EndFunc Func UpdateProcessFilesButton() If GUICtrlRead($chkAutoLoadFilesAfterTopic) = $GUI_CHECKED Then GUICtrlSetState($btnProcessFiles, $GUI_DISABLE) Else GUICtrlSetState($btnProcessFiles, $GUI_ENABLE) EndIf EndFunc ;NOTE: @CRLF will result in telegram sending the message ;To write multiline message you got to use @LF and then manually send {ENTER} Func WriteMessage($message) Sleep($actionsdelay_short) MouseClick("left", 400, 1010, 1) Send($message, 1) Send("{ENTER}") EndFunc Func ElaborateAllFolders() If GUICtrlRead($chkElaborateAllFolders) = $GUI_CHECKED Then While True CreateTopic() ProcessFiles() If GUICtrlRead($txtNextFolder) = "END-FOLDERS" Then ExitLoop EndIf SwapNextFolder() WinActivate($TgUpperForm) WEnd EndIf EndFunc
    2 points
  31. I was needing to copy some files something like a backup of a folder without overwrite file. I found in this thread a suggestion to use _WinAPI_ShellFileOperation but for my surprise it does overwrite files all the time 🤔. So I was checking MSDN and found out that IFileOperation implemented a nice operation flag to handle what I was needing(FOFX_KEEPNEWERFILE) so I just wrote this sample in case anyone was looking for it. #include <WinAPIShellEx.au3> ;~ Global Const $FOF_ALLOWUNDO = 0x40 ;~ Global Const $FOF_CONFIRMMOUSE = 0x2 ;~ Global Const $FOF_FILESONLY = 0x80 ;~ Global Const $FOF_MULTIDESTFILES = 0x1 ;~ Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000 ;~ Global Const $FOF_NOCONFIRMATION = 0x10 ;~ Global Const $FOF_NOCONFIRMMKDIR = 0x200 ;~ Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x800 ;~ Global Const $FOF_NOERRORUI = 0x400 ;~ Global Const $FOF_NORECURSION = 0x1000 ;~ Global Const $FOF_RENAMEONCOLLISION = 0x8 ;~ Global Const $FOF_SILENT = 0x4 ;~ Global Const $FOF_SIMPLEPROGRESS = 0x100 ;~ Global Const $FOF_WANTMAPPINGHANDLE = 0x20 ;~ Global Const $FOF_WANTNUKEWARNING = 0x4000 Global Const $FOFX_ADDUNDORECORD = 0x20000000 Global Const $FOFX_NOSKIPJUNCTIONS = 0x00010000 Global Const $FOFX_PREFERHARDLINK = 0x00020000 Global Const $FOFX_SHOWELEVATIONPROMPT = 0x00040000 Global Const $FOFX_EARLYFAILURE = 0x00100000 Global Const $FOFX_PRESERVEFILEEXTENSIONS = 0x00200000 Global Const $FOFX_KEEPNEWERFILE = 0x00400000 Global Const $FOFX_NOCOPYHOOKS = 0x00800000 Global Const $FOFX_NOMINIMIZEBOX = 0x01000000 Global Const $FOFX_MOVEACLSACROSSVOLUMES = 0x02000000 Global Const $FOFX_DONTDISPLAYSOURCEPATH = 0x04000000 Global Const $OFX_DONTDISPLAYDESTPATH = 0x08000000 Global Const $FOFX_RECYCLEONDELETE = 0x00080000 Global Const $FOFX_REQUIREELEVATION = 0x10000000 Global Const $FOFX_COPYASDOWNLOAD = 0x40000000 Global Const $FOFX_DONTDISPLAYLOCATIONS = 0x80000000 Global Const $IID_IShellItem = "{43826d1e-e718-42ee-bc55-a1e261c37bfe}" Global Const $dtag_IShellItem = _ "BindToHandler hresult(ptr;clsid;clsid;ptr*);" & _ "GetParent hresult(ptr*);" & _ "GetDisplayName hresult(int;ptr*);" & _ "GetAttributes hresult(int;int*);" & _ "Compare hresult(ptr;int;int*);" Global Const $IID_IShellItemArray = "{b63ea76d-1f85-456f-a19c-48159efa858b}" Global Const $dtagIShellItemArray = "BindToHandler hresult();GetPropertyStore hresult();" & _ "GetPropertyDescriptionList hresult();GetAttributes hresult();GetCount hresult(dword*);" & _ "GetItemAt hresult();EnumItems hresult();" Global Const $BHID_EnumItems = "{94F60519-2850-4924-AA5A-D15E84868039}" Global Const $IID_IEnumShellItems = "{70629033-e363-4a28-a567-0db78006e6d7}" Global Const $dtagIEnumShellItems = "Next hresult(ulong;ptr*;ulong*);Skip hresult();Reset hresult();Clone hresult();" Global Const $CLSID_IFileOperation = "{3AD05575-8857-4850-9277-11B85BDB8E09}" Global Const $IID_IFileOperation = "{947AAB5F-0A5C-4C13-B4D6-4BF7836FC9F8}" Global Const $dtagIFileOperation = "Advise hresult(ptr;dword*);" & _ "Unadvise hresult(dword);" & _ "SetOperationFlags hresult(dword);" & _ "SetProgressMessage hresult(wstr);" & _ "SetProgressDialog hresult(ptr);" & _ "SetProperties hresult(ptr);" & _ "SetOwnerWindow hresult(hwnd);" & _ "ApplyPropertiesToItem hresult(ptr);" & _ "ApplyPropertiesToItems hresult(ptr);" & _ "RenameItem hresult(ptr;wstr;ptr);" & _ "RenameItems hresult(ptr;wstr);" & _ "MoveItem hresult(ptr;ptr;wstr;ptr);" & _ "MoveItems hresult(ptr;ptr);" & _ "CopyItem hresult(ptr;ptr;wstr;ptr);" & _ "CopyItems hresult(ptr;ptr);" & _ "DeleteItem hresult(ptr;ptr);" & _ "DeleteItems hresult(ptr);" & _ "NewItem hresult(ptr;dword;wstr;wstr;ptr);" & _ "PerformOperations hresult();" & _ "GetAnyOperationsAborted hresult(ptr*);" _Test() Func _Test() Local $sPathFrom = @ScriptDir & "\PathFrom\" Local $sPathTo = @ScriptDir & "\PathTo\" DirRemove($sPathFrom, 1) DirRemove($sPathTo, 1) DirCreate($sPathFrom) For $i = 1 To 5000 FileWrite($sPathFrom & $i & ".txt", "Hello World - " & $i) Next _WinAPI_ShellFileOperation($sPathFrom & "*.*", $sPathTo, $FO_COPY, BitOR($FOF_NOERRORUI, $FOF_NOCONFIRMATION)) ;update file From and To FileWrite($sPathFrom & 1 & ".txt", " Only this should be update in 'To' Folder") FileWrite($sPathTo & 2 & ".txt", " This should not be overwritten but it does :(") MsgBox(0, "ShellFileOperation", "Check these files: " & @CRLF & $sPathFrom & 1 & ".txt" & @CRLF & @CRLF & $sPathTo & 2 & ".txt") _WinAPI_ShellFileOperation($sPathFrom & "*.*", $sPathTo, $FO_COPY, BitOR($FOF_NOERRORUI, $FOF_NOCONFIRMATION)) MsgBox(0, "ShellFileOperation", "Check these files: " & @CRLF & $sPathFrom & 1 & ".txt" & @CRLF & @CRLF & $sPathTo & 2 & ".txt") ;update file From and To FileWrite($sPathFrom & 1 & ".txt", " - I was updated again :-S") FileWrite($sPathTo & 2 & ".txt", " This will not be overwritten :)") MsgBox(0, "IFileOperation", "Check these files: " & @CRLF & $sPathFrom & 1 & ".txt" & @CRLF & @CRLF & $sPathTo & 2 & ".txt") _IFileOperationCopyFiles($sPathFrom, $sPathTo) MsgBox(0, "IFileOperation", "Check these files: " & @CRLF & $sPathFrom & 1 & ".txt" & @CRLF & @CRLF & $sPathTo & 2 & ".txt") DirRemove($sPathFrom, 1) DirRemove($sPathTo, 1) EndFunc ;==>_Test Func _IFileOperationCopyFiles($sPathFrom, $sPathTo, $iFlags = BitOR($FOF_NOERRORUI, $FOFX_KEEPNEWERFILE, $FOFX_NOCOPYHOOKS, $FOF_NOCONFIRMATION)) If Not FileExists($sPathFrom) Then Return SetError(1, 0, False) EndIf If Not FileExists($sPathTo) Then DirCreate($sPathTo) EndIf Local $tIIDIShellItem = CLSIDFromString($IID_IShellItem) Local $tIIDIShellItemArray = CLSIDFromString($IID_IShellItemArray) Local $oIFileOperation = ObjCreateInterface($CLSID_IFileOperation, $IID_IFileOperation, $dtagIFileOperation) If Not IsObj($oIFileOperation) Then Return SetError(2, 0, False) Local $pIShellItemFrom = 0 Local $pIShellItemTo = 0 _SHCreateItemFromParsingName($sPathFrom, 0, DllStructGetPtr($tIIDIShellItem), $pIShellItemFrom) _SHCreateItemFromParsingName($sPathTo, 0, DllStructGetPtr($tIIDIShellItem), $pIShellItemTo) If Not $pIShellItemFrom Or Not $pIShellItemTo Then Return SetError(3, 0, False) Local $oIShellItem = ObjCreateInterface($pIShellItemFrom, $IID_IShellItem, $dtag_IShellItem) Local $pEnum = 0 $oIShellItem.BindToHandler(0, $BHID_EnumItems, $IID_IEnumShellItems, $pEnum) Local $oIEnumShellItems = ObjCreateInterface($pEnum, $IID_IEnumShellItems, $dtagIEnumShellItems) If Not $pEnum Then Return SetError(4, 0, False) $oIFileOperation.SetOperationFlags($iFlags) Local $pItem = 0 Local $iFeched = 0 While $oIEnumShellItems.Next(1, $pItem, $iFeched) = 0 $oIFileOperation.CopyItems($pItem, $pIShellItemTo) WEnd Return $oIFileOperation.PerformOperations() = 0 EndFunc ;==>_IFileOperationCopyFiles Func _SHCreateItemFromParsingName($szPath, $pbc, $riid, ByRef $pv) Local $aRes = DllCall("shell32.dll", "long", "SHCreateItemFromParsingName", "wstr", $szPath, "ptr", $pbc, "ptr", $riid, "ptr*", 0) If @error Then Return SetError(1, 0, @error) $pv = $aRes[4] Return $aRes[0] EndFunc ;==>_SHCreateItemFromParsingName Func CLSIDFromString($sString) Local $tCLSID = DllStructCreate("dword;word;word;byte[8]") Local $aRet = DllCall("Ole32.dll", "long", "CLSIDFromString", "wstr", $sString, "ptr", DllStructGetPtr($tCLSID)) If @error Then Return SetError(1, 0, @error) If $aRet[0] <> 0 Then Return SetError(2, $aRet[0], 0) Return $tCLSID EndFunc ;==>CLSIDFromString Saludos
    2 points
  32. So just for the heck of it: the full SciTE4AutoIt3 comes with a PersonalTools.lua in the %localappdata%\AutoIt v3\SciTE, so this is an example LUA function how you could update the version on each save, when it is found in the source file: -- Update version of line with this format: -- ;Version: 1.001 -- on each save function PersonalTools:OnBeforeSave(path) if editor.Lexer == SCLEX_AU3 and path ~= "" then local spos, epos = editor:findtext('^\\s*;Version:\\s*[\\d\\.]*', SCFIND_REGEXP, 0) if spos then local dline = editor:textrange(spos, epos) local curversion = dline:match('Version:%s*([%d%.]*)') newversion = curversion + 0.001 editor:SetSel(spos, epos) editor:ReplaceSel(";Version: " .. string.format("%.3f", newversion)) end end end Over to you to modify it to your wishes.
    2 points
  33. Nine

    Restart UDF

    Made an enhanced version that informs the script of the restart, keeps track of the number of restarts and transmits actual command line parameters to the restarted script. Works compiled and uncompiled (DOS cmd console and Scite). #include <GUIConstants.au3> #include <Constants.au3> HotKeySet("{F1}", Restart) Global $iRestart = 0 Global $sCmdLine = StringStripWS(@Compiled ? $CmdLineRaw : StringRegExpReplace($CmdLineRaw, '.*?\Q' & @ScriptName & '\E"?\h*(.*)', "$1"), $STR_STRIPTRAILING) If StringInStr($sCmdLine, "/Restart=", $STR_CASESENSE) Then $iRestart = Int(StringRegExpReplace($sCmdLine, ".*\/Restart=(\d+)", "$1")) $sCmdLine = StringRegExpReplace($sCmdLine, "(.*?)\h*\/Restart=\d+", "$1") EndIf GUICreate("[" & $sCmdLine & "]", 300, 70) GUICtrlCreateLabel($iRestart, 40, 30, 50, 20) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func Restart() ShellExecute(@ScriptName, $sCmdLine & " /Restart=" & $iRestart + 1, @ScriptDir, @Compiled ? "" : "run") Exit EndFunc ;==>Restart
    2 points
  34. #include <GUIConstantsEx.au3> #include <GuiListView.au3> Local $hGUI = GUICreate("How to obtain the right mouse click position for multiple column items",1000,600) Local $OK = GUICtrlCreateButton("OK", 10, 10, 85, 25) Local $ListView = GUICtrlCreateListView("",10,50,978,500) Local $hListView = GUICtrlGetHandle($ListView) For $i = 0 To 19 _GUICtrlListView_AddColumn($ListView,$i,80) Next Local $2DArray[100][20] For $i = 0 To 19 For $t = 0 To 99 $2DArray[$t][$i] = "R"&$t&" - "&"C"&$i Next Next _GUICtrlListView_AddArray($ListView,$2DArray) Local $header = _GUICtrlListView_GetHeader($ListView) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg(0x007B, 'WM_CONTEXTMENU') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $OK Exit EndSwitch WEnd Func WM_CONTEXTMENU($hWnd,$Msg,$wParam,$lParam) If $wParam = $hListView Then Local $tPoint = _WinAPI_GetMousePos(True, $hListView) Local $aLVItem =_GUICtrlListView_SubItemHitTest($hListView, $tPoint.X, $tPoint.Y) Local $aHItem = _GUICtrlHeader_HitTest($header, $tPoint.X, $tPoint.Y) If $aHItem[0] <> -1 Then ConsoleWrite('Clicked on header: ' & $aLVItem[1] & @CRLF) EndIf EndFunc Or you can use the info already existent in lParam: Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg If $wParam = $hListView Then Local $tPoint = DllStructCreate('long X;long Y;') $tPoint.X = _WinAPI_LoWord($lParam) $tPoint.Y = _WinAPI_HiWord($lParam) _WinAPI_ScreenToClient($hListView, $tPoint) Local $aLVItem =_GUICtrlListView_SubItemHitTest($hListView, $tPoint.X, $tPoint.Y) Local $aHItem = _GUICtrlHeader_HitTest($header, $tPoint.X, $tPoint.Y) If $aHItem[0] <> -1 Then ConsoleWrite('Clicked on header: ' & $aLVItem[1] & @CRLF) EndIf EndFunc
    2 points
  35. UEZ

    AutoIt Snippets

    Get the binary type for exe / dll file. ;Coded by UEZ build 2024-04-08 #AutoIt3Wrapper_UseX64 = y #include <WinAPIFiles.au3> #include <WinAPIProc.au3> Global $sFile = FileOpenDialog("Select a DLL file", "", "File (*.dll;*.exe)", $FD_FILEMUSTEXIST) If @error Then Exit MsgBox($MB_ICONINFORMATION, "File Binary Type", StringRegExpReplace($sFile, ".+\\(.+)", "$1") & " = " & _WinAPI_GetBinaryType2($sFile)) ; #FUNCTION# ==================================================================================================================== ; Author.........: UEZ ; Modified.......: ; =============================================================================================================================== Func _WinAPI_GetBinaryType2($sFile) Local Const $hFile = _WinAPI_CreateFile($sFile, 2, 2) If Not $hFile Or @error Then Return SetError(1, 0, 0) Local Const $hMapping = _WinAPI_CreateFileMapping($hFile, 0, Null, $PAGE_READONLY, Null) If Not $hMapping Then _WinAPI_CloseHandle($hFile) Return SetError(2, 0, 0) EndIf Local Const $pAddress = _WinAPI_MapViewOfFile($hMapping, 0, 0, $FILE_MAP_READ) If Not $pAddress Or @error Then __ReturnGBT2($hMapping, $hFile, 3) Local $aHeader = DllCall("Dbghelp.dll", "ptr", "ImageNtHeader", "ptr", $pAddress) If @error Or IsArray($aHeader) = 0 Then Return __ReturnGBT2($hMapping, $hFile, 4) Local $tIMAGE_NT_HEADERS = DllStructCreate("dword Signature;ptr FileHeader;ptr OptionalHeader;", $aHeader[0]) If @error Or Not IsDllStruct($tIMAGE_NT_HEADERS) Then Return __ReturnGBT2($hMapping, $hFile, 5) Local $tIMAGE_FILE_HEADER = DllStructCreate("word Machine;word NumberOfSections;dword TimeDateStamp;dword PointerToSymbolTable;dword NumberOfSymbols;word SizeOfOptionalHeader;word Characteristics;", DllStructGetPtr($tIMAGE_NT_HEADERS) + 4) If @error Or Not IsDllStruct($tIMAGE_FILE_HEADER) Then Return __ReturnGBT2($hMapping, $hFile, 6) __ReturnGBT2($hMapping, $hFile, 0) Switch $tIMAGE_FILE_HEADER.Machine Case 0x014c Return "x86" Case 0x0200 Return "Intel Itanium" Case 0x8664 Return "x64" Case Else Return "Error" EndSwitch EndFunc ;==>_WinAPI_GetBinaryType2 Func __ReturnGBT2($hMapping, $hFile, $iError) _WinAPI_CloseHandle($hMapping) _WinAPI_CloseHandle($hFile) If $iError Then Return SetError($iError, 0, 0) EndFunc ;==>__ReturnGBT2
    2 points
  36. Since I disovered FreeBasic I decided to create a DLL to implement much faster image processing functionality to AutoIt. Following functions are implemented yet: _GDIPlus_BitmapApplyFilter_BWJJNDithering _GDIPlus_BitmapApplyFilter_BWBayerOrderedDithering _GDIPlus_BitmapApplyFilter_Cartoon1 _GDIPlus_BitmapApplyFilter_ColorAccent _GDIPlus_BitmapApplyFilter_Convolution_AnotherBlur _GDIPlus_BitmapApplyFilter_Convolution_BoxBlur _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection1 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection2 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection3 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection4 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection5 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection6 _GDIPlus_BitmapApplyFilter_Convolution_Emboss1 _GDIPlus_BitmapApplyFilter_Convolution_Emboss45Degree _GDIPlus_BitmapApplyFilter_Convolution_EmbossTopLeftBottomRight _GDIPlus_BitmapApplyFilter_Convolution_Gaussian3x3 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_1 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_2 _GDIPlus_BitmapApplyFilter_Convolution_GaussianBlur _GDIPlus_BitmapApplyFilter_Convolution_IntenseEmboss _GDIPlus_BitmapApplyFilter_Convolution_Kirsch _GDIPlus_BitmapApplyFilter_Convolution_Laplace1 _GDIPlus_BitmapApplyFilter_Convolution_Laplace2 _GDIPlus_BitmapApplyFilter_Convolution_Laplace3 _GDIPlus_BitmapApplyFilter_Convolution_LaplacianOfGaussian _GDIPlus_BitmapApplyFilter_Convolution_ManualMatrix _GDIPlus_BitmapApplyFilter_Convolution_MotionBlur _GDIPlus_BitmapApplyFilter_Convolution_Outline3x3 _GDIPlus_BitmapApplyFilter_Convolution_Prewitt _GDIPlus_BitmapApplyFilter_Convolution_Sharpen1 _GDIPlus_BitmapApplyFilter_Convolution_Sharpen2 _GDIPlus_BitmapApplyFilter_Convolution_Sobel _GDIPlus_BitmapApplyFilter_Convolution_SovelVsPrewitt _GDIPlus_BitmapApplyFilter_Convolution_TriangleBlur _GDIPlus_BitmapApplyFilter_Convolution_Unsharp _GDIPlus_BitmapApplyFilter_Convolution_Unsharp5x5 _GDIPlus_BitmapApplyFilter_Delaunay _GDIPlus_BitmapApplyFilter_Dilatation _GDIPlus_BitmapApplyFilter_DistortionBlur _GDIPlus_BitmapApplyFilter_Edges _GDIPlus_BitmapApplyFilter_Erosion _GDIPlus_BitmapApplyFilter_FakeGreyscale _GDIPlus_BitmapApplyFilter_FishEye _GDIPlus_BitmapApplyFilter_Indexed _GDIPlus_BitmapApplyFilter_Jitter _GDIPlus_BitmapApplyFilter_Kuwahara _GDIPlus_BitmapApplyFilter_Linellism _GDIPlus_BitmapApplyFilter_Median _GDIPlus_BitmapApplyFilter_Median2 _GDIPlus_BitmapApplyFilter_Mosaic _GDIPlus_BitmapApplyFilter_OilPainting _GDIPlus_BitmapApplyFilter_Open _GDIPlus_BitmapApplyFilter_PenSketch _GDIPlus_BitmapApplyFilter_PenSketch2 _GDIPlus_BitmapApplyFilter_Pixelate _GDIPlus_BitmapApplyFilter_Pointillism _GDIPlus_BitmapApplyFilter_RadialBlur _GDIPlus_BitmapApplyFilter_Raster _GDIPlus_BitmapApplyFilter_Spiral _GDIPlus_BitmapApplyFilter_Swirl _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour _GDIPlus_BitmapApplyFilter_TiltShift _GDIPlus_BitmapApplyFilter_TimeWarp _GDIPlus_BitmapApplyFilter_Ver _GDIPlus_BitmapApplyFilter_Wave _GDIPlus_BitmapApplyFilter_XRay Since I am absolutely a newbie in FreeBasic, the DLL may contain errors. Please report any bug. FreeBasic source code can be found here: https://pastebin.com/Lugp6rCR To do: add function headers with descriptions speed-up FB code -> partly done add more filters -> ongoing Credits to: Jakub Szymanowski rdc Dewald Esterhuizen Santhosh G_ Christian Graus www.gutgames.com Have fun. You can compare the speed with AutoIt version: #AutoIt3Wrapper_Version=b #include <Array.au3> #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Global Const $hGUI = GUICreate("GDI+ Image Filters", $iW * 2, $iH) Global $fProg = 0, $iEnd = $iW * $iH - 1 AdlibRegister("Progress", 490) Global $t = TimerInit() Global Const $hGDIBitmap = _GDIPlus_BitmapApplyFilter_Median($hImage, 4) ConsoleWrite(Round(TimerDiff($t) / 1000, 2) & " s / " & Round(TimerDiff($t) / 60000, 2) & " min" & @CRLF) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1) Global Const $iPic_o = GUICtrlCreatePic("", $iW, 0, $iW - 1, $iH - 1) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) Global Const $hGDIBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_o, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap2)) GUISetState() AdlibUnRegister("Progress") ToolTip("") Do Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap2) _GDIPlus_Shutdown() Exit Func Progress() ToolTip(Int($fProg / $iEnd * 100) & " % / " & Round(TimerDiff($t) / 60000, 2) & " min", MouseGetPos(0) + 30, MouseGetPos(1) + 30) EndFunc #Region Symmetric Nearest Neighbour Func _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour($hImage, $fRadius = 2, $bGDI = True) ;no alpha channel implemented yet Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iRowOffset, $iX, $iY, $c, $k, $sumR, $sumG, $sumB, $iCount, $xx, $yy, $iR, $iG, $iB, $iR1, $iG1, $iB1, $iR2, $iG2, $iB2, $x, $y For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW For $iX = 0 To $iW - 1 $sumR = 0 $sumG = 0 $sumB = 0 $iCount = 0 $c = DllStructGetData($tPixel, 1, $iRowOffset + $iX) $iR = BitShift(BitAND(0x00FF0000, $c), 16) $iG = BitShift(BitAND(0x0000FF00, $c), 8) $iB = BitAND(0x000000FF, $c) For $yy = -$fRadius To $fRadius For $xx = -$fRadius To $fRadius $k = $iX + $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = $iY + $yy $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR1 = BitShift(BitAND(0x00FF0000, $c), 16) $iG1 = BitShift(BitAND(0x0000FF00, $c), 8) $iB1 = BitAND(0x000000FF, $c) $k = $iX - $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = ($iY - $yy) $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR2 = BitShift(BitAND(0x00FF0000, $c), 16) $iG2 = BitShift(BitAND(0x0000FF00, $c), 8) $iB2 = BitAND(0x000000FF, $c) If __DeltaE($iR, $iG, $iB, $iR1, $iG1, $iB1) < __DeltaE($iR, $iG, $iB, $iR2, $iG2, $iB2) Then $sumR += $iR1 $sumG += $iG1 $sumB += $iB1 Else $sumR += $iR2 $sumG += $iG2 $sumB += $iB2 EndIf $iCount += 1 Next Next DllStructSetData($tPixel_Dest, 1, 0xFF000000 + Int($sumR / $iCount) * 0x10000 + Int($sumG / $iCount) * 0x100 + Int($sumB / $iCount), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_SNN" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __DeltaE($iR1, $iG1, $iB1, $iR2, $iG2, $iB2) Return Sqrt(($iR1 - $iR2) * ($iR1 - $iR2) + ($iG1 - $iG2) * ($iG1 - $iG2) + ($iB1 - $iB2) * ($iB1 - $iB2)) EndFunc #EndRegion #Region Jitter Func _GDIPlus_BitmapApplyFilter_Jitter($hImage, $iAmount = 20, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset, $fNX, $fNY For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $fNX = $iX + Int((Random() - 0.5) * $iAmount) $fNX = $fNX < 1 ? 1 : $fNX > $iW - 1 ? $iW - 1 : $fNX $fNY = ($iY + Int((Random() - 0.5) * $iAmount)) $fNY = $fNY < 1 ? 1 : $fNY > $iH - 1 ? $iH - 1 : $fNY $fNY *= $iW DllStructSetData($tPixel_Dest, 1, DllStructGetData($tPixel, 1, $fNY + $fNX), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Jitter" & $iAmount & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc #EndRegion #Region Median Func _GDIPlus_BitmapApplyFilter_Median($hImage, $fRadius = 3, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 DllStructSetData($tPixel_Dest, 1, __Median_Value($iX, $iY, $fRadius, $tPixel, $iW, $iH), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Median" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __Median_Value($iPosX, $iPosY, $fRadius, $tPixel, $iW, $iH) Local $iX, $iY, $aColors[1000], $iColors = 0, $iSize = $iW * $iH - 1, $iOff, $e For $iX = $iPosX - $fRadius To $iPosX + $fRadius For $iY = $iPosY - $fRadius To $iPosY + $fRadius $iOff = 1 + $iY * $iW + $iX $aColors[$iColors] = DllStructGetData($tPixel, 1, $iOff < 1 ? 1 : $iOff > $iSize ? $iSize : $iOff) $iColors += 1 Next Next ReDim $aColors[$iColors] ;~ _ArraySort($aColors, 0) $e = $iColors - 1 __ArrayQuickSort1D($aColors, 0, $e) Local $iMid = Floor($iColors / 2), $iMedian If BitAND($iColors, 1) Then $iMedian = Int($aColors[$iMid + 1]) Else $iMedian = Int(($aColors[$iMid] + $aColors[$iMid + 1]) / 2) EndIf Return $iMedian EndFunc #EndRegion _GDIPlus_BitmapApplyFilter v0.9.8 build 2024-04-17 beta.7z
    2 points
  37. Hi all, A couple of additions today. ctrl + click a fader or knob to reset it to a default value. shift + drag a fader or knob to make fine adjustments. Default values can be set per-control with: _GUICtrlGDI_SetDefaultValue($hWnd, $iValue) Otherwise out-of-the-box default values are: LR Knob/Horizontal Fader = 64 Vertical Fader = 100 All Else = 0
    2 points
  38. Should be easy when all that needed to be done is copy a "THEME" template file into the file pointed to. Could even consider letting it run parallel with the current available themes and connect them by naming them the same.
    2 points
  39. Hi @argumentum, I had an idea I’ve been working on for a while for the CHM. I almost gave it up because I kept coming across problems, but I finally got a working example to share, thanks to many web searches . This is probably more than the Devs would ever want to add, plus it would be probably for the CHM only? Not sure. But thought it would be worth passing on to you, maybe spark some ideas. One of the main problems I ran into is that the CHM doesn’t accept local storage, session storage, or cookies, so I had no way of storing any settings between pages. But in looking at another program’s help file I had seen, that offered a light/dark them switcher, I found that to save settings between pages, they were using the window.name property, which solved my problem. For this example I converted your three CSS’s (light, dark and buuf (which I called custom)). My modifications add a selector in the top right corner of every page, allowing you to change CSS styles actively. I currently have it set to refresh the page, but without a refresh works too, except some edging wasn’t being updated correctly until scrolling the page. With that said, there are some hang ups, namely: As I mentioned, this would probably be CHM only mod. The selector isn’t completely stylable. To style it more, it sounds like you would need to make a custom one using JS and CSS, using some coding/ settings which isn’t (I think) compatible with the CHM. More coding, and adds a new class. Loses CSS theme setting upon closing the CHM file, could get annoying. One other possibility, I think, would be the ability for the selector to be dynamically filled with CSS options found in the folder. But perhaps that would cause lag, and, of course much more code. Anyway, here it is. Thought you might be interested in it. Just open the chm file by double clicking, (at least that works for me?). I’m also including the htm files so you can see what I did. AutoIt CHM W Selector.zip
    2 points
  40. This seems to work but you need libcairo-2.dll which can be found also on my OneDrive (x86 / x64 folders). ;Coded by UEZ build 2024-04-02 beta #AutoIt3Wrapper_UseX64=n #include "..\Cairo.au3" Cairo_Example() Func Cairo_Example() If Not Cairo_Init("libcairo-2.dll") Then ConsoleWrite(@error & @CRLF) Exit EndIf If FileExists("Example.pdf") Then FileDelete("Example.pdf") Local $MM_TO_PT = 72.0 / 25.4, $PAGE_WIDTH_A5 = 148, $PAGE_HEIGHT_A5 = 210, $PAGE_WIDTH_A4 = 210, $PAGE_HEIGHT_A4 = 297 Local Const $pSurface = Cairo_PDF_Create("Example.pdf", $PAGE_WIDTH_A5 * $MM_TO_PT, $PAGE_HEIGHT_A5 * $MM_TO_PT) Cairo_PDF_RestrictToVersion($pSurface, $CAIRO_PDF_VERSION_1_4) Local Const $pContext = Cairo_Context_Create($pSurface) Cairo_Context_SetLineWidth($pContext, 6) Cairo_Context_PathAddRectangle($pContext, 12, 12, 232,70) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArc($pContext, 64, 64, 40, 0, ACos(-1) * 2) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArcNegative($pContext, 192, 64, 40, 0, -ACos(-1) * 2) Cairo_Context_SetFillRule($pContext, $CAIRO_FILL_RULE_EVEN_ODD) Cairo_Context_SetSourceRGB($pContext, 0, 0.7, 0) Cairo_Context_FillPreserve($pContext) Cairo_Context_SetSourceRGB($pContext, 0, 0, 0) Cairo_Context_Stroke($pContext) Cairo_Context_Translate($pContext, 0, 128) Cairo_Context_PathAddRectangle($pContext, 12, 12, 232,70) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArc($pContext, 64, 64, 40, 0, ACos(-1) * 2) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArcNegative($pContext, 192, 64, 40, 0, -ACos(-1) * 2) Cairo_Context_SetFillRule($pContext, $CAIRO_FILL_RULE_WINDING) Cairo_SetColor($pContext, 0, 0, 0.9) Cairo_Context_FillPreserve($pContext) Cairo_SetColor($pContext, 0, 0, 0) Cairo_Context_Stroke($pContext) Cairo_Context_PathClear($pContext) Cairo_Context_PathAddMoveTo($pContext, 40, 150) Cairo_Font_SelectFace($pContext) Cairo_Font_SetSize($pContext, 30) Cairo_Context_PathAddText($pContext, "PDF Example") Cairo_SetColor($pContext, 0.9, 0, 0, 1) Cairo_Context_FillPreserve($pContext) Cairo_SetColor($pContext, 0, 0, 0.1, 0.5) Cairo_Context_SetLineWidth($pContext, 1.5) Cairo_Context_Stroke($pContext) Cairo_Surface_Finish($pSurface) Cairo_Surface_Flush($pSurface) ConsoleWrite(Cairo_Surface_GetStatus($pSurface) & @CRLF) Cairo_Context_Destroy($pContext) Cairo_Surface_Destroy($pSurface) Cairo_Close() ConsoleWrite(FileGetSize("Example.pdf") & @CRLF) EndFunc I seems that the Cairo.dll / Cairo64.dll doesn't work properly with PDF creation...
    2 points
  41. Andreik

    ePUB Reader

    New version available. Fixed a small bug in UpdateSlider().
    2 points
  42. The error is in _WM_NOTIFY_DebugEvent() because the calling process does not have read access to the specified range of memory. It's pretty easy to check with _WinAPI_IsBadReadPtr() after $tInfo is created and it will return true. This happens because lParam in WM_COMMAND is a handle to the control window but in _GUICtrlButton_SetSplitInfo() example it's passed as a pointer to a NMHDR structure. $sText = "Text=" & _GUICtrlButton_GetText($hCtrl) _WM_NOTIFY_DebugEvent($sCode, $tagNMHDR, $lParam, "IDFrom", $sText) ; <<< ---- This line Return 0 ; Only workout clicking on the button Edit: just use GUIRegisterMsg() by yourself without this extra library (WM_NOTIFY.au3) and everything works as expected #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WindowsConstants.au3> Global $g_hBtn, $g_idMemo, $g_hBtn2 ; Note: The handle from these buttons can NOT be read with GUICtrlRead Example() Func Example() Local $hGUI = GUICreate("Button Set SplitInfo (v" & @AutoItVersion & ")", 400, 400) $g_idMemo = GUICtrlCreateEdit("", 10, 100, 390, 284, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") $g_hBtn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON) _GUICtrlButton_SetSplitInfo($g_hBtn) $g_hBtn2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 120, 30, $BS_SPLITBUTTON) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) Local $aInfo = _GUICtrlButton_GetSplitInfo($g_hBtn) MemoWrite("Split Info" & @CRLF & "----------------") For $x = 0 To 3 MemoWrite("$ainfo[" & $x & "] = " & $aInfo[$x]) Next MemoWrite("Split Info" & @CRLF & "----------------") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local Const $BCN_HOTITEMCHANGE = -1249 Local $tagNMBHOTITEM = $tagNMHDR & ";dword dwFlags" Local $tNMBHOTITEM = DllStructCreate($tagNMBHOTITEM, $lParam) Local $iCode = DllStructGetData($tNMBHOTITEM, "Code") Local $hWndFrom = DllStructGetData($tNMBHOTITEM, "hWndFrom") Local $iFlags = DllStructGetData($tNMBHOTITEM, "dwFlags") Local $sText = "" Switch $iCode Case $BCN_HOTITEMCHANGE ; Win XP and Above $sText = "Text=" & _GUICtrlButton_GetText($hWndFrom) If BitAND($iFlags, 0x10) = 0x10 Then ConsoleWrite('BCN_HOTITEMCHANGE - Entering' & @CRLF) ;~ _WM_NOTIFY_DebugEvent("$BCN_HOTITEMCHANGE - Entering", $tagNMBHOTITEM, $lParam, "IDFrom", $sText) ElseIf BitAND($iFlags, 0x20) = 0x20 Then ConsoleWrite('BCN_HOTITEMCHANGE - Leaving' & @CRLF) ;~ _WM_NOTIFY_DebugEvent("$BCN_HOTITEMCHANGE - Leaving", $tagNMBHOTITEM, $lParam, "IDFrom", $sText) EndIf Case $BCN_DROPDOWN MemoWrite("$BCN_DROPDOWN") _Popup_Menu($hWndFrom) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Popup_Menu($hCtrl) Local $hMenu Local Enum $e_idOpen = 1000, $e_idSave, $e_idInfo $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2) Case $e_idOpen MemoWrite("Open - Selected") Case $e_idSave MemoWrite("Save - Selected") Case $e_idInfo MemoWrite("Info - Selected") EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) EndFunc ;==>_Popup_Menu ; React on a button click Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $iCode = BitShift($wParam, 16) Local $hCtrl = $lParam Local $sCode, $sText Switch $hCtrl Case $g_hBtn, $g_hBtn2 Switch $iCode Case $BN_CLICKED $sCode = "$BN_CLICKED" Case $BN_PAINT $sCode = "$BN_PAINT" Case $BN_PUSHED $sCode = "$BN_PUSHED" Case $BN_HILITE $sCode = "$BN_HILITE" Case $BN_UNPUSHED $sCode = "$BN_UNPUSHED" Case $BN_UNHILITE $sCode = "$BN_UNHILITE" Case $BN_DISABLE $sCode = "$BN_DISABLE" Case $BN_DBLCLK $sCode = "$BN_DBLCLK" Case $BN_DOUBLECLICKED $sCode = "$BN_DOUBLECLICKED" Case $BN_SETFOCUS $sCode = "$BN_SETFOCUS" Case $BN_KILLFOCUS $sCode = "$BN_KILLFOCUS" EndSwitch $sText = "Text=" & _GUICtrlButton_GetText($hCtrl) ConsoleWrite($sText & @CRLF) ;~ _WM_NOTIFY_DebugEvent($sCode, $tagNMHDR, $lParam, "IDFrom", $sText) Return 0 ; Only workout clicking on the button EndSwitch ; Proceed the default AutoIt3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default AutoIt3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND
    2 points
  43. AutoIt3.exe ended.rc:-1073740771 Same error, I'm gonna take a nap before I look...
    2 points
  44. I suppose it is the progress bar that he finds too small. One solution is to create a custom GUI progress bar with the desired size, but why reinvent the wheel. Just adjust the size of each component : #include <WinAPISysWin.au3> #include <String.au3> #include <WinAPIGdi.au3> #include <FontConstants.au3> ProgressOn("Test", "Main text", "Sub Text") Local $hWnd = WinGetHandle("Test") WinMove($hWnd, "", 200, 200, 600, 250) Local $hText1 = ControlGetHandle($hWnd, "", "Static1") Local $hProgress = ControlGetHandle($hWnd, "", "msctls_progress321") Local $hText2 = ControlGetHandle($hWnd, "", "Static2") Local $aPos = ControlGetPos($hWnd, "", $hText1) _WinAPI_MoveWindow($hText1, $aPos[0], $aPos[1], $aPos[2] * 2, $aPos[3] * 2) Local $hFont1 = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') _WinAPI_SetFont($hText1, $hFont1) $aPos = ControlGetPos($hWnd, "", $hProgress) _WinAPI_MoveWindow($hProgress, $aPos[0], $aPos[1] + 50, $aPos[2] * 2, $aPos[3] * 2) $aPos = ControlGetPos($hWnd, "", $hText2) _WinAPI_MoveWindow($hText2, $aPos[0], $aPos[1] + 85, $aPos[2] * 2, $aPos[3] * 2) Local $hFont2 = _WinAPI_CreateFont(40, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') _WinAPI_SetFont($hText2, $hFont2) For $i = 10 To 100 Step 10 Sleep(500) ProgressSet($i, $i & "%") Next ProgressSet(100, "Done", "Complete") Sleep(2000) _WinAPI_DeleteObject($hFont1) _WinAPI_DeleteObject($hFont2) ProgressOff() If it is the MsgBox that is too small, you can pretty much do the same, but you will need to hook the MsgBox to a CBT proc. In any case, I felt it is a good example of how to reuse an existing function without creating it from scratch...
    2 points
  45. Melba23

    kirb

    Is it really nearly 4 years since I had to do this? Such a pity that I now have to post anew in this section. Our friend in the title of this thread has been remittingly negative about AutoIt since his arrival here - and has the most unfortunate tendency to refer to AHK almost every time he opens a thread. But worse, he has resorted to ad hominen attacks against MVPs and, rather foolishly, the Mod team. He is now taking a short holiday to consider whether his attitude should change, as it must if he wishes to remain part of this community, or whether he would be better off elsewhere. M23
    2 points
  46. I need from from time to time to run small processes to perform task that would otherwise clog the main process. Yes, there is a number of other UDF that could have done it very well, but I felt they were an over-kill for what I wanted. Don't throw me stones, I know it's not really multi-threading, but it is as close as I could get with simple AutoIt. If someone wonders why I called it PMT, the P stands for Pretending. And I'm also not pretending it is an elaborate UDF. Just small and simple to use... Version 2024-03-24 * corrected bug when 8 parameters (max) is passed to the function Example : #AutoIt3Wrapper_Res_SaveSource=y #include "PMT-UDF.AU3" #include <Constants.au3> _PMT_Init() Local $hProc1 = _PMT_Start("Test1", Default, "Test 1") _PMT_Start("Test2") _PMT_Start("Test3", 5) Local $sResponse While Sleep(50) $sResponse = _PMT_GetResponse($hProc1) If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped") If $sResponse <> "" Then MsgBox($MB_OK, "Success", $sResponse & @CRLF) ExitLoop EndIf WEnd Func Test1($sTitle, $sMessage) Local $iResp = MsgBox($MB_OK, $sTitle, $sMessage) Return "Done with value " & $iResp EndFunc Func Test2() MsgBox($MB_OK, "2", "Test 2") EndFunc Func Test3($iTimeout) MsgBox($MB_OK, "3", "Test 3", $iTimeout) EndFunc You can pass up to 8 parameters to _PMT_Start. It is up to you to manage the right number. You cannot pass structures, maps or arrays as parameter (only bool, ptr, hWnd, int, float, string, and the keyword Default). You could use my WCD-IPC if need be to exchange large amount of data. If you want to run it compiled, you need to have add #AutoIt3Wrapper_Res_SaveSource=y at the start of your script. In the case you decide to compile your script, _PMT_Init allows you to identity where AutoIt3 is located (in the situation where AutoIt is not installed in the usual directory) to get the right includes in your "threads". Let me know if you have any question, or suggestion, I will be glad to hear them. Enjoy. PMT-UDF.au3
    2 points
  47. I would also do some advertising, as the data fits very well for this. With the TableData UDF you can simplify things quite a bit: #include "Json.au3" #include "TableData.au3" Local $sJSON = '[{"symbol":"ETHBTC","priceChange":"-0.00031000","priceChangePercent":"-0.595","weightedAvgPrice":"0.05197174","prevClosePrice":"0.05213000","lastPrice":"0.05182000","lastQty":"20.06760000","bidPrice":"0.05182000","bidQty":"23.61320000","askPrice":"0.05183000","askQty":"30.12050000","openPrice":"0.05213000","highPrice":"0.05243000","lowPrice":"0.05156000","volume":"24595.97310000","quoteVolume":"1278.29551268","openTime":1711203672778,"closeTime":1711290072778,"firstId":438016051,"lastId":438113829,"count":97779},{"symbol":"LTCBTC","priceChange":"0.00001600","priceChangePercent":"1.192","weightedAvgPrice":"0.00134319","prevClosePrice":"0.00134200","lastPrice":"0.00135800","lastQty":"1.64000000","bidPrice":"0.00135800","bidQty":"2.93700000","askPrice":"0.00135900","askQty":"135.64200000","openPrice":"0.00134200","highPrice":"0.00137700","lowPrice":"0.00131400","volume":"99931.64700000","quoteVolume":"134.22719281","openTime":1711203670214,"closeTime":1711290070214,"firstId":96069410,"lastId":96092177,"count":22768},{"symbol":"BNBBTC","priceChange":"-0.00016800","priceChangePercent":"-1.927","weightedAvgPrice":"0.00860063","prevClosePrice":"0.00871800","lastPrice":"0.00854800","lastQty":"0.75000000","bidPrice":"0.00854600","bidQty":"1.01500000","askPrice":"0.00854700","askQty":"0.51100000","openPrice":"0.00871600","highPrice":"0.00871700","lowPrice":"0.00849800","volume":"26867.77800000","quoteVolume":"231.07994652","openTime":1711203672378,"closeTime":1711290072378,"firstId":237459363,"lastId":237516989,"count":57627},{"symbol":"NEOBTC","priceChange":"0.00000050","priceChangePercent":"0.220","weightedAvgPrice":"0.00023046","prevClosePrice":"0.00022710","lastPrice":"0.00022740","lastQty":"2.80000000","bidPrice":"0.00022720","bidQty":"40.03000000","askPrice":"0.00022750","askQty":"31.85000000","openPrice":"0.00022690","highPrice":"0.00023590","lowPrice":"0.00022540","volume":"19836.53000000","quoteVolume":"4.57156205","openTime":1711203663295,"closeTime":1711290063295,"firstId":46240496,"lastId":46242649,"count":2154},{"symbol":"QTUMETH","priceChange":"0.00001700","priceChangePercent":"1.340","weightedAvgPrice":"0.00129800","prevClosePrice":"0.00127600","lastPrice":"0.00128600","lastQty":"0.90000000","bidPrice":"0.00128700","bidQty":"45.50000000","askPrice":"0.00129000","askQty":"354.40000000","openPrice":"0.00126900","highPrice":"0.00131600","lowPrice":"0.00126700","volume":"5090.00000000","quoteVolume":"6.60683920","openTime":1711203643004,"closeTime":1711290043004,"firstId":5437599,"lastId":5437748,"count":150}]' ; parse JSON and convert the structure into a table object $mData = _td_MapsToTable(_JSON_Parse($sJSON)) ; sort data - to do this convert attribute into number type and use this as comparison value _td_Sort($mData, "Number($x.priceChangePercent)", True) ; show data _td_display($mData)
    2 points
  48. It's been a while... updated with some fixes and improvements. FIXED: Wrong line endings when copying from code preview window FIXED: Issue changing properties when Obect Explorer window is not open FIXED: Issue when selecting controls under certain other conditions FIXED: SaveAs keyboard shortcut FIXED: Undo/Redo for Global property ADDED: Auto-size property for Labels, Buttons, and Inputs
    2 points
  49. Lol, I spent over 40 years understanding what computer science is about. Stop making wall of words and make a runable script that all we actually can run...
    2 points
×
×
  • Create New...