Je cherche à limiter le déplacement de fichiers "accidentels" dans les fenêtres FileSelectFolder() & FileSaveDialog().
Ne trouvant aucun paramètre propre à ces fonctions je me suis tourné vers la base de registre pour modifier les clés suivantes :
- HKEY_CURRENT_USER\Control Panel\Desktop\DragHeight
- HKEY_CURRENT_USER\Control Panel\Desktop\DragWidth
J'aimerai modifier ces clés à l'ouverture et à la fermeture des fenêtres FileSelectFolder() & FileSaveDialog().
J'arrive à modifier les clés mais, hormis en redémarrant l'ordinateur, je ne trouve pas de solution pour rafraichir instantanément les paramètres utilisateurs.
Code : Tout sélectionner
#RequireAdmin
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIsysinfoConstants.au3>
#include <WindowsConstants.au3>
global $dragHeight, $dragWidth
readDrag("Valeurs initiales")
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "DragHeight", "REG_SZ", switchDrag($dragHeight))
_WinAPI_SystemParametersInfo($SPI_SETDRAGHEIGHT, 0)
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "DragWidth", "REG_SZ", switchDrag($dragWidth))
_WinAPI_SystemParametersInfo($SPI_SETDRAGWIDTH, 0)
;force user update
$func="UpdatePerUserSystemParameters"
RunWait("rundll32 USER32.DLL," & $func)
sleep(500)
readDrag("Nouvelles valeurs")
Func readDrag($title)
$dragHeight = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "DragHeight")
$dragWidth = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "DragWidth")
MsgBox($MB_SYSTEMMODAL, $title, "Height : " & $dragHeight & @LF & "Width : " & $dragWidth)
EndFunc
Func switchDrag($string)
If $string == 4 Then Return 50
Return 4
EndFunc