Jump to content

User71

Members
  • Posts

    5
  • Joined

  • Last visited

User71's Achievements

  1. Thank you both for your answers, I didn't even think of adding a @‌CRLF before the text! Unless anyone else can tell me (us) where we're going wrong I guess it's just one of those things I'll have to work around. Anyone else?
  2. Thanks Reb, tried your code and it centres it but no multi-line, and if I put multi-line on the end it centres it at the top instead and it ignores the @CRLF in the text. Did I do something wrong?
  3. Hi All, I'm sure this is a simple one to answer and I have searched and experimented before I asked (well enough hopefully!) I'm trying to set a button background to be white, the font colour red, centred vertically and horizontally and multi-line. Can it be done? Here is my example code: #include <Constants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ColorConstantS.au3> #include <FontConstants.au3> #include "ColorConstants.au3" Opt("GUIOnEventMode", 1) $GUI = GUICreate("GUI", 250, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Button = GUICtrlCreateButton("Button" & @CRLF & "One", 160, 185, 85, 110, BitOR($BS_MULTILINE, $BS_CENTER, $BS_VCENTER, $WS_EX_WINDOWEDGE)) GUICtrlSetBkColor(-1, $COLOR_White) GUICtrlSetFont($Button, 14, 800, 0, "MV Boli", 5) GUICtrlSetColor($Button, 0xFF0000) GUICtrlSetOnEvent($Button, "_Exit") GUISetState() While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_ExitWith everything I have tried, this is the closest I get, button white, font red, correct font, but no centring and sometimes no multi-line (depending on button text and font size). I saw I might have to add the default button forced style back in so I did that too $WS_EX_WindowEdge. Thanks for any help and apologies if I've missed an obvious answer to this elsewhere.
  4. Thank you both for your replies, I will investigate further when I'm not being forced to Xmas shop! Thanks Saint for reminding me of the quotes, I will go through and change them when I can. And thanks Spider, never seen that function it looks interesting, I guess it would mainly change the DirRemove part of my code to look at the array with a nth variable to count the array entries? So DirRemove($Array [$nthEntry], 1) I forgot to add my dir line I'm running (which does work), just because I prepopulated the text files first this time as I was troubleshooting. I run this first normally but as said, I was trying to simplify to find the problem so I just made the C:List1.txt and put in X:21New Folder which becomes "X:21New Folder" in C:List2.txt. Local $DIRCMDPath = "X:\2\1" & " > " Local $HiddenDirPath = @MyDocumentsDir & "\SBackup\Logs\HiddenDir.txt" Local $DIRCMD = "dir /S /B /A:HD " & $DIRCMDPath & $HiddenDirPath Local $DetectHidden = Run(@ComSpec & " /c " & $DIRCMD, @WindowsDir, @SW_HIDE) Thanks EDIT I have successfully used Spider001 suggestion of an array in the following script, but it does give an error as seen below: #include <MsgBoxConstants.au3> #include <file.au3> #include <Array.au3> Array() Func Array() Global $Array = _FileListToArrayRec("X:\2\1", "*", $FLTAR_FOLDERS, 0, 0, $FLTAR_FULLPATH) If @error Then Exit _ArrayDisplay($Array, "Display all first level folders with full path") EndFunc ;==>Array Local $nth = 1 While 1 $FileAttr = FileGetAttrib($Array[$nth]) If StringInStr($FileAttr, "H") Or StringInStr($FileAttr, "S") Then DirRemove($Array[$nth], 1) EndIf $nth = $nth + 1 If $FileAttr = "" Then ExitLoop WEnd "X:\Software\AutoIT\Tutorial Tests\TestSpacev2.au3" (16) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $FileAttr = FileGetAttrib($Array[$nth]) $FileAttr = FileGetAttrib(^ ERROR The script does work, but it wants to go on to FileGetAttrib from a non existent part of the array which I think is the cause of the error, e.g. trying to access $array[4] when only $array[0] to [3] exists. Any suggestions to solve the error? If so I think it might be case closed EDIT Think I managed to sort it; feel free to suggest a neater way though: Global $input2_data = Somepath $DirGetSizeArray = DirGetSize($Input2_Data, 3) Local $ArrayFolders = _FileListToArrayRec($Input2_Data, "*", $FLTAR_FOLDERS, 0, 0, $FLTAR_FULLPATH) _ArrayDisplay($ArrayFolders, "Display no hidden or system folders") If IsArray($ArrayFolders) Then Global $ArraySize = UBound($ArrayFolders) - 1 EndIf Local $nth = 1 While 1 If $DirGetSizeArray[2] = 0 Then ExitLoop $FileAttr = FileGetAttrib($ArrayFolders[$nth]) If StringInStr($FileAttr, "H") Or StringInStr($FileAttr, "S") Then DirRemove($ArrayFolders[$nth], 1) EndIf If $nth = $ArraySize Then ExitLoop $nth = $nth + 1 WEnd Local $ArrayFiles = _FileListToArrayRec($Input2_Data, "*", $FLTAR_FILES, 0, 0, $FLTAR_FULLPATH) _ArrayDisplay($ArrayFiles, "Display no hidden or system files") If IsArray($ArrayFiles) Then Global $ArraySize = UBound($ArrayFiles) - 1 EndIf Local $nth = 1 While 1 If $DirGetSizeArray[1] = 0 Then ExitLoop $FileAttr = FileGetAttrib($ArrayFiles[$nth]) If StringInStr($FileAttr, "H") Or StringInStr($FileAttr, "S") Then FileSetAttrib($ArrayFiles[$nth], "-SHRA") FileDelete($ArrayFiles[$nth]) EndIf If $nth = $ArraySize Then ExitLoop $nth = $nth + 1 WEnd
  5. Hi, I'm a newbie to both forum and AutoIT, please excuse me if this is a question with an obvious answer. I use the forums a lot so thanks for all the past help you guys have given me. I'm trying to write a simple script to find hidden folders in a location I specify in a variable, and then delete those folders using DirRemove or similar. So far I'm running a cmd with dir to make a List.txt containing paths to hidden folders and trying to read the list.txt line by line and delete the folders. I've had varying success but never 100% reliable so I thought I must be doing it wrong. Here's the current code I'm messing with: (Excuse the includes, can't remember whcih ones I need for this script ) #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <file.au3> Local $Path1 = "C:\List1.txt" Local $Path2 = "C:\List2.txt" Local $FileOpen1 = FileOpen($Path1, 0) Local $FileOpen2 = FileOpen($Path2, 2) While 1 $FileReadLine1 = FileReadLine($FileOpen1) ;MsgBox(0, "", $FileReadLine) ;MsgBox(0, "", $FileOpen2) $FileWriteLine = FileWriteLine($FileOpen2, """" & $FileReadLine1 & """") If $FileReadLine1 = "" Then ExitLoop WEnd While 1 $FileReadLine2 = FileReadLine($Path2) ;MsgBox(0, "", $FileReadLine2) ;$DirRemove = DirRemove($FileReadLine2, 1) ;MsgBox(0, "", $DirRemove) ;Local $RD = Run(@ComSpec & " /c " & "RD /S /Q " & $FileReadLine2, @WindowsDir, @SW_HIDE) If $FileReadLine2 = "" Then ExitLoop WEnd FileClose($FileOpen1) FileClose($FileOpen2) ;$DirRemove = DirRemove("X:\2\1\New Folder", 1) This is my current "lets see what works and what doesn't" kinda mess script. As you can see the first bit takes the paths given by dir and puts "" around them to be sure I can't be suckered that way. That bit works, the deleting bit does not unless I use the bottom line with manually written path. Please let me know where I'm going wrong, at least just on the deleting bit if not my scripting generally , the script was shorter but grew as I experimented trying to make it work! Thanks in advance
×
×
  • Create New...