Leaderboard
Popular Content
Showing content with the highest reputation on 08/19/2023 in all areas
-
Saves the position of the icons, from the desktop, with the ability of restoring With command line parameters -save , it save the icons setting, with -restore , it restore the icons setting. Without command line parameters display a GUI with save , restore buttons DesktopIconSet.au3 ; https://www.autoitscript.com/forum/topic/210688-desktop-icons-save-and-restore/ ;---------------------------------------------------------------------------------------- ; Title...........: DesktopIconSet.au3 ; Description.....: Saves the position of the icons, from the desktop, with the ability of restoring ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Notes ..........: Tested on Windows 10 Version 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $g_sIniPath = @ScriptDir & "\Setting.ini" Global $g_hDesktop = _WinGetDesktopHandle() Global $g_hDeskCtrlListView = ControlGetHandle($g_hDesktop, "", "[CLASS:SysListView32;INSTANCE:1]") ConsoleWrite("$g_sIniPath=" & $g_sIniPath & @CRLF) ConsoleWrite("$g_hDesktop=" & $g_hDesktop & @CRLF) ConsoleWrite("$g_hDeskCtrlListView=" & $g_hDeskCtrlListView & @CRLF) Global $iParams = $CmdLine[0] ;Check if $CmdLine parameters If Not $iParams Then _CallGUI() Else $iParams = $CmdLine EndIf Switch $iParams[1] Case "-save" _SaveSetting() Case "-restore" _RestoreSetting() EndSwitch Exit ;_SetShortcutPos("Recycle Bin", 0, 0) ;---------------------------------------------------------------------------------------- Func _CallGUI() GUICreate(" DeskTop shortcuts", 170, 90, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Local $ButtonSave = GUICtrlCreateButton("Save Setting", 10, 10, 150, 30) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Local $ButtonRestore = GUICtrlCreateButton("Restore Setting", 10, 50, 150, 30) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $ButtonSave _SaveSetting() ExitLoop Case $ButtonRestore _RestoreSetting() ExitLoop EndSwitch WEnd Exit EndFunc ;==>_CallGUI ;---------------------------------------------------------------------------------------- Func _SetShortcutPos($Name = "", $X = 0, $Y = 0) Local $iIndex = _GUICtrlListView_FindInText($g_hDeskCtrlListView, $Name) If $iIndex == -1 Then Return SetError(1, 0, "! Could not find icon: " & $Name) EndIf _GUICtrlListView_SetItemPosition($g_hDeskCtrlListView, $iIndex, $X, $Y) Return "- " & $Name & "=" & $X & "," & $Y EndFunc ;==>_SetShortcutPos ;---------------------------------------------------------------------------------------- Func _SaveSetting() Local $iItemCount, $sTxt, $aPos $iItemCount = _GUICtrlListView_GetItemCount($g_hDeskCtrlListView) ConsoleWrite("> Save Setting:" & @CRLF) ConsoleWrite("- Item Count:" & $iItemCount & @CRLF) $sTxt = "[Setting]" & @CRLF For $i = 0 To $iItemCount - 1 $sTxt &= _GUICtrlListView_GetItemText($g_hDeskCtrlListView, $i) $aPos = _GUICtrlListView_GetItemPosition($g_hDeskCtrlListView, $i) $sTxt &= "=" & $aPos[0] & "," & $aPos[1] & @CRLF Next ConsoleWrite($sTxt & @CRLF) Local $hFileOpen = FileOpen($g_sIniPath, $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8_NOBOM) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the txt file.") Return False EndIf FileWrite($hFileOpen, $sTxt) EndFunc ;==>_SaveSetting ;---------------------------------------------------------------------------------------- Func _RestoreSetting() ConsoleWrite("> Restore Setting:" & @CRLF) Local $aPos ; Read the INI section labelled 'Setting'. This will return a 2 dimensional array. Local $aArray = IniReadSection($g_sIniPath, "Setting") If Not @error Then ; Enumerate through the array displaying the keys and their respective values. For $i = 1 To $aArray[0][0] $aPos = StringSplit($aArray[$i][1], ",") If $aPos[0] = 2 Then ConsoleWrite(_SetShortcutPos($aArray[$i][0], $aPos[1], $aPos[2]) & @CRLF) EndIf Next EndIf EndFunc ;==>_RestoreSetting ;---------------------------------------------------------------------------------------- ; https://www.autoitscript.com/forum/topic/119783-desktop-class-workerw/#comment-903081 ; <_WinGetDesktopHandle.au3> ; Function to get the Windows' Desktop Handle. ; Since this is no longer a simple '[CLASS:Progman]' on Aero-enabled desktops, this method uses a slightly ; more involved method to find the correct Desktop Handle. ; ; Author: Ascend4nt, credits to Valik for pointing out the Parent->Child relationship: Desktop->'SHELLDLL_DefView' ;---------------------------------------------------------------------------------------- Func _WinGetDesktopHandle() Local $i, $hDeskWin, $hSHELLDLL_DefView, $h_Listview_Configs, $aWinList ; The traditional Windows Classname for the Desktop, not always so on newer O/S's $hDeskWin = WinGetHandle("[CLASS:Progman]") ; Parent->Child relationship: Desktop->SHELLDLL_DefView $hSHELLDLL_DefView = ControlGetHandle($hDeskWin, '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') ; No luck with finding the Desktop and/or child? If $hDeskWin = '' Or $hSHELLDLL_DefView = '' Then ; Look through a list of WorkerW windows - one will be the Desktop on Windows 7+ O/S's $aWinList = WinList("[CLASS:WorkerW]") For $i = 1 To $aWinList[0][0] $hSHELLDLL_DefView = ControlGetHandle($aWinList[$i][1], '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') If $hSHELLDLL_DefView <> '' Then $hDeskWin = $aWinList[$i][1] ExitLoop EndIf Next EndIf ; Parent->Child relationship: Desktop->SHELDLL_DefView->SysListView32 $h_Listview_Configs = ControlGetHandle($hSHELLDLL_DefView, '', '[CLASS:SysListView32; INSTANCE:1]') If $h_Listview_Configs = '' Then Return SetError(-1, 0, '') Return SetExtended($h_Listview_Configs, $hDeskWin) EndFunc ;==>_WinGetDesktopHandle ;---------------------------------------------------------------------------------------- Please, leave your comments and experiences here. thank you very much !1 point
-
special permissions ShellExecute(@WindowsDir & "\explorer.exe", "C:\Users\Public\Desktop\Oracle VM VirtualBox.lnk")1 point
-
How to search only the second StringRegExp Or Second Random String?
HezzelQuartz reacted to mikell for a topic
Looks like you didn't clearly undrestand how my code works Using an array you can't do this in one go. You must separate the categories, then change the number in each of them, then replace in the main text this category by the "new category" with the new number Here it is, with explicit variable names and comments, and using a correct replacement character $text = FileRead(@ScriptDir & "\" & "database.txt") ;$text = StringReplace($text, "'", ChrW(0xFFFD) ) ; get the categories $categories = StringRegExp($text, 'category":\h+"[^"]+"\s+},\s+\d+', 3) ; visualize categories _ArrayDisplay($categories, "categories") ; get the numbers $numbers = StringRegExp($text, 'category":\h+"[^"]+"\s+},\s+(\d+)', 3) _ArrayDisplay($numbers, "numbers") ; loop through categories For $i = 0 to UBound($categories)-1 ; for each category, make the new number $new_n = $numbers[$i] +50 ; replace number by new number ;$new_cat = Execute("'" & StringRegExpReplace($categories[$i], "(\d+)$", "' & $new_n & '") & "'") $new_cat = StringRegExpReplace($categories[$i], '(\d+)$', $new_n) ; replace the category by the one modified $text = StringReplace($text, $categories[$i], $new_cat) Next ;$text = StringReplace($text, ChrW(0xFFFD), "'") Msgbox(0, "new text", $text) Edit I did no error checking, up to you how to do them And in the loop a simple SRER is enough as there is no operation in the 'replace' part1 point -
Nah ... RPG & Punch cards were related as it used the 80 columns card format for the syntax. ...and I punched punch-cards too for a IBM RJE system.1 point
-
How to add a UDF to Auto It?
pseakins reacted to argumentum for a topic
..therefore I, put'em in the same includes folder. That way I don't have to remember a thing. (anyone here plz don't follow my doing, I know that I'm disorganized)1 point -
Looks simple/clear/good. Few tips: 1) instead of Setting.ini use @ScriptName with .ini extension (here DesktopIconSet.ini) ;Global $g_sIniPath = @ScriptDir & "\Setting.ini" Global $g_sIniPath Global $ext = StringRight(@ScriptName, 4) ; .exe / .au3 Global $ini = StringReplace(@ScriptName,$ext,'.ini',1,1) $g_sIniPath = @ScriptDir & "\" & $ini 2) instead of ConsoleWrite use helper function Debug() ;ConsoleWrite("$g_sIniPath=" & $g_sIniPath & @CRLF) ;ConsoleWrite("$g_hDesktop=" & $g_hDesktop & @CRLF) ;ConsoleWrite("$g_hDeskCtrlListView=" & $g_hDeskCtrlListView & @CRLF) Debug("$g_sIniPath=" & $g_sIniPath) Debug("$g_hDesktop=" & $g_hDesktop) Debug("$g_hDeskCtrlListView=" & $g_hDeskCtrlListView) Func Debug($text) If Not @Compiled Then ConsoleWrite($text & @CRLF) EndFunc 3) probably there may be position conflicts when you may try to set position of icon to other with the same position ... so maybe some simple test for that scenario and try to automatically change conflicting position to right or down ...1 point
-
IconDock - Mac style Icon toolbar
twothirtyone reacted to TouchOdeath for a topic
https://autoit.de/index.php/Attachment/79469-IconDock-zip/ With current version of autoit you'll need to rename $ghGDIPDLL to $__g_hGDIPDll in IconDock.au31 point