Leaderboard
Popular Content
Showing content with the highest reputation on 11/01/2017 in all areas
-
After reading this page, (http://www.drububu.com/illustration/tsp/index.html) I was curious and I put together this script. it is not a "stand alone" script, as it uses some third parties programs*, but in few steps it acomplish the conversion to the TSP art. The generated images are quite nice, but you have to try more attempts to find the right combinations of parameters for different source images. Best results can easily obtained with schematic black and wite images. Drag and drop for example something like in this link. Also, set the "Variable thickness line" option and try with the image at this link for another example: (https://images.fineartamerica.com/images/artworkimages/mediumlarge/1/david-michelangelo-murphy-elliott.jpg) Since used programs generate also some temporay files, please save this script and the dependencies into a single folder so to avoid the scattering of files around and also allowing the main script to find the needed programs. Example of an TSP art generated with this script and related programs (the image on the left is converted in the image on the right) just drag and drop images on the GUI of the script and all is done automatically. * Here are the links to download the needed "dependencies": ( just put all the stuff in a single folder along with the script.) voronoi.exe http://www.drububu.com/illustration/tsp/voronoi.zip stippler.dll also contained in the above archive concorde.exe http://www.math.uwaterloo.ca/tsp/concorde/downloads/codes/cygwin/concorde.exe.gz this program needs the cygwin dll (a very nice one) (I've used 7zip to open this archive) cygwin1.dll https://cygwin.com/snapshots/ get one x86 cygwin1-xxxxxxxx.dll.xz (only dll) svg_extract.exe http://www.drububu.com/illustration/tsp/svg_extract.zip tsp2svg.exe http://www.drububu.com/illustration/tsp/tsp2svg.zip here the script: ; TSP Art generator #include <FileConstants.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <GDIPlus.au3> If Not _CheckDependencies() Then Exit ; can't run without dependencies. Global $bDropped, $sFile, $bDropAllowed = True ; create a blank file, or empty it if it's already created Global $hTail, $sLogFile = FileGetShortName(@ScriptDir & "\LogFile.txt") _GDIPlus_Startup() ; just for image format conversion to PNG (if needed) $Form1 = GUICreate("TSP art generator", 500, 650, -1, -1, -1, $WS_EX_ACCEPTFILES) ; --- options $Combo1 = GUICtrlCreateCombo("", 350, 505, 60, 25) GUICtrlCreateLabel("Sampling points", 415, 510, 80, 25) GUICtrlSetData($Combo1, "1000|2000|4000|6000|8000|10000|20000|40000|60000", "4000") ; some sampling rate $Checkbox1 = GUICtrlCreateCheckbox("Variable thickness line", 350, 535, 145, 25) $Checkbox2 = GUICtrlCreateCheckbox("Color (voronoi only)", 350, 565, 145, 25) ; --- Log viewer Global $hLog = GUICtrlCreateEdit("", 5, 500, 340, 145, BitOR($WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_MULTILINE, $ES_READONLY)) ; log viewer GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetFont(-1, 9, -1, -1, "Courier New") ; following is a transparent control over the browser control ; purpose is to avoid that the drop event is captured by the browser control $hGlass = GUICtrlCreateLabel("", 0, 0, 500, 650) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; This is like a glass over the following underlying browser Control GUICtrlSetCursor(-1, 2) ; Cursor is an arrow (instead of the default I-beam) ; --- Embed a browser control Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 5, 5, 490, 490) $oIE.navigate("about:blank") AutoItSetOption("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") GUISetState(@SW_SHOW, $Form1) _LogPrint(@CRLF & _ "Hello," & @CRLF & _ "Drag and dropping images here above," & @CRLF & _ "will be converted into a TSP Art." & @CRLF & _ "have fun...") ; --- Main loop While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE _Exit() Case $bDropped = True $bDropped = False $bDropAllowed = False ; Drop not allowed while generating _Generate_PST_Art() $bDropAllowed = True EndSelect WEnd ; --- Call externa programs the right sequence Func _Generate_PST_Art() _EmptyLog() ; empty the temporary log file _checkFileFormat($sFile) ; if dropped image isn't a PNG convert it to PNG _ShowInBrowser($sFile) ; show dropped image in the browser control ; step 1) Transform PNG image into a voronoi svg image ; ============================================================================ If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; variable thickness line? $sOptions = "" Else $sOptions = " -f " ; fixed radus EndIf If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then ; color points for voronoi? $sOptions = " -c " & $sOptions EndIf ; _call_External_Program(".\voronoi.exe " & $sOptions & "-s " & GUICtrlRead($Combo1) & " -n -I " & $sFile & " -O out.svg", True) _call_External_Program(FileGetShortName(@ScriptDir & '\voronoi.exe') & $sOptions & ' -s ' & GUICtrlRead($Combo1) & ' -n -I ' & $sFile & ' -O out.svg', True) _ShowInBrowser(FileGetShortName(@ScriptDir & "\out.svg")) ; show generated voronoi image in the browser control ; ; step 2) Extract points from the voronoi svg image and save to positions.tsp file ; for later input by the concorde TSP solver ; ============================================================================ _call_External_Program(FileGetShortName(@ScriptDir & '\svg_extract.exe') & " out.svg") _LogPrint("... going to next step ...") ; ; step 3) Resolve the Traveling Salesman Problem using the very good ; concorde.exe program (it needs the presence of the cygwin1.dll to work) ; ============================================================================ _call_External_Program(FileGetShortName(@ScriptDir & "\concorde.exe") & " -V -o tour.cyc positions.tsp", True) _LogPrint("... going to next step ...") ; ; step 3a) some adjustments to the tour.cyc file generated by concorde.exe ; ============================================================================ $hfile = FileOpen(FileGetShortName(@ScriptDir & '\tour.cyc')) Local $sContent = FileRead($hfile) FileClose($hfile) FileDelete(FileGetShortName(@ScriptDir & '\tour.cyc')) $sContent = StringReplace($sContent, Chr(0x20), Chr(0x0A)) _LogPrint("Replaced 0x20 with 0x0A " & @extended & " times.") $sContent = StringReplace($sContent, Chr(0x0A) & Chr(0x0A), Chr(0x0A)) _LogPrint("Replaced 0x0A 0x0A with 0x0A " & @extended & " times." & @CRLF) Local $x = StringInStr($sContent, Chr(0x0A)) ; first 0A $sContent = StringMid($sContent, $x + 1) ; remove first data (it's the number of points, not a point) $hfile = FileOpen(FileGetShortName(@ScriptDir & '\tour.cyc'), $FO_OVERWRITE + $FO_BINARY) FileWrite($hfile, $sContent) ; save adjusted data FileFlush($hfile) FileClose($hfile) ; ; step 4) "merge" data from out.svg and tour.cyc into the final tsp_art.svg file ; ============================================================================ If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sOptions = " +w" ; variable thickness line Else $sOptions = "" ; fixed thickness line EndIf $sOptions = FileGetShortName(@ScriptDir & "\tsp2svg.exe") & " out.svg tour.cyc" & $sOptions _call_External_Program($sOptions) _ShowInBrowser(FileGetShortName(@ScriptDir & "\tsp_art.svg")) _LogPrint(@CRLF & _ "+-----------------------------------+" & @CRLF & _ "| End of conversion --> tsp_art.svg |" & @CRLF & _ "+-----------------------------------+" & @CRLF) EndFunc ;==>_Generate_PST_Art ; === Functions Func _call_External_Program($sCommand, $bVerbose = False) Local $sLine If $bVerbose = True Then $sCommand = @ComSpec & " /c " & $sCommand & ">>" & $sLogFile & " 2>>&1" EndIf Local $hPid = Run($sCommand, ".", @SW_HIDE) If Not $hPid Then _LogPrint("Error on run external program" & @CRLF) Return SetError(1) EndIf Do If $bVerbose Then $sLine = FileReadLine($hTail) If Not @error Then _LogPrint($sLine) EndIf EndIf Until Not ProcessExists($hPid) If $bVerbose Then $sLine = "..." ; "Task execution terminated ...." Do _LogPrint($sLine) $sLine = FileReadLine($hTail) Until @error EndIf EndFunc ;==>_call_External_Program Func _LogPrint($sLine) If StringLen(GUICtrlRead($hLog)) > 25000 Then ; Max Len of a CtrlBox is 30000 char _GUICtrlEdit_SetText($hLog, StringRight(GUICtrlRead($hLog), 20000)) ; short the content of CtrlBox to 20000 char EndIf _GUICtrlEdit_AppendText($hLog, $sLine & @CRLF) EndFunc ;==>_LogPrint Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) If $bDropAllowed Then Local $sExt = ".bmp|.png|.jpg|.gif" ; img drop filtering thanks to @UEZ Local $aFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then For $i = 1 To $aFileList[0] If StringInStr($sExt, StringRegExpReplace($aFileList[$i], ".*(\.+)", "$1")) Then $bDropped = True $sFile = FileGetShortName($aFileList[$i]) ExitLoop EndIf Next Else _LogPrint("Error on drop" & @CRLF) EndIf _WinAPI_DragFinish($wParam) _LogPrint("Droped: " & $sFile & @CRLF) Return 0 EndIf EndFunc ;==>WM_DROPFILES Func _ShowInBrowser($sImg) ; setup Javascript engine with also embeded the "entity" library If StringRight($sImg, 3) = "svg" Then Else EndIf ; *** create a minimal 'html' page listing for the browser control Local $sHTML = "<HTML><HEAD>" & @CRLF & _ "<meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" />" & @CRLF & _ "</HEAD>" & @CRLF & _ "<body>" & @CRLF & _ '<img src="' & $sImg & '" style="width:100%; height:100%;" />' & @CRLF & _ "</body>" & @CRLF & _ "</HTML>" & @CRLF ; html closing tags ; *** end of html page listing ; _LogPrint(">_" & @CRLF) $oIE.navigate('about:blank') While Not String($oIE.readyState) = 'complete' ; wait for about:blank Sleep(100) WEnd $oIE.document.Write($sHTML) ; inject lising directly to the HTML document: $oIE.document.close() ; close the write stream Sleep(1000) $oIE.document.execCommand("Refresh") EndFunc ;==>_ShowInBrowser Func _checkFileFormat($sFile) Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) Local $aFormat = _GDIPlus_ImageGetRawFormat($hImage) If $aFormat[1] <> "PNG" Then _ConvertToPNG($hImage) _GDIPlus_ImageDispose($hImage) EndFunc ;==>_checkFileFormat Func _ConvertToPNG(ByRef $hImage) Local $CLSID = _GDIPlus_EncodersGetCLSID('PNG') $sFile = FileGetShortName(@ScriptDir & "\Input.png") _GDIPlus_ImageSaveToFileEx($hImage, $sFile, $CLSID) EndFunc ;==>_ConvertToPNG Func _EmptyLog() FileClose($hTail) $hTail = FileOpen($sLogFile, $FO_OVERWRITE) FileWrite($hTail, "Start log: " & @YEAR & '/' & @MON & '/' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & @CRLF) FileFlush($hTail) FileClose($hTail) $hTail = FileOpen($sLogFile) ; read only EndFunc ;==>_EmptyLog Func _CheckDependencies() Local $iDependencie = 0 $iDependencie += FileExists(@ScriptDir & "\voronoi.exe") ; http://www.drububu.com/illustration/tsp/voronoi.zip $iDependencie += FileExists(@ScriptDir & "\stippler.dll") ; " also contained in the above archive $iDependencie += FileExists(@ScriptDir & "\concorde.exe") ; http://www.math.uwaterloo.ca/tsp/concorde/downloads/codes/cygwin/concorde.exe.gz $iDependencie += FileExists(@ScriptDir & "\cygwin1.dll") ; get one from here https://cygwin.com/snapshots/ get cygwin1-xxxxxxxxx.dll.xz $iDependencie += FileExists(@ScriptDir & "\svg_extract.exe") ; http://www.drububu.com/illustration/tsp/svg_extract.zip $iDependencie += FileExists(@ScriptDir & "\tsp2svg.exe") ; http://www.drububu.com/illustration/tsp/tsp2svg.zip Return $iDependencie = 6 EndFunc ;==>_CheckDependencies Func _Exit() _GDIPlus_Shutdown() FileClose($hTail) AutoItSetOption("GUIOnEventMode", 0) GUIRegisterMsg($WM_DROPFILES, "") Exit EndFunc ;==>_Exit1 point
-
ComboBox Set DROPDOWNLIST Colors/size UDF
ratus69 reacted to argumentum for a topic
#include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Array.au3> #include <WinAPITheme.au3> #include <GDIPlus.au3> #Region GUICtrlComboSetColors UDF Global $g__aWM_CTLCOLORLISTBOX[1][16] = [[0, 0, 0]] ; init. the Global array ; #FUNCTION# ==================================================================================================================== ; Name...........: GUICtrlComboSetColors ; Description ...: Change the colors and position/size of a ComboBox ; Syntax.........: GUICtrlComboSetColors ( $idCombo [, $iBgColor = Default] [, $iFgColor = Default] [, $iExtendLeft = Default] ) ; Parameters ....: $idCombo - GUICtrlCreateCombo() ControlID / [ ArrayIndex ] ; $iBgColor - Background RGB color ; - or "-1" to use prior color declared ; - or to remove a control by ControlID, "-2" ; - or to remove a control by ArrayIndex, "-3" ; $iFgColor - Foreground RGB color ; - or "-1" to use prior color declared ; - or "-2" to use sytem color and leave theme default ; $iExtendLeft - pixels to extend the dropdown list ; - or "-1" to use prior width declared ; - or "1" auto size, extending left ( see Remarks/AutoSize ) ; - or "2" auto size, extending right ( see Remarks/AutoSize ) ; Return values .: Success - index position in the array ; Failure - 0 ; @error - 1 : Control handle = 0 ; - 2 : GetComboBoxInfo failed ; - 3 : Control for removal not found ; @extended - 2 : Success on Control removal ; Author ........: argumentum ; Modified.......: v0.0.0.5 ; Remarks .......: this UDF is in its a work in progress, will expand if needed. ; AutoSize...: use the pertinent parameters from GUICtrlComboSetColors_SetAutoSize() ; minus the CtrlID as semicolon separated to initialize. Ex: "2;Arial;8.5;0" ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-bgcolor/ ; Example .......: Yes, at the end of the file ; =============================================================================================================================== Func GUICtrlComboSetColors($idCombo = 0, $iBgColor = Default, $iFgColor = Default, $iExtendLeft = Default) If Not $idCombo Then Return SetError(1, 0, 0) Local $n, $tInfo, $i = 0 If $iBgColor = -2 Or $iBgColor = -3 Then Local $m For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If ($g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo And $iBgColor = -2) Or ($g__aWM_CTLCOLORLISTBOX[$n][9] = $idCombo And $iBgColor = -3) Then _ArrayDelete($g__aWM_CTLCOLORLISTBOX, $n) $g__aWM_CTLCOLORLISTBOX[0][0] -= 1 Return SetError(0, 2, $n) EndIf Next Return SetError(3, 0, 0) EndIf For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo Then $i = $n ExitLoop EndIf Next If Not $i Then $g__aWM_CTLCOLORLISTBOX[0][0] += 1 $i = $g__aWM_CTLCOLORLISTBOX[0][0] ; If $i >= UBound($g__aWM_CTLCOLORLISTBOX) Then ReDim $g__aWM_CTLCOLORLISTBOX[$i + 1][16] ; add extra "slots" EndIf EndIf Local $sStr = GUICtrlRead($idCombo) Local $iSetWindowTheme = 1 If $iBgColor = Default And $iFgColor = Default Then $iSetWindowTheme = 0 If $iBgColor = Default Then $iBgColor = _WinAPI_GetSysColor($COLOR_WINDOW) If $iFgColor = Default Then $iFgColor = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) If $iBgColor = -1 Then $iBgColor = $g__aWM_CTLCOLORLISTBOX[$i][10] If $iFgColor = -1 Then $iFgColor = $g__aWM_CTLCOLORLISTBOX[$i][11] $g__aWM_CTLCOLORLISTBOX[$i][11] = $iFgColor $g__aWM_CTLCOLORLISTBOX[$i][10] = $iBgColor If $iExtendLeft = Default Then $iExtendLeft = 0 $g__aWM_CTLCOLORLISTBOX[$i][12] = 0 EndIf If $iExtendLeft = -1 Then $iExtendLeft = $g__aWM_CTLCOLORLISTBOX[$i][8] ElseIf Int($iExtendLeft) = 1 Then $g__aWM_CTLCOLORLISTBOX[$i][12] = 1 ElseIf Int($iExtendLeft) = 2 Then $g__aWM_CTLCOLORLISTBOX[$i][12] = 2 Else $g__aWM_CTLCOLORLISTBOX[$i][12] = 0 EndIf $g__aWM_CTLCOLORLISTBOX[$i][8] = Int($iExtendLeft) $g__aWM_CTLCOLORLISTBOX[$i][0] = $idCombo $g__aWM_CTLCOLORLISTBOX[$i][1] = GUICtrlGetHandle($idCombo) $g__aWM_CTLCOLORLISTBOX[$i][13] = "Arial" ; default $sFont $g__aWM_CTLCOLORLISTBOX[$i][14] = 8.5 ; default $fSize $g__aWM_CTLCOLORLISTBOX[$i][15] = 0 ; default $iStyle If $g__aWM_CTLCOLORLISTBOX[$i][12] Then $f = StringSplit($iExtendLeft, ";") If UBound($f) > 1 Then $g__aWM_CTLCOLORLISTBOX[$i][8] = Int($f[1]) If UBound($f) > 2 Then $g__aWM_CTLCOLORLISTBOX[$i][13] = $f[2] If UBound($f) > 3 Then $g__aWM_CTLCOLORLISTBOX[$i][14] = Int($f[3]) If UBound($f) > 4 Then $g__aWM_CTLCOLORLISTBOX[$i][15] = Int($f[4]) $t = TimerInit() GUICtrlComboSetColors_SetAutoSize(Int("-" & $i), $g__aWM_CTLCOLORLISTBOX[$i][12], $g__aWM_CTLCOLORLISTBOX[$i][13], $g__aWM_CTLCOLORLISTBOX[$i][14], $g__aWM_CTLCOLORLISTBOX[$i][15]) ConsoleWrite(TimerDiff($t) & @CRLF) EndIf If _GUICtrlComboBox_GetComboBoxInfo($idCombo, $tInfo) Then If $iSetWindowTheme Then If $g__aWM_CTLCOLORLISTBOX[$i][11] <> -2 Then _WinAPI_SetWindowTheme($g__aWM_CTLCOLORLISTBOX[$i][1], "", "") If $g__aWM_CTLCOLORLISTBOX[$i][11] <> -2 Then GUICtrlSetColor($g__aWM_CTLCOLORLISTBOX[$i][0], $iFgColor) GUICtrlSetBkColor($g__aWM_CTLCOLORLISTBOX[$i][0], $iBgColor) Else GUICtrlSetBkColor($g__aWM_CTLCOLORLISTBOX[$i][0], _WinAPI_GetSysColor($COLOR_HOTLIGHT)) _WinAPI_SetWindowTheme($g__aWM_CTLCOLORLISTBOX[$i][1], 0, 0) EndIf $g__aWM_CTLCOLORLISTBOX[$i][2] = DllStructGetData($tInfo, "hCombo") $g__aWM_CTLCOLORLISTBOX[$i][3] = DllStructGetData($tInfo, "hEdit") $g__aWM_CTLCOLORLISTBOX[$i][4] = DllStructGetData($tInfo, "hList") ; this is what is colored Else $g__aWM_CTLCOLORLISTBOX[0][0] -= 1 Return SetError(2, 0, 0) EndIf If Int($g__aWM_CTLCOLORLISTBOX[$i][5]) Then _WinAPI_DeleteObject($g__aWM_CTLCOLORLISTBOX[$i][5]) $g__aWM_CTLCOLORLISTBOX[$i][5] = 0 ; holder for "_WinAPI_CreateSolidBrush()" return value $g__aWM_CTLCOLORLISTBOX[$i][6] = BitOR(BitAND($iBgColor, 0x00FF00), BitShift(BitAND($iBgColor, 0x0000FF), -16), BitShift(BitAND($iBgColor, 0xFF0000), 16)) If $g__aWM_CTLCOLORLISTBOX[$i][11] = -2 Then $iFgColor = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) $g__aWM_CTLCOLORLISTBOX[$i][7] = BitOR(BitAND($iFgColor, 0x00FF00), BitShift(BitAND($iFgColor, 0x0000FF), -16), BitShift(BitAND($iFgColor, 0xFF0000), 16)) If Not $g__aWM_CTLCOLORLISTBOX[0][1] Then If $g__aWM_CTLCOLORLISTBOX[$i][4] Then $g__aWM_CTLCOLORLISTBOX[0][1] = GUIRegisterMsg($WM_CTLCOLORLISTBOX, "UDF_WM_CTLCOLORLISTBOX") If $g__aWM_CTLCOLORLISTBOX[0][1] Then OnAutoItExitRegister("OnAutoItExit_UDF_WM_CTLCOLORLISTBOX") EndIf EndIf $g__aWM_CTLCOLORLISTBOX[0][2] += 1 $g__aWM_CTLCOLORLISTBOX[$i][9] = $g__aWM_CTLCOLORLISTBOX[0][2] ; internal ID $g__aWM_CTLCOLORLISTBOX[0][3] = TimerInit() ; to use in UDF_WM_CTLCOLORLISTBOX() $g__aWM_CTLCOLORLISTBOX[0][4] = 0 ; to use in UDF_WM_CTLCOLORLISTBOX() If $sStr Then GUICtrlSetData($idCombo, $sStr) Return SetError(0, 0, $g__aWM_CTLCOLORLISTBOX[0][2]) EndFunc ;==>GUICtrlComboSetColors Func UDF_WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam) ConsoleWrite('+ Func UDF_WM_CTLCOLORLISTBOX(' & $hWnd & ', ' & $Msg & ', ' & $wParam & ', ' & $lParam & ')' & @CRLF) For $i = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$i][4] = $lParam Then If TimerDiff($g__aWM_CTLCOLORLISTBOX[0][3]) > 500 Or $g__aWM_CTLCOLORLISTBOX[0][4] <> $lParam Then If $g__aWM_CTLCOLORLISTBOX[$i][12] Then GUICtrlComboSetColors_SetAutoSize("-" & $i) EndIf $g__aWM_CTLCOLORLISTBOX[0][3] = TimerInit() $g__aWM_CTLCOLORLISTBOX[0][4] = $lParam If $g__aWM_CTLCOLORLISTBOX[$i][8] > 0 Then Local $aWPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$i][2]) WinMove($lParam, "", $aWPos[0] - $g__aWM_CTLCOLORLISTBOX[$i][8], $aWPos[1] + $aWPos[3], $aWPos[2] + $g__aWM_CTLCOLORLISTBOX[$i][8]) ElseIf $g__aWM_CTLCOLORLISTBOX[$i][8] < 0 Then Local $aWPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$i][2]) WinMove($lParam, "", $aWPos[0], $aWPos[1] + $aWPos[3], $aWPos[2] - $g__aWM_CTLCOLORLISTBOX[$i][8]) EndIf If $g__aWM_CTLCOLORLISTBOX[$i][7] >= 0 Then _WinAPI_SetTextColor($wParam, $g__aWM_CTLCOLORLISTBOX[$i][7]) EndIf If $g__aWM_CTLCOLORLISTBOX[$i][6] >= 0 Then _WinAPI_SetBkColor($wParam, $g__aWM_CTLCOLORLISTBOX[$i][6]) If Not $g__aWM_CTLCOLORLISTBOX[$i][5] Then $g__aWM_CTLCOLORLISTBOX[$i][5] = _WinAPI_CreateSolidBrush($g__aWM_CTLCOLORLISTBOX[$i][6]) Return $g__aWM_CTLCOLORLISTBOX[$i][5] EndIf Return 0 EndIf Next EndFunc ;==>UDF_WM_CTLCOLORLISTBOX ; #FUNCTION# ==================================================================================================================== ; Name...........: GUICtrlComboSetColors_SetAutoSize ; Description ...: Set autosize for a ComboBox initialized in GUICtrlComboSetColors() ; Syntax.........: GUICtrlComboSetColors ( $idCombo [, $iExtendLeft = Default] [, $sFont = Default] [, $fSize = Default] [, $iStyle = Default] ) ; Parameters ....: $idCombo - GUICtrlCreateCombo() ControlID / [ ArrayIndex ] ; $iExtendLeft - 1 = Left, 2 = Right, 0 = disable auto-sizing ; $sFont - Font name ; $fSize - Font size ; $iStyle - Font style ; Return values .: Success - widthest string in pixels ; Failure - -1 ; @error - look at the comments in the function ; Author ........: argumentum ; Modified.......: v0.0.0.5 ; Remarks .......: this UDF is in its a work in progress, will expand if needed. ; Related .......: GUICtrlComboSetColors() ; Link ..........: https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-bgcolor/ ; Example .......: Yes, at the end of the file ; =============================================================================================================================== Func GUICtrlComboSetColors_SetAutoSize($idCombo, $iExtendLeft = Default, $sFont = Default, $fSize = Default, $iStyle = Default) ConsoleWrite('+ Func GUICtrlComboSetColors_AutoSizeSet("' & $idCombo & '", "' & $iExtendLeft & '", "' & $sFont & '", "' & $fSize & '", "' & $iStyle & '")' & @CRLF) $idCombo = Int($idCombo) ; just in case the value is a string Local $n, $iArrayIndex = 0, $iCtrl = 0 If $idCombo > 0 Then For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo Then ; the expected value, is the ControlID $iArrayIndex = $n ExitLoop EndIf Next Return SetError(4, 0, -1) ; $iArrayIndex not found ElseIf $idCombo < 0 Then ; the expected value, is a negative of array's index .. $iArrayIndex = Int(StringTrimLeft(StringStripWS($idCombo, 8), 1)) ; .. so now is a positive value .. If $iArrayIndex < 1 Then Return SetError(3, 0, -1) ; .. else, error .. If $iArrayIndex > $g__aWM_CTLCOLORLISTBOX[0][0] Then Return SetError(2, 0, -1) ; .. as long as is not greater than expected Else Return SetError(1, 0, -1) ; could not find a usable value EndIf Switch $iExtendLeft Case 0, 1, 2 $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][12] = $iExtendLeft EndSwitch Local $aCtrlPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$iArrayIndex][1]) If UBound($aCtrlPos) <> 4 Then Return SetError(5, 0, -1) ; could not get a usable value Local $sString = StringReplace(_GUICtrlComboBox_GetList($g__aWM_CTLCOLORLISTBOX[$iArrayIndex][0]), "|", @CRLF) Local $aStrWidth = _GDIPlus_MeasureString($sString, $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][13], $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][14], $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][15]) If UBound($aStrWidth) <> 2 Then Return SetError(6, 0, -1) ; could not get a usable value If $aStrWidth[0] < $aCtrlPos[2] Then $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = 0 Else $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = $aStrWidth[0] - $aCtrlPos[2] If $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][12] = 2 Then $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = Int("-" & $aStrWidth[0] - $aCtrlPos[2]) EndIf Return $aStrWidth[0] EndFunc ;==>GUICtrlComboSetColors_SetAutoSize Func _GDIPlus_MeasureString($sString, $sFont = "Arial", $fSize = 12, $iStyle = 0, $bRound = True) ConsoleWrite('Func _GDIPlus_MeasureString("' & $sString & '", "' & $sFont & '", "' & $fSize & '", "' & $iStyle & '", "' & $bRound & '")' & @CRLF) ; original code @ https://www.autoitscript.com/forum/topic/150736-gdi-wrapping-text/?do=findComment&comment=1077210 If Not $__g_iGDIPRef Then _GDIPlus_Startup() ; added by argumentum for this UDF's implementation ( AutoIt v3.3.14 ) due to the way the function is written ;~ Func _GDIPlus_Startup($sGDIPDLL = Default, $bRetDllHandle = False) ;~ $__g_iGDIPRef += 1 <-- I believe this aspect should be coded differently in "GDIPlus.au3" ;~ If $__g_iGDIPRef > 1 Then Return True Local $aSize[2] Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) If Not $hFamily Then Return SetError(1, 0, $aSize) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) Local Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND(0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) $aSize[0] = $bRound ? Round($aInfo[0].Width, 0) : $aInfo[0].Width $aSize[1] = $bRound ? Round($aInfo[0].Height, 0) : $aInfo[0].Height _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return $aSize EndFunc ;==>_GDIPlus_MeasureString Func OnAutoItExit_UDF_WM_CTLCOLORLISTBOX() For $i = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If Int($g__aWM_CTLCOLORLISTBOX[$i][5]) Then _WinAPI_DeleteObject($g__aWM_CTLCOLORLISTBOX[$i][5]) Next If $__g_iGDIPRef Then _GDIPlus_Shutdown() EndFunc ;==>OnAutoItExit_UDF_WM_CTLCOLORLISTBOX #EndRegion GUICtrlComboSetColors UDF Example() Func Example() ; Create GUI GUICreate("ComboBox Set DROPDOWNLIST BgColor", 640, 300) Local $a_idCombo[7] = [6] $a_idCombo[1] = GUICtrlCreateCombo("", 2, 2, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[1], 0xEEEEEE, -2, Default) Example_FillTheCombo($a_idCombo[1]) GUICtrlCreateLabel("<<< change BG color, default theme && size ", 400, 4, 396, 296) $a_idCombo[2] = GUICtrlCreateCombo("", 2, 32, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[2], 0x0000FF, 0xFFFF00, 0) Example_FillTheCombo($a_idCombo[2]) GUICtrlCreateLabel("<<< change colors", 400, 34, 396, 296) $a_idCombo[3] = GUICtrlCreateCombo("", 2, 62, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[3], 0xdddddd, Default, 100) Example_FillTheCombo($a_idCombo[3]) GUICtrlCreateLabel("<<< change BG color, resize 100px. left", 400, 64, 396, 296) $a_idCombo[4] = GUICtrlCreateCombo("", 2, 92, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[4], Default, 0x0000FF, -100) Example_FillTheCombo($a_idCombo[4]) GUICtrlCreateLabel("<<< change FG color, resize 100px. right", 400, 94, 396, 296) $a_idCombo[5] = GUICtrlCreateCombo("", 2, 122, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[5], 0x00FFFF, 0x0000FF, 1) Example_FillTheCombo($a_idCombo[5]) GUICtrlCreateLabel("<<< change colors, resize auto left", 400, 124, 396, 296) $a_idCombo[6] = GUICtrlCreateCombo("", 2, 152, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($a_idCombo[6], 10, 400, 0, "Courier New") GUICtrlComboSetColors($a_idCombo[6], Default, Default, "2;Courier New;10") Example_FillTheCombo($a_idCombo[6]) GUICtrlCreateLabel("<<< default colors, resize auto right", 400, 154, 396, 296) Local $bttnArrayShow = GUICtrlCreateButton("Show array", 2, 296 - 27, 75, 25) Local $bttnStrMore = GUICtrlCreateButton("Longer str.", 102, 296 - 27, 75, 25) Local $idLorem = GUICtrlCreateLabel("", 195, 296 - 27, 50, 25) Local $bttnStrLess = GUICtrlCreateButton("Shorter str.", 252, 296 - 27, 75, 25) GUISetState(@SW_SHOW) WinActivate("ComboBox Set DROPDOWNLIST BgColor") ;~ Sleep(3500) ; you can reassign colors, size, or restore default ;~ GUICtrlComboSetColors($idCombo5, Default, Default, 300) ; this resets the Control back to default and changes $iExtendLeft ;~ GUICtrlComboSetColors($idCombo5, 0x0000FF, 0x00FFFF, -1) ; this changes the colors and keeps $iExtendLeft as it was ;~ GUICtrlComboSetColors($idCombo5, -1, -1, 300) ; using "-1" will keep the existing colors ;~ ; so in this case, only the $iExtendLeft is declared ;~ Example_FillTheCombo($idCombo5) ;~ Sleep(500) ; after removal, it will not repaint "hList", but then again, you're deleteing the control ;~ GUICtrlComboSetColors($idColors, -3) ;~ GUICtrlDelete($idCombo2) Local $iLorem = 5, $sLorem = "" Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Return Case $bttnArrayShow _ArrayDisplay($g__aWM_CTLCOLORLISTBOX, "$g__aWM_CTLCOLORLISTBOX") Case $bttnStrMore $iLorem += 5 Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) Case $bttnStrLess $iLorem -= 5 Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) EndSwitch WEnd EndFunc ;==>Example Func Example_FillTheCombo(ByRef $idComboCtrl) GUICtrlSetData($idComboCtrl, "") _GUICtrlComboBox_AddString($idComboCtrl, "something") _GUICtrlComboBox_AddString($idComboCtrl, "something else") _GUICtrlComboBox_AddString($idComboCtrl, "blah, blah, blah, blah") _GUICtrlComboBox_AddString($idComboCtrl, "Lorem will change") Local $a = _GUICtrlComboBox_GetListArray($idComboCtrl) GUICtrlSetData($idComboCtrl, $a[1]) EndFunc ;==>Example_FillTheCombo Func Example_LoremStr(ByRef $iLorem, ByRef $sLorem, ByRef $a_idCombo, ByRef $idLorem) Local Static $s = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." $s &= " Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat." Local Static $i = 5, $a = StringSplit($s, " ") If $iLorem < 1 Then $iLorem = 1 If $iLorem > $a[0] Then $iLorem = $a[0] Local $x, $iLastEntry $sLorem = "" GUICtrlSetData($idLorem, $iLorem & ' words') For $x = 1 To $iLorem $sLorem &= $a[$x] & " " Next For $x = 1 To $a_idCombo[0] $iLastEntry = _GUICtrlComboBox_GetCount($a_idCombo[$x]) - 1 _GUICtrlComboBox_DeleteString($a_idCombo[$x], $iLastEntry) _GUICtrlComboBox_AddString($a_idCombo[$x], $sLorem) Next EndFunc ;==>Example_LoremStr new in v0.0.0.5: auto size the dropdown. You may also wanna take a look at ComboBox Color Background/Text subclass approach.1 point -
So, this is not one of my neatest scripts, but I haven't contributed much to the forum lately, and this was a help to me this week. I was migrating about 40 print queues from an old print server to a new one. Since this entails removing the old printer and creating the new printer for each user on each PC for each print queue used (for about 350 users), doing this manually was out of the question. I just added this to the logon scripts to run once per user per machine. If anyone finds the need to make a similar migration, please feel free to use/modify this. Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;don't want to crash out if there is a problem. #include "PrintMgr.au3" ;https://www.autoitscript.com/forum/topic/155485-printers-management-udf/ #include "ServiceControl.au3" ;https://www.autoitscript.com/forum/topic/6487-updated-service-control-funtions/ #include <array.au3> Global $sOldPrintServer = "oldservername" Global $sNewPrintServer = "newservername" Global $sDefaultPrinter = _CleanName(_GetDefaultPrinter()) ;If you change print queue names below, you may need to take that into account and modify $sDefaultPrinter as well. Global $aPrinters = _PrintMgr_EnumPrinter() If @error Then Exit Global $aReplaced[1] = [0] Global $sTempName ;remove printers that are mapped to old server For $iLoop = 1 To $aPrinters[0] If Not StringInStr($aPrinters[$iLoop], $sOldPrintServer) Then ContinueLoop ;not a printer we are concerned with $sTempName = $aPrinters[$iLoop] ConsoleWrite("Removing " & $sTempName & @CRLF) _PrintMgr_RemovePrinter($sTempName) $sTempName = _CleanName($sTempName) ;If you need to change a print queue name, modify $sTempName here before adding it to the array. _ArrayAdd($aReplaced, $sTempName) $aReplaced[0] = $aReplaced[0] + 1 Next ;Stop and re-start print spooler. This alleviated problems on a few machines. ConsoleWrite("Stopping Spooler" & @CRLF) _StopService(@ComputerName, "spooler") Sleep(1000) ConsoleWrite("Starting Spooler" & @CRLF) _StartService(@ComputerName, "spooler") Sleep(1000) ;remap to the new server (assuming all of the print queues have the same share name) For $iLoop = 1 To $aReplaced[0] Local $isdefault = False If $aReplaced[$iLoop] = $sDefaultPrinter Then $isdefault = True ConsoleWrite("Adding \\" & $sNewPrintServer & "\" & $aReplaced[$iLoop] & "(" & $isdefault & ")" & @CRLF) _PrintMgr_AddWindowsPrinterConnection("\\" & $sNewPrintServer & "\" & $aReplaced[$iLoop]) If $isdefault Then _PrintMgr_SetDefaultPrinter("\\" & $sNewPrintServer & "\" & $aReplaced[$iLoop]) Next Func _GetDefaultPrinter() ; CyberSlug - 18 Nov 2004 Local $key, $default, $defPrtNm If @OSType = "WIN32_WINDOWS" Then $key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers" $defPrtNm = RegRead("HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers", "Default") Else ;WIN_NT type $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers" $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device") $defPrtNm = StringLeft($default, StringInStr($default, ",") - 1) EndIf Return $defPrtNm EndFunc ;==>_GetDefaultPrinter Func _CleanName($sName) Local $sTempName = $sName $sTempName = StringReplace($sTempName, "\\" & $sOldPrintServer & "\", "") Return $sTempName EndFunc ;==>_CleanName Func MyErrFunc() ;just dump the info to the console and keep going Local $sErrNum Local $sMsg $sErrNum = Hex($oMyError.Number, 8) $sMsg = "Error Number: " & $sErrNum & @CRLF $sMsg &= "WinDescription: " & $oMyError.WinDescription & @CRLF $sMsg &= "Script Line: " & $oMyError.ScriptLine & @CRLF ConsoleWrite($sMsg) EndFunc ;==>MyErrFunc1 point
-
How to get notified when user clicks combo boxe's edit area ?
Earthshine reacted to Melba23 for a topic
kcvinu, Less elegant but seemingly effective: #include <GUIConstantsEx.au3> #include <GuiComboBox.au3> #include <WinAPI.au3> Global $tInfo, $bFocus = False Global $Window_0 = GUICreate("My Window", 800, 500) $btn = GUICtrlCreateButton("Click Me", 50, 50, 120, 50) Global $cmb = GUICtrlCreateCombo("Sample", 50, 150, 300, 50) Global $lstbx = GUICtrlCreateList("FirstItem", 400,50, 200, 300) GUICtrlSetData($cmb, "Item 2|Item 3", "Item 2") GUICtrlSetData($lstbx, "Apple|Orange|Pineapple|Grape|Lemon") GUISetState(@SW_SHOW) _GUICtrlComboBox_GetComboBoxInfo($cmb, $tInfo) $hComboEdit = DllStructGetData($tInfo, "hEdit") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If _WinAPI_GetFocus() = DllStructGetData($tInfo, "hEdit") And $bFocus = False Then $bFocus = True ConsoleWrite("True" & @CRLF) ElseIf _WinAPI_GetFocus() <> DllStructGetData($tInfo, "hEdit") And $bFocus = True Then $bFocus = False ConsoleWrite("False" & @CRLF) EndIf WEnd M231 point -
I don't know much about VB.NET, but I don't think standard controls and VB.NET controls are comparable with regard to code. And event messages and notifications are also not comparable. I think "ComboBox_Mouseclick" is a standard message. It's not implemented through subclassing. In AutoIt it's impossible without subclassing, because the internal message handler would "eat" all the mouse clicks.1 point
-
How to get notified when user clicks combo boxe's edit area ?
Earthshine reacted to LarsJ for a topic
Get a handle to the edit control and subclass the edit control: #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <WinAPIShellEx.au3> Global $g_idMemo Example() Func Example() Local $tInfo, $idCombo ; Create GUI GUICreate("ComboBox Get ComboBox Info", 400, 296) $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Add files _GUICtrlComboBox_BeginUpdate($idCombo) _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe") _GUICtrlComboBox_EndUpdate($idCombo) If _GUICtrlComboBox_GetComboBoxInfo($idCombo, $tInfo) Then MemoWrite("Handle to the ComboBox .....: " & DllStructGetData($tInfo, "hCombo")) MemoWrite("Handle to the Edit Box .....: " & DllStructGetData($tInfo, "hEdit")) MemoWrite("Handle to the drop-down list: " & DllStructGetData($tInfo, "hList")) EndIf Local $hEdit = DllStructGetData($tInfo, "hEdit") Local $pMsgHandler = DllCallbackGetPtr( DllCallbackRegister( "MsgHandler", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) _WinAPI_SetWindowSubclass( $hEdit, $pMsgHandler, 1000, 0 ) ; $iSubclassId = 1000, $pData = 0 ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Cleanup _WinAPI_RemoveWindowSubclass( $hEdit, $pMsgHandler, 1000 ) ; Unregister message handler GUIDelete() EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ; Message handler based on subclassing Func MsgHandler( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) Switch $iMsg Case $WM_LBUTTONDOWN ConsoleWrite( "$WM_LBUTTONDOWN" & @CRLF ) EndSwitch ; Call next function in subclass chain (this forwards WM_COMMAND messages to main GUI (other messages are already forwarded)) Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] EndFunc1 point -
How to get notified when user clicks combo boxe's edit area ?
kcvinu reacted to Earthshine for a topic
i literally typed in your question to google and got this. i hope it is helpful.1 point -
Please help me to code web auto login
Earthshine reacted to Jos for a topic
Please provide your full bankaccount details. Thanks so much!1 point -
How to loop through a files list for same processing steps
Earthshine reacted to JLogan3o13 for a topic
@DrGert welcome to the forum. See below: Open my image processing program (I can even do that manually before launching the Autoit script) Look at the Run function in the help file. Via mouse clicks navigate to the open file dialog Look at FileOpenDialog in the help file Inject a file path + name from a previously provided list Take a look at the example for FileOpenDialog, this function returns the path to the file you select. Via mouse clicks perform multiple steps of actions in the program Take a look at the AutoIt Window Info tool (in the same directory where you installed AutoIt). With the application open, hover over various features (buttons, menus, inputs, etc.) to see what the tool returns. Then look at the Control~ commands in the help file: ControlClick, ControlSend, etc. Pay attention to the examples for the Control commands to learn how to make use of the information you get from the AutoIt Window Info Tool. Via mouse clicks navigate to the file save as dialog Same as above Inject a path + name that has a relationship to the name under #3 (i.e. same name with additional suffix like name_processed.txt Same as above, using ControlSend or ControlSetText Via mouse click OK to save. ControlClick Jump to #2 until list in #3 is all done Check out For Loops in the help file to see how you can loop through all of the files Close program ControlClick Each of these sections of the help file has at least one solid example to give you an idea how the function works. Try them out for yourself, making sure you read and understand why things do what they do (will help you pick up harder tasks much more easily as you progress). If you get stuck on any section, post your code here even if it does not work, and we will do our best to assist1 point -
Speed up the Copying of all files in a folder over the network
Earthshine reacted to BrewManNH for a topic
Because you tell it to, and not where you indicated it does. You use _FileListToArray twice in 2 different functions. Want to speed it up, get rid of those functions you're using, such as _FileListToArrayEx and _DirListToArray and just use normal UDFs. _ArrayAdd slows down the script when you're just adding one item at a time due to having to call ReDim for every time you use it, and ReDim is slow.1 point -
Read or copy file from another pc over the internet
Belini reacted to Earthshine for a topic
Could you can set up Virtual Machines that could be your FTP servers?1 point -
Read or copy file from another pc over the internet
Belini reacted to JLogan3o13 for a topic
Again, you could do that if you want to set up an externally facing ftp server. You have to understand how vague "write and read information from a server" is. What are you trying to send (files, client/server application stream, etc.)?1 point -
Optimizing C# and VB code Index based sorting The examples in post 4 is an introduction to threading. The examples here shows how VB code can be optimized using multithreading. The examples are a continuation of the code in post 2 regarding index based sorting. Multithreaded sorting The idea is that if 4 threads are used to sort 100,000 rows, the first thread can sort the first 25,000 rows, the next thread can sort the next 25,000 rows, etc. It results in 4 indexes that finally can be combined into one big index. This is the code in Sort2DArrayOptEx.vb: Imports System Imports System.Threading Imports System.Collections Class SortArrayClass Dim aObjects, aCompare As Object(,) Dim iPartRows, iRestRows, iCmps As Integer Dim iThreads = 4, aIndex(iThreads)(), aRows(iThreads) As Integer Public Function Sort2DArray( aObjPar As Object(,), aCompPar As Object(,) ) As Integer() aObjects = aObjPar : aCompare = aCompPar Dim iRows As Integer = aObjects.GetUpperBound(1) + 1 iRestRows = iRows Mod iThreads : iPartRows = ( iRows - iRestRows ) / iThreads iCmps = aCompare.GetUpperBound(1) + 1 'Multithreaded index based sorting Dim th0 As New Thread( AddressOf Sort2DArraySub ) : th0.Start(0) Dim th1 As New Thread( AddressOf Sort2DArraySub ) : th1.Start(1) Dim th2 As New Thread( AddressOf Sort2DArraySub ) : th2.Start(2) Dim th3 As New Thread( AddressOf Sort2DArraySub ) : th3.Start(3) 'Main thread sleeps until sorting is done While aRows(0) = 0 Or aRows(1) = 0 Or aRows(2) = 0 Or aRows(3) = 0 Thread.Sleep(20) End While 'Combine four indexes into one Dim aIndexAll(iRows-1) As Integer Dim aIndexIdx(iThreads), iLeft, iRight, r, j As Integer For i As Integer = 0 To iRows - 1 iLeft = If( aIndexIdx(0) < aRows(0), 0, If( aIndexIdx(1) < aRows(1), 1, If( aIndexIdx(2) < aRows(2), 2, 3 ) ) ) iRight = iLeft While iRight < iThreads iRight += 1 Select iRight Case 1 iRight = If( aIndexIdx(1) < aRows(1), 1, If( aIndexIdx(2) < aRows(2), 2, If( aIndexIdx(3) < aRows(3), 3, iThreads ) ) ) Case 2 iRight = If( aIndexIdx(2) < aRows(2), 2, If( aIndexIdx(3) < aRows(3), 3, iThreads ) ) Case 3 iRight = If( aIndexIdx(3) < aRows(3), 3, iThreads ) End Select If iRight = iThreads Then Exit While r = 0 'Compare result (-1,0,1) j = 0 'Index in $aCompare array While r = 0 And j < iCmps r = If( aCompare(1,j), String.Compare( aObjects(aCompare(0,j),aIndex(iLeft)(aIndexIdx(iLeft))), aObjects(aCompare(0,j),aIndex(iRight)(aIndexIdx(iRight))) ), If( aObjects(aCompare(0,j),aIndex(iLeft)(aIndexIdx(iLeft))) < aObjects(aCompare(0,j),aIndex(iRight)(aIndexIdx(iRight))), -1, If( aObjects(aCompare(0,j),aIndex(iLeft)(aIndexIdx(iLeft))) > aObjects(aCompare(0,j),aIndex(iRight)(aIndexIdx(iRight))), 1, 0 ) ) ) * aCompare(2,j) j += 1 End While Select r Case 1 iLeft = iRight Case 0 If aIndex(iLeft)(aIndexIdx(iLeft)) > aIndex(iRight)(aIndexIdx(iRight)) Then iLeft = iRight End Select End While aIndexAll(i) = aIndex(iLeft)(aIndexIdx(iLeft)) aIndexIdx(iLeft) += 1 Next Return aIndexAll End Function 'Multithreaded index based sorting Private Sub Sort2DArraySub( oThread As Object ) Dim iThread As Integer = CInt( oThread ) Dim iFirstRow As Integer = If( iThread < iRestRows, iPartRows * iThread + iThread, iPartRows * iThread + iRestRows ) Dim iLastRow As Integer = iFirstRow + If( iThread < iRestRows, iPartRows, iPartRows - 1 ) Dim iRows As Integer = iLastRow - iFirstRow + 1 Dim MyList As New Generic.List( Of Integer ) MyList.Capacity = iRows MyList.Add(iFirstRow) 'Sorting by multiple columns Dim lo, hi, mi, r, j As Integer For i As Integer = iFirstRow + 1 To iLastRow lo = iFirstRow hi = i - 1 Do r = 0 'Compare result (-1,0,1) j = 0 'Index in $aCompare array mi = ( lo + hi ) / 2 While r = 0 And j < iCmps r = If( aCompare(1,j), String.Compare( aObjects(aCompare(0,j),i), aObjects(aCompare(0,j),MyList.Item(mi-iFirstRow)) ), If( aObjects(aCompare(0,j),i) < aObjects(aCompare(0,j),MyList.Item(mi-iFirstRow)), -1, If( aObjects(aCompare(0,j),i) > aObjects(aCompare(0,j),MyList.Item(mi-iFirstRow)), 1, 0 ) ) ) * aCompare(2,j) j += 1 End While Select r Case -1 hi = mi - 1 Case 1 lo = mi + 1 Case 0 Exit Do End Select Loop Until lo > hi MyList.Insert( If(lo=mi+1,mi+1,mi)-iFirstRow, i ) Next aIndex(iThread) = MyList.ToArray() aRows(iThread) = iRows End Sub End Class In Runtimes.au3 the execution times for sorting arrays with different number of rows are measuered for pure AutoIt code, for optimized VB code and for multithreaded VB code. This is the results on my PC: Code executed as 32 bit code Code executed as 64 bit code ============================ ============================ $iRows = 100, 6 columns $iRows = 100, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 4.3340 Pure AutoIt code: 3.7655 Optimized VB code: 1.2553 Optimized VB code: 1.4281 Multithreaded VB code: 19.0067 Multithreaded VB code: 33.5323 $iRows = 500, 6 columns $iRows = 500, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 27.5916 Pure AutoIt code: 25.5753 Optimized VB code: 2.6330 Optimized VB code: 2.8050 Multithreaded VB code: 31.2496 Multithreaded VB code: 36.4108 $iRows = 1000, 6 columns $iRows = 1000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 106.4464 Pure AutoIt code: 90.3135 Optimized VB code: 35.7356 Optimized VB code: 27.4234 Multithreaded VB code: 64.3406 Multithreaded VB code: 57.4474 $iRows = 2000, 6 columns $iRows = 2000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 142.1940 Pure AutoIt code: 134.2208 Optimized VB code: 11.6813 Optimized VB code: 10.9643 Multithreaded VB code: 30.2622 Multithreaded VB code: 33.4628 $iRows = 5000, 6 columns $iRows = 5000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 401.1128 Pure AutoIt code: 365.6661 Optimized VB code: 38.3885 Optimized VB code: 31.2551 Multithreaded VB code: 79.6997 Multithreaded VB code: 89.7060 $iRows = 10000, 6 columns $iRows = 10000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 826.2889 Pure AutoIt code: 691.7514 Optimized VB code: 70.5041 Optimized VB code: 65.1964 Multithreaded VB code: 89.2076 Multithreaded VB code: 60.4300 $iRows = 20000, 6 columns $iRows = 20000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 1816.3940 Pure AutoIt code: 1517.2513 Optimized VB code: 183.4977 Optimized VB code: 151.7480 Multithreaded VB code: 150.1049 Multithreaded VB code: 135.3445 $iRows = 50000, 6 columns $iRows = 50000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 5386.5884 Pure AutoIt code: 4239.2327 Optimized VB code: 602.9203 Optimized VB code: 471.3676 Multithreaded VB code: 373.1342 Multithreaded VB code: 371.5393 $iRows = 100000, 6 columns $iRows = 100000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 12798.0606 Pure AutoIt code: 9489.1929 Optimized VB code: 1590.7280 Optimized VB code: 1273.4829 Multithreaded VB code: 800.1118 Multithreaded VB code: 684.8815 $iRows = 250000, 6 columns $iRows = 250000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 44781.3723 Pure AutoIt code: 27407.9705 Optimized VB code: 7217.6899 Optimized VB code: 5222.3106 Multithreaded VB code: 2330.1729 Multithreaded VB code: 1914.2506 $iRows = 500000, 6 columns $iRows = 500000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 128479.2462 Pure AutoIt code: 69438.5295 Optimized VB code: 25016.8543 Optimized VB code: 16692.2426 Multithreaded VB code: 5949.0161 Multithreaded VB code: 4565.7862 $iRows = 750000, 6 columns $iRows = 750000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 250176.5552 Pure AutoIt code: 107785.2414 Optimized VB code: 54193.4737 Optimized VB code: 35217.0613 Multithreaded VB code: 10827.3308 Multithreaded VB code: 8186.0242 $iRows = 1000000, 6 columns $iRows = 1000000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 408457.7649 Pure AutoIt code: 162282.8254 Optimized VB code: 96291.4960 Optimized VB code: 62412.9602 Multithreaded VB code: 17399.9110 Multithreaded VB code: 12690.8546 $iRows = 2000000, 6 columns $iRows = 2000000, 6 columns Sort array by columns 0, 1, 2 Sort array by columns 0, 1, 2 ----------------------------------- ----------------------------------- Pure AutoIt code: 1445235.5246 Pure AutoIt code: 498648.9821 Optimized VB code: 409872.8400 Optimized VB code: 282116.6518 Multithreaded VB code: 63527.4207 Multithreaded VB code: 51087.1290 Code is added to "Examples\5) Optimizing C# and VB code\1) Index based sorting\" in zip-file in bottom of first post. Implementing a progress bar Another advantage of performing the sorting in 4 worker threads is that the main thread can be released by the VB code and thereby making the AutoIt code responsive while the sorting is going on. This makes it possible to implement a progress bar in the AutoIt code. The code in Sort2DArrayOptEx2.vb is changed a little bit: Imports System Imports System.Threading Imports System.Collections Class SortArrayClass Dim aObjects, aCompare As Object(,) Dim iRows, iPartRows, iRestRows, iCmps As Integer Dim iThreads = 4, aIndex(iThreads)(), aRows(iThreads) As Integer Public Sub Sort2DArray( aObjPar As Object(,), aCompPar As Object(,) ) aObjects = aObjPar : aCompare = aCompPar : iRows = aObjects.GetUpperBound(1) + 1 iRestRows = iRows Mod iThreads : iPartRows = ( iRows - iRestRows ) / iThreads iCmps = aCompare.GetUpperBound(1) + 1 'Multithreaded index based sorting Dim th0 As New Thread( AddressOf Sort2DArraySub ) : th0.Start(0) Dim th1 As New Thread( AddressOf Sort2DArraySub ) : th1.Start(1) Dim th2 As New Thread( AddressOf Sort2DArraySub ) : th2.Start(2) Dim th3 As New Thread( AddressOf Sort2DArraySub ) : th3.Start(3) End Sub 'Multithreaded index based sorting Private Sub Sort2DArraySub( oThread As Object ) Dim iThread As Integer = CInt( oThread ) Dim iFirstRow As Integer = If( iThread < iRestRows, iPartRows * iThread + iThread, iPartRows * iThread + iRestRows ) Dim iLastRow As Integer = iFirstRow + If( iThread < iRestRows, iPartRows, iPartRows - 1 ) Dim iSubRows As Integer = iLastRow - iFirstRow + 1 Dim MyList As New Generic.List( Of Integer ) MyList.Capacity = iSubRows MyList.Add(iFirstRow) 'Sorting by multiple columns Dim lo, hi, mi, r, j As Integer For i As Integer = iFirstRow + 1 To iLastRow lo = iFirstRow hi = i - 1 Do r = 0 'Compare result (-1,0,1) j = 0 'Index in $aCompare array mi = ( lo + hi ) / 2 While r = 0 And j < iCmps r = If( aCompare(1,j), String.Compare( aObjects(aCompare(0,j),i), aObjects(aCompare(0,j),MyList.Item(mi-iFirstRow)) ), If( aObjects(aCompare(0,j),i) < aObjects(aCompare(0,j),MyList.Item(mi-iFirstRow)), -1, If( aObjects(aCompare(0,j),i) > aObjects(aCompare(0,j),MyList.Item(mi-iFirstRow)), 1, 0 ) ) ) * aCompare(2,j) j += 1 End While Select r Case -1 hi = mi - 1 Case 1 lo = mi + 1 Case 0 Exit Do End Select Loop Until lo > hi MyList.Insert( If(lo=mi+1,mi+1,mi)-iFirstRow, i ) If ( i - iFirstRow ) Mod 1000 = 0 Then aRows(iThread) = i - iFirstRow Next aIndex(iThread) = MyList.ToArray() aRows(iThread) = iSubRows End Sub Public Function Sort2DArrayGetCount() As Integer Return aRows(0) + aRows(1) + aRows(2) + aRows(3) End Function Public Function Sort2DArrayGetIndex() As Integer() 'Combine four indexes into one Dim aIndexAll(iRows-1) As Integer Dim aIndexIdx(iThreads), iLeft, iRight, r, j As Integer For i As Integer = 0 To iRows - 1 iLeft = If( aIndexIdx(0) < aRows(0), 0, If( aIndexIdx(1) < aRows(1), 1, If( aIndexIdx(2) < aRows(2), 2, 3 ) ) ) iRight = iLeft While iRight < iThreads iRight += 1 Select iRight Case 1 iRight = If( aIndexIdx(1) < aRows(1), 1, If( aIndexIdx(2) < aRows(2), 2, If( aIndexIdx(3) < aRows(3), 3, iThreads ) ) ) Case 2 iRight = If( aIndexIdx(2) < aRows(2), 2, If( aIndexIdx(3) < aRows(3), 3, iThreads ) ) Case 3 iRight = If( aIndexIdx(3) < aRows(3), 3, iThreads ) End Select If iRight = iThreads Then Exit While r = 0 'Compare result (-1,0,1) j = 0 'Index in $aCompare array While r = 0 And j < iCmps r = If( aCompare(1,j), String.Compare( aObjects(aCompare(0,j),aIndex(iLeft)(aIndexIdx(iLeft))), aObjects(aCompare(0,j),aIndex(iRight)(aIndexIdx(iRight))) ), If( aObjects(aCompare(0,j),aIndex(iLeft)(aIndexIdx(iLeft))) < aObjects(aCompare(0,j),aIndex(iRight)(aIndexIdx(iRight))), -1, If( aObjects(aCompare(0,j),aIndex(iLeft)(aIndexIdx(iLeft))) > aObjects(aCompare(0,j),aIndex(iRight)(aIndexIdx(iRight))), 1, 0 ) ) ) * aCompare(2,j) j += 1 End While Select r Case 1 iLeft = iRight Case 0 If aIndex(iLeft)(aIndexIdx(iLeft)) > aIndex(iRight)(aIndexIdx(iRight)) Then iLeft = iRight End Select End While aIndexAll(i) = aIndex(iLeft)(aIndexIdx(iLeft)) aIndexIdx(iLeft) += 1 Next Return aIndexAll End Function End Class In Progressbar.au3 the execution times are measuered for the new code. This is the results on my PC when the code is run as 64 bit code: 250,000 rows Generate array Array generated 782.829209100278 Start sorting ... Sorting started 1052.33601879453 Sorting finished 3112.24138122098 Get index ... Index received 628.809605602899 500,000 rows Generate array Array generated 1692.53510123118 Start sorting ... Sorting started 1736.08362238057 Sorting finished 5300.57901794125 Get index ... Index received 987.373807333858 750,000 rows Generate array Array generated 2701.3300790124 Start sorting ... Sorting started 2846.97747093829 Sorting finished 8147.51853411496 Get index ... Index received 1427.32770753222 1,000,000 rows Generate array Array generated 3671.26491871585 Start sorting ... Sorting started 3360.98083976994 Sorting finished 11515.8238123206 Get index ... Index received 1913.89753875819 2,000,000 rows Generate array Array generated 7789.33304890347 Start sorting ... Sorting started 6773.98630303971 Sorting finished 48250.9211649065 Get index ... Index received 3852.50335220913 Note the lines titled "Sorting started". These are the lines that measure the time it takes to execute this code: Public Sub Sort2DArray( aObjPar As Object(,), aCompPar As Object(,) ) aObjects = aObjPar : aCompare = aCompPar : iRows = aObjects.GetUpperBound(1) + 1 iRestRows = iRows Mod iThreads : iPartRows = ( iRows - iRestRows ) / iThreads iCmps = aCompare.GetUpperBound(1) + 1 'Multithreaded index based sorting Dim th0 As New Thread( AddressOf Sort2DArraySub ) : th0.Start(0) Dim th1 As New Thread( AddressOf Sort2DArraySub ) : th1.Start(1) Dim th2 As New Thread( AddressOf Sort2DArraySub ) : th2.Start(2) Dim th3 As New Thread( AddressOf Sort2DArraySub ) : th3.Start(3) End Sub Most of the time is spent by passing the array ($aArray) as a parameter from the AutoIt code to the VB method (in aObjPar). Code is added to "Examples\5) Optimizing C# and VB code\1) Index based sorting\" in zip-file in bottom of first post. Global array variable Post 2 is a UDF version of four examples about generating a 2D array of random data, sorting the array by one or more columns through an index, converting the 2D array to a 1D array in CSV format, and finally saving the 1D array as a CSV file. The code is stored in "Examples\3) UDF version of examples\" in zip-file in bottom of first post. I've added a new example, ExampleOpt2.au3, to the Examples folder, where the execution times and the total execution time for these 4 procedures are measured for an array with 250,000 rows. This is the results: Code executed as 32 bit code Code executed as 64 bit code ============================ ============================ 250000 rows 250000 rows Generate array: 995.724559926393 Generate array: 797.652719123923 Sort array: 7236.27375117504 Sort array: 5291.30258795446 Convert array: 1426.65439887983 Convert array: 1224.09933028633 Save array: 450.983570086659 Save array: 383.220670832949 Total time: 10109.6362800679 Total time: 7696.27530819767 At the bottom of the example above we saw that quite a lot of time is being used to transfer arrays between the AutoIt code and the VB code. One way to avoid the time used to transfer arrays between AutoIt code and VB code is to store the array ($aArray/aObjects) as a global variable in the VB code. This is implemented in "Examples\5) Optimizing C# and VB code\2) Global array variable\Includes\ArrayFuncsOpt.vb". There is also used a multithreaded version of the sorting code. And the two procedures to convert and save the array as a CSV file is combined into one procedure to avoid transfering the array of strings back and forth. This is the time measurement for the new code: Code executed as 32 bit code Code executed as 64 bit code ============================ ============================ 250000 rows 250000 rows Generate array: 696.800872597593 Generate array: 516.643380589801 Sort array: 1542.99252546023 Sort array: 1465.04082474547 Save array: 446.520844017085 Save array: 418.329314718878 Total time: 2686.31424207491 Total time: 2400.01352005415 Code in "Examples\5) Optimizing C# and VB code\2) Global array variable\" in zip-file in bottom of first post. Delete global variables To delete global variables used in the VB code simply delete the object. The objects are solely handled in Includes\ArrayFuncsOpt.au3 UDF (there are no objects directly in the user code). The $oArrayClass object which is an instance of the ArrayClass in the VB code is created in ArrayFuncsOptInit() in this way: Func ArrayFuncsOptInit( $bDelObj = False ) Static $oNetCode = 0, $oArrayClass = 0 If $bDelObj Then $oArrayClass = 0 $oArrayClass = DotNet_CreateObject( $oNetCode, "ArrayClass" ) Return EndIf If IsObj( $oArrayClass ) Then Return $oArrayClass ; Compile and load VB code, create ArrayClass object $oNetCode = DotNet_LoadVBcode( FileRead( "..\Includes\ArrayFuncsOpt.vb" ), "System.dll" ) $oArrayClass = DotNet_CreateObject( $oNetCode, "ArrayClass" ) Return $oArrayClass EndFunc And the object is deleted in ArrayFuncsDelObject() by calling ArrayFuncsOptInit() with the $bDelObj parameter set to True: Func ArrayFuncsDelObject() ArrayFuncsOptInit( True ) EndFunc When the old object is deleted, a new object is created. ArrayFuncsDelObject() is called in bottom of ExampleOpt2.au3. Similar procedures are used in the example with the progress bar above to delete the old object and create a new.1 point
-
Someone solved the problem of closing?1 point
-
Can't get ID of button on app to be able to press it
argumentum reacted to junkew for a topic
Its probably more difficult and you need to send the proper messages around http://mh-nexus.de/en/delphimessages.php VCL Control Notifications VCL Control Notifications are just reflections of the corresponding WM_xxx messages. They are sent by a window to their parent window (not VCL but Windows). This makes in Delphi no sense as the parent knows basically nothing about its child windows and can therefore not handle them. Each of these messages contains in its lParam the handle of the child window which has sent the message. The VCL does nothing else then to add CN_BASE to the message value and sends the message then to the window which created it originally. This way windows can handle their special messages themselves. Control Notification Value CN_BASE $BC00 CN_CHAR CN_BASE + WM_CHAR CN_CHARTOITEM CN_BASE + WM_CHARTOITEM CN_COMMAND CN_BASE + WM_COMMAND CN_COMPAREITEM CN_BASE + WM_COMPAREITEM CN_CTLCOLORBTN CN_BASE + WM_CTLCOLORBTN CN_CTLCOLORDLG CN_BASE + WM_CTLCOLORDLG CN_CTLCOLOREDIT CN_BASE + WM_CTLCOLOREDIT CN_CTLCOLORLISTBOX CN_BASE + WM_CTLCOLORLISTBOX CN_CTLCOLORMSGBOX CN_BASE + WM_CTLCOLORMSGBOX CN_CTLCOLORSCROLLBAR CN_BASE + WM_CTLCOLORSCROLLBAR CN_CTLCOLORSTATIC CN_BASE + WM_CTLCOLORSTATIC CN_DELETEITEM CN_BASE + WM_DELETEITEM CN_DRAWITEM CN_BASE + WM_DRAWITEM CN_KEYDOWN CN_BASE + WM_KEYDOWN CN_KEYUP CN_BASE + WM_KEYUP CN_HSCROLL CN_BASE + WM_HSCROLL CN_MEASUREITEM CN_BASE + WM_MEASUREITEM CN_NOTIFY CN_BASE + WM_NOTIFY CN_PARENTNOTIFY CN_BASE + WM_PARENTNOTIFY CN_SYSKEYDOWN CN_BASE + WM_SYSKEYDOWN CN_SYSCHAR CN_BASE + WM_SYSCHAR CN_VKEYTOITEM CN_BASE + WM_VKEYTOITEM CN_VSCROLL CN_BASE + WM_VSCROLL1 point -
I don't really give a shit whether this post breaks the rules or not. What I do give a shit about is your pathetic attitude. BigDod's opinion on whether or not doesn't matter. Your opinion ESPECIALLY doesn't matter (Do you know how many times people clearly breaking the rules claim they aren't?). The opinion of a moderator matters and this thread required our opinion. BigDod did the exact right thing by reporting it for clarification. You fucked everything up, though, with your shit attitude. If Jos had not beaten me to this thread I would have banned you for a few days for the attitude. Since he beat me here and feels the thread should be locked I'm going to just leave it at that. So to be clear, this thread isn't locked because it breaks any rules (It might or it might not, I don't care to evaluate that aspect). It's locked because you took a shitty attitude about the whole thing instead of waiting for a moderator to come along and confirm one way or the other. If it weren't for your attitude Jos would have easily deferred to someone with more poker knowledge (Likely me) and I would have bothered to determine if you're breaking the rules or not. As it stands, I don't care. I do, however, strongly discourage you from broaching the subject again on this forum as that is very clearly against the rules. Next time you claim you have nothing to hide prove it by keeping your word-hole shut until your claims are validated. Trying to vigorously defend yourself with a poor attitude only implies guilt even if there isn't real guilt. TL;DR version: Use your fucking brain, not your fingers.1 point
-
IconFileScanner
argumentum reacted to Valuater for a topic
UPDATED... ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.8.2.2 ( updated by Valuater) ; Author: Holger Kotsch ; ; Script Function: ; IconFileScanner 1.3.1 (added few features by G.Sandler (MsCreatoR), and "correction fix" for 3.8.2.1 by ptrex) ; ; ---------------------------------------------------------------------------- #NoTrayIcon #include <GUIConstantsEX.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #Include <GuiListView.au3> #Include <GuiListBox.au3> Opt("GuiOnEventMode", 1) HotKeySet("{ESC}", "QuitApp") HotKeySet("{DOWN}", "UpDownPressed") HotKeySet("{UP}", "UpDownPressed") Global Const $LVM_SETCOLUMN = 0x101A Global Const $LVM_GETITEM = $LVM_FIRST + 5 Global $ConfigFile = StringTrimRight(@ScriptFullPath, 3) & "ini" Global $szDirType = RegRead("HKCR\Directory", "") If $szDirType = "" Then $szDirType = "Directory" Global $nFirstEntry = 0, $nLastEntry = 0 Global $szVersion = "1.3.1" Global $nCurCol = -1 Global $nSortDir = 1 Global $bSet = 0 Global $nCol = -1 Global $nIcon = -1 Global $szCurrentPath = IniRead($ConfigFile, "Main Prefs", "Current Folder To Scan", @WindowsDir) Global $FoldersToScan = IniRead($ConfigFile, "Main Prefs", "Folders To Scan", $szCurrentPath) $hGUI = GUICreate("Icon File Scanner", 585, 342, -1, -1, _ BitOr($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, "QuitApp") GUISetOnEvent($GUI_EVENT_RESIZED, "MainEvents") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "MainEvents") GUISetOnEvent($GUI_EVENT_DROPPED, "MainEvents") GUISetIcon("shell32.dll", -219) $nFileMenu = GUICtrlCreateMenu("&File") $nFileSelFolder = GUICtrlCreateMenuItem("Select Folder...",$nFileMenu) $nViewMenu = GUICtrlCreateMenu("&View") $nViewMenuItem0 = GUICtrlCreateMenuItem("Icons", $nViewMenu, -1, 1) $nViewMenuItem1 = GUICtrlCreateMenuItem("Report", $nViewMenu, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $nViewMenuItem2 = GUICtrlCreateMenuItem("SmallIcons", $nViewMenu,-1, 1) $nViewMenuItem3 = GUICtrlCreateMenuItem("List", $nViewMenu, -1, 1) $nHelpMenu = GUICtrlCreateMenu("&Help") $nAboutItem = GUICtrlCreateMenuItem("About",$nHelpMenu) GUICtrlCreateLabel("", 0, 0, 701, 2, $SS_SUNKEN) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT) $nPathLabel = GUICtrlCreateLabel("Path:",5, 5, 30, 18) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nCurPath = GUICtrlCreateCombo("", 35, 2, 350, 20) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DROPACCEPTED) If $FoldersToScan <> "" Then GUICtrlSetData(-1, $FoldersToScan, $szCurrentPath) $nGoButton= GUICtrlCreateButton("Go", 385, 2, 25, 20, $BS_FLAT) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nPathButton= GUICtrlCreateButton("...", 410, 2, 25, 20, BitOr($BS_ICON, $BS_FLAT)) GUICtrlSetImage(-1, "shell32.dll", 3, 0) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nDirList = GUICtrlCreateListView("Name|Size|Type|Changed", 0, 23, 390, 280) GUICtrlRegisterListViewSort(-1, "LVSort") GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlListViewSetColumnFormat($nDirList, 1, $LVCFMT_RIGHT) GUICtrlSetImage(-1, "shell32.dll", 0) $nContext = GUICtrlCreateContextMenu($nDirList) $viewitem = GUICtrlCreateMenu("View", $nContext) $nDirItem0 = GUICtrlCreateMenuItem("Icons", $viewitem, -1, 1) $nDirItem1 = GUICtrlCreateMenuItem("Report", $viewitem, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $nDirItem2 = GUICtrlCreateMenuItem("SmallIcons", $viewitem,-1, 1) $nDirItem3 = GUICtrlCreateMenuItem("List", $viewitem, -1, 1) $OpenWithItem = GUICtrlCreateMenuItem("Open with...", $nContext) $ShowPropertiesItem = GUICtrlCreateMenuItem("Properties...", $nContext) GUICtrlCreateMenuItem("", $nContext) $nInfoItem = GUICtrlCreateMenuItem("Info", $nContext) $nIconList = GUICtrlCreateListView("Icon", 395, 23, 190, 280) GUICtrlSetStyle(-1, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) ;set this LView to LVS_ICON-style cause LVS_ICON=0x0000 GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $nIconMenu = GUICtrlCreateContextMenu($nIconList) $nIconItem0 = GUICtrlCreateMenuItem("Icons", $nIconMenu, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $nIconItem1 = GUICtrlCreateMenuItem("Report", $nIconMenu, -1, 1) $nIconItem2 = GUICtrlCreateMenuItem("SmallIcons", $nIconMenu,-1, 1) $nIconItem3 = GUICtrlCreateMenuItem("List", $nIconMenu, -1, 1) $nFileInfo = GUICtrlCreateLabel("File:", 0, 305, 390, 18, $SS_SUNKEN) GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT) $nIconInfo = GUICtrlCreateLabel("Icons:", 395, 305, 190, 18, $SS_SUNKEN) GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT) For $i = $nFileSelFolder To $nIconItem3 GUICtrlSetOnEvent($i, "MainEvents") Next GUISetState() $nFirstItem = 0 $nLastItem = 0 $nFirstIcon = 0 $nLastIcon = 0 $nOldItem = 0 DirToList($szCurrentPath) GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, 0, -1) GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, 0, -2) While 1 Sleep(100) WEnd Func MainEvents() Switch @GUI_CtrlId Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE GUISetState(@SW_LOCK, $hGUI) $nStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", GUICtrlGetHandle($nIconList), "int", -16) $nStyle = BitAnd($nStyle[0], 0x0003) GUICtrlSetStyle($nIconList, BitOr(1, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) GUICtrlSetStyle($nIconList, BitOr($nStyle, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) GUISetState(@SW_UNLOCK, $hGUI) Case $GUI_EVENT_DROPPED If Not StringInStr(FileGetAttrib(@GUI_DragFile), "D") Then Return GUICtrlSetData($nCurPath, @GUI_DragFile, @GUI_DragFile) ControlClick($hGUI, "", $nGoButton) Case $OpenWithItem Local $sListStr = GUICtrlRead(GUICtrlRead($nDirList)) If $sListStr = "" Then Return RefreshItem(@GUI_CtrlId) Local $GetFullPath = $szCurrentPath & '\' & StringLeft($sListStr, StringInStr($sListStr, "|")-1) Run('rundll32 shell32,OpenAs_RunDLL ' & $GetFullPath) Case $ShowPropertiesItem Local $sListStr = GUICtrlRead(GUICtrlRead($nDirList)) If $sListStr = "" Then Return RefreshItem(@GUI_CtrlId) Local $GetFullPath = $szCurrentPath & '\' & StringLeft($sListStr, StringInStr($sListStr, "|")-1) _ShellExecuteEx($GetFullPath, "", "", "Properties") Case $nAboutItem, $nInfoItem RefreshItem(@GUI_CtrlId) _Msgbox(64, "About", "IconFileScanner " & $szVersion & " by Holger Kotsch", $hGUI) Case $nPathButton, $nFileSelFolder, $nGoButton, $nCurPath If @GUI_CtrlId = $nGoButton Or @GUI_CtrlId = $nCurPath Then $szFolder = GUICtrlRead($nCurPath) If Not FileExists($szFolder) Then Return $FoldersToScan &= "|" & $szFolder Else GUISetState(@SW_DISABLE) $szFolder = FileSelectFolder("Select folder to scan", "", 0, $szCurrentPath) GUISetState(@SW_ENABLE) EndIf If $szFolder <> "" Then $szCurrentPath = $szFolder GUICtrlSetData($nCurPath, $szCurrentPath, $szCurrentPath) GUICtrlSetData($nFileInfo, "Scanning folder...") GUICtrlSetData($nIconInfo, "Icons:") For $i = $nFirstIcon To $nLastIcon GUICtrlDelete($i) Next For $i = $nFirstItem To $nLastItem GUICtrlDelete($i) Next $nFirstItem = 0 $nLastItem = 0 $nFirstIcon = 0 $nLastIcon = 0 $nOldItem = 0 GUISetCursor(1) GUICtrlSetCursor($nDirList,1) DirToList($szCurrentPath) GUISetCursor(2) GUICtrlSetCursor($nDirList,2) EndIf Case $nDirItem0 To $nDirItem3, $nViewMenuItem0 To $nViewMenuItem3 If @GUI_CtrlId >= $nDirItem0 And @GUI_CtrlId <= $nDirItem3 Then $nMsgItem = $nDirItem0 For $i = 0 To 3 GUICtrlSetState($nViewMenuItem0 + $i, $GUI_UNCHECKED) Next GUICtrlSetState($nViewMenuItem0 + @GUI_CtrlId - $nMsgItem, $GUI_CHECKED) Else $nMsgItem = $nViewMenuItem0 For $i = 0 To 3 GUICtrlSetState($nDirItem0 + $i, $GUI_UNCHECKED) Next GUICtrlSetState($nDirItem0 + @GUI_CtrlId - $nMsgItem, $GUI_CHECKED) EndIf GUICtrlSetStyle($nDirList, BitOr(@GUI_CtrlId - $nMsgItem, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) If BitAnd(@GUI_CtrlId - $nMsgItem, $LVS_REPORT) Then GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, 0, 200) For $i = 1 To 3 GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, $i, -1) GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, $i, -2) Next EndIf Case $nIconItem0 To $nIconItem3 GUICtrlSetStyle($nIconList, BitOr(@GUI_CtrlId - $nIconItem0, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) Case $nFirstItem To $nLastItem RefreshItem(@GUI_CtrlId) Case $nDirList $bSet = 0 $nCurCol = $nCol GUICtrlSendMsg($nDirList, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($nDirList), 0) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($nDirList), "int", 0, "int", 1) EndSwitch EndFunc Func RefreshItem($nMsg) Local $sListStr = GUICtrlRead(GUICtrlRead($nDirList)) If Not StringInStr($sListStr, "|") Then Return If $nOldItem = $nMsg Then Return $nOldItem = $nMsg $szFileInfo = StringSplit($sListStr, "|") $szFile = $szFileInfo[1] If $nFirstIcon > 0 Then For $i = $nFirstIcon To $nLastIcon GUICtrlDelete($i) Next EndIf GUICtrlSetData($nFileInfo, "Type: " & $szFileInfo[3] & " Changed at: " & $szFileInfo[4] & " Size: " & $szFileInfo[2]) $nIcons = FileGetIconCount($szCurrentPath & "\" & $szFile) GUICtrlSetData($nIconInfo, "Extracting icons...") GUISetCursor(1) GUICtrlSetCursor($nIconList,1) For $i = 1 To $nIcons $nIcon = GUICtrlCreateListViewItem($i, $nIconList) GUICtrlSetImage(-1, $szCurrentPath & "\" & $szFile, $i * -1) If $nFirstIcon = 0 Then $nFirstIcon = $nIcon Next GUICtrlSetData($nIconInfo, "Icons: " & $nIcons) GUISetCursor(2) GUICtrlSetCursor($nIconList, 2) $nLastIcon = $nIcon EndFunc Func UpDownPressed() If Not HotKeysHandler($hGUI, "UpDownPressed") Then Return Local $CountItems = ControlListView($hGUI, "", $nDirList, "GetItemCount") Local $SelectedIndex = ControlListView($hGUI, "", $nDirList, "GetSelected") Local $NewIndex = $SelectedIndex Switch @HotKeyPressed Case "{DOWN}" $NewIndex += 1 Case "{UP}" $NewIndex -= 1 EndSwitch If $NewIndex >= $CountItems Or $NewIndex < 0 Then Return ControlListView($hGui, "", $nDirList, "Select", $NewIndex) RefreshItem(GUICtrlRead($nDirList)) Local $hList = GUICtrlGetHandle($nDirList) DllCall("user32.dll", "long", "SendMessage", "hwnd", $hList, "int", 0x1013, "int", $NewIndex, "int", 0) ;$LVM_ENSUREVISIBLE EndFunc Func HotKeysHandler($hWnd, $FuncName) If Not WinActive($hWnd) Then HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, $FuncName) Return 0 EndIf Return 1 EndFunc Func _ShellExecuteEx($sCmd, $Args = "", $sFolder = "", $Verb = "", $rState = @SW_SHOWNORMAL, $hWnd = 0) Local $struINFO = DllStructCreate("long;long;long;ptr;ptr;ptr;ptr;long;long;long;ptr;long;long;long;long") Local $struVerb = DllStructCreate("char[15];char") Local $struPath = DllStructCreate("char[255];char") Local $struArgs = DllStructCreate("char[255];char") Local $struWDir = DllStructCreate("char[255];char") DllStructSetData($struVerb, 1, $Verb) If StringRight($sCmd, 3) = "lnk" Then Local $aShortcutInfo = FileGetShortcut($sCmd) If IsArray($aShortcutInfo) Then DllStructSetData($struPath, 1, $aShortcutInfo[0]) DllStructSetData($struWDir, 1, $aShortcutInfo[1]) DllStructSetData($struArgs, 1, $aShortcutInfo[2]) $rState = $aShortcutInfo[6] Else Return 0 EndIf Else DllStructSetData($struPath, 1, $sCmd) DllStructSetData($struWDir, 1, $sFolder) DllStructSetData($struArgs, 1, $Args) EndIf DllStructSetData($struINFO, 1, DllStructGetSize($struINFO)) DllStructSetData($struINFO, 2, BitOR(0xC, 0x40, 0x400)) DllStructSetData($struINFO, 3, $hWnd) DllStructSetData($struINFO, 4, DllStructGetPtr($struVerb)) DllStructSetData($struINFO, 5, DllStructGetPtr($struPath)) DllStructSetData($struINFO, 6, DllStructGetPtr($struArgs)) DllStructSetData($struINFO, 7, DllStructGetPtr($struWDir)) DllStructSetData($struINFO, 8, $rState) Local $iRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($struINFO)) Return $iRet[0] EndFunc Func FileGetIconCount($szFile) Local $nCount = 0 Local $LPCTSTR = DllStructCreate("char[260]") DllStructSetData($LPCTSTR, 1, $szFile) $nCount = DllCall("shell32.dll", "int", "ExtractIconEx", "ptr", DllStructGetPtr($LPCTSTR), "int", -1, "int", 0, "int", 0, "int", 0) Return $nCount[0] EndFunc Func DirToList($szPath) Dim $hSearch, $szFile, $szDate, $szType, $nItem $hSearch = FileFindFirstFile($szPath & "\*.*") If $hSearch <> -1 Then $nItem = -1 While 1 $szFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $szFile <> "." And $szFile <> ".." And Not StringInStr(FileGetAttrib($szPath & "\" & $szFile), "D") Then $szExt = ".ani|.cpl|.ico|.icl|.dll|.exe" $szExt = StringSplit($szExt, "|") $nExtFound = 0 For $i = 1 To $szExt[0] If StringInStr($szFile, $szExt[$i]) Then $nExtFound = 1 ExitLoop EndIf Next If $nExtFound Then $nIcon = 0 $szIconFile = $szPath & "\" & $szFile If FileGetIconCount($szIconFile) > 0 Then If FileGetIcon($szIconFile, $nIcon, $szFile) Then $szSize = Round(FileGetSize($szPath & "\" & $szFile) / 1000) & " KB" $szType = FileGetType($szFile) $arDate = FileGetTime($szPath & "\" & $szFile) If IsArray($arDate) Then $szDate = $arDate[2] & "." & $arDate[1] & "." & _ $arDate[0] & " " & $arDate[3] & ":" & $arDate[4] $nItem = GUICtrlCreateListViewItem($szFile & "|" & $szSize & "|" & $szType & "|" & $szDate, $nDirList) GUICtrlSetImage($nItem, $szIconFile, -$nIcon) GUICtrlSetOnEvent($nItem, "MainEvents") If $nFirstItem = 0 Then $nFirstItem = $nItem EndIf EndIf EndIf EndIf WEnd FileClose($hSearch) $nLastItem = $nItem If $nLastItem > 0 Then GUICtrlSetData($nFileInfo, $nLastItem - $nFirstItem & " Objects") Else GUICtrlSetData($nFileInfo, "Ready") EndIf EndIf EndFunc Func FileGetType($szFile) Local $szRegDefault = "", $szRegType = "" $szExt = StringRight($szFile,4) $szRegDefault = RegRead("HKCR\" & $szExt,"") If $szRegDefault <> "" Then $szRegType = RegRead("HKCR\" & $szRegDefault,"") If $szRegType = "" Then $szRegType = $szExt & "-File" Return $szRegType EndFunc Func FileGetIcon(ByRef $szIconFile, ByRef $nIcon, $szFile) Local $szRegDefault = "", $szDefIcon = "" $nIcon = 0 $szExt = StringRight($szFile,4) $szRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $szExt,"ProgID") If $szRegDefault = "" Then $szRegDefault = RegRead("HKCR\" & $szExt,"") If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\" & $szRegDefault & "\DefaultIcon","") If $szDefIcon = "" Then $szIconFile = "shell32.dll" ElseIf $szDefIcon <> "%1" Then $arSplit = StringSplit($szDefIcon,",") If IsArray($arSplit) Then $szIconFile = $arSplit[1] If $arSplit[0] > 1 Then $nIcon = $arSplit[2] Else Return 0 EndIf EndIf Return 1 EndFunc Func GUICtrlListViewSetColumnFormat($hListView, $nCol, $nFormat) $hListViewHeader = GUICtrlSendMsg($hListView, $LVM_GETHEADER, 0, 0) Local $LVCOLUMN = DllStructCreate("uint;int;int;ptr;int;int;int;int") DllStructSetData($LVCOLUMN, 1, $LVCF_FMT) DllStructSetData($LVCOLUMN, 2, $nFormat) GUICtrlSendMsg($hListView, $LVM_SETCOLUMN, $nCol, DllStructGetPtr($LVCOLUMN)) EndFunc Func LVSort($hWnd, $nItem1, $nItem2, $nColumn) Local $nSort GUICtrlSetCursor($nDirList, 1) If $nColumn = $nCurCol Then If Not $bSet Then $nSortDir = $nSortDir * -1 $bSet = 1 EndIf Else $nSortDir = 1 EndIf $nCol = $nColumn $val1 = GetSubItemText($nDirList, $nItem1, $nColumn) $val2 = GetSubItemText($nDirList, $nItem2, $nColumn) If $nColumn = 1 Then $val1 = Number(StringTrimRight($val1, 3)) $val2 = Number(StringTrimRight($val2, 3)) ElseIf $nColumn = 3 Then $val1 = StringRight(StringTrimRight($val1, 6), 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2) $val2 = StringRight(StringTrimRight($val2, 6), 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2) EndIf $nResult = 0 If $val1 < $val2 Then $nResult = -1 ElseIf $val1 > $val2 Then $nResult = 1 EndIf $nResult = $nResult * $nSortDir GUICtrlSetCursor($nDirList, 2) Return $nResult EndFunc Func GetSubItemText($nCtrlID, $nItemID, $nColumn) Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int") DllStructSetData($stLvfi, 1, $LVFI_PARAM) DllStructSetData($stLvfi, 3, $nItemID) Local $stBuffer = DllStructCreate("char[260]") $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi)); Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int") DllStructSetData($stLvi, 1, $LVIF_TEXT) DllStructSetData($stLvi, 2, $nIndex) DllStructSetData($stLvi, 3, $nColumn) DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer)) DllStructSetData($stLvi, 7, 260) GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi)); Return DllStructGetData($stBuffer, 1) EndFunc Func GetComboString($hComboBox, $sDelimiter = "|") Local $sDelim = $sDelimiter, $sResult, $nItem, $Struct For $i = 0 To GUICtrlSendMsg($hComboBox, $LB_GETCOUNT, 0, 0) - 1 $Struct = DllStructCreate("char[" & GUICtrlSendMsg($hComboBox, $LB_GETTEXTLEN, $i, 0) + 1 & "]") DllCall("user32.dll", "int", "SendMessageA", "hwnd", GUICtrlGetHandle($hComboBox), _ "int", $LB_GETTEXT, "int", $i, "ptr", DllStructGetPtr($Struct)) $nItem = DllStructGetData($Struct, 1) If $nItem <> "" Then $sResult &= $nItem & $sDelimiter Next Return StringRegExpReplace($sResult, "\A\" & $sDelim & "+|\" & $sDelim & "+$|(\" & $sDelim & ")+", "\1") EndFunc Func _MsgBox($MsgBoxType, $MsgBoxTitle, $MsgBoxText, $hWnd=0) Local $iRet = DllCall ("user32.dll", "int", "MessageBox", _ "hwnd", $hWnd, _ "str", $MsgBoxText , _ "str", $MsgBoxTitle, _ "int", $MsgBoxType) Return $iRet[0] EndFunc Func QuitApp() If Not HotKeysHandler($hGUI, "QuitApp") Then Return $FoldersToScan = GetComboString($nCurPath, "|") $FoldersToScan = StringRegExpReplace($FoldersToScan, "\A\|+|\|+$|(\|)+", "\1") IniWrite($ConfigFile, "Main Prefs", "Folders To Scan", $FoldersToScan) IniWrite($ConfigFile, "Main Prefs", "Current Folder To Scan", GUICtrlRead($nCurPath)) Exit EndFunc 8)1 point -
VLC Media Player
Earthshine reacted to FireFox for a topic
@ptrex briliant !! Good job and useful COM udf Cheers, FireFox.1 point