Sign in to follow this  
Followers 0
johnmcloud

[SOLVED] FileSetAttrib - Variable & Macro

5 posts in this topic

#1 ·  Posted (edited)

Hi guys, i have a question.

Why this work:

FileSetAttrib("C:\Documents and Settings\Windows Xp\Desktop\Test", "+SH",1)

And this not?

$Folder="test"
FileSetAttrib('"' & @WorkingDir & "\" & $Folder & '"', "+SH",1)

Is a limitation or my error?

Thanks for support

Edited by johnmcloud

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The only reason that wouldn't work is if @WorkingDir isn't the directory you think it is.

Uh? Is the same directory, i have create a "Test" folder. Take a look:

$NewFolder="Test"
MsgBox(0,0,'"' & @WorkingDir & "" & $NewFolder & '"')

The result is the same dir of the script with full path, so is the same.

Edited by johnmcloud

Share this post


Link to post
Share on other sites

johnmcloud,

You have superfluous quotes in your "file pattern" parameter - try this:

FileSetAttrib(@WorkingDir & "" & $Folder, "+SH",1)

You do not need quotes around variables, only strings. You need additonal quotes around path strings when you pass them to the DOS console using Run(@ComSpec & " /c "....) and they contain spaces - but not with the AutoIt native commands. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

johnmcloud,

You have superfluous quotes in your "file pattern" parameter - try this:

FileSetAttrib(@WorkingDir & "" & $Folder, "+SH",1)

You do not need quotes around variables, only strings. You need additonal quotes around path strings when you pass them to the DOS console using Run(@ComSpec & " /c "....) and they contain spaces - but not with the AutoIt native commands. :)

M23

You have right, i have made the " " becouse i have try without it and not work. The problem was in my script i need to add a Sleep(500) between DirCreate and FileSetAttrib, withuot it i don't know why don't work on my system, maybe becouse the folder has a long name.

Thanks all

Share this post


Link to post
Share on other sites

johnmcloud,

in my script i need to add a Sleep(500) between DirCreate and FileSetAttrib

You have to give the system time to recognize the new folder. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • ur
      AutoItSetOption for arrays
      By ur
      If we give the below line in our script, we can expand the variables in double quotes to its values.
      AutoItSetOption ("ExpandVarStrings", 1) Like, 
      Local $b=4 MsgBox(0,"$b$","See subject") But coming to variables, they are not getting expanded.
      Local $a[3]=[1,2,3] Local $b=4 _ArrayDisplay($a) MsgBox(0,"$a$$b$","See subject") Could anyone please help me on this.
    • LegitStack
      Run variable as script
      By LegitStack
      Is there a way to execute the text inside a variable is if it was part of the script?
      In this example I'd like to get a message box pop up but I don't: 
      ;testme.au3   local $var = 'msgbox(64,"hello","world")'   $var is there a command that can be used like maybe 'Exec' or 'Execute' or something?
        local $var = 'msgbox(64,"hello","world")'   Execute $var  
    • Reizvoller
      Subscript Used on Non-Accessible Variable WinGetPos error
      By Reizvoller
      Func workSpaceSetup () ConsoleWrite ("workSpaceSetup" &@CRLF) $workSpace = WinGetHandle ("some site - Google Chrome") ConsoleWrite ($workSpace&@CRLF) $pos1 = WinGetPos ($workSpace) WinMove ($workSpace , "", $pos1[0] , $pos1[1] , 1366, 768, 0) EndFunc So the script is first, the error I get is second in the quote.
      This is one function of many for an app I am building but it is the first one that runs so I know there aren't other things at play here.
      The idea is to keep the window in the same space it is when the script runs but just resize it as this app is used across multiple computers with different screen resolutions.
      Could someone please elaborate upon what "Subscript used on non-accessible variable" means? 
      Oh and the variable is declared as "Global $pos1 = 0" at the top outside of any functions with the other global variables.
      Any advice would be greatly appreciated!
      -Reiz
    • RamPalav
      Send text to VBA form
      By RamPalav
      Hi,
      I want to send text into a VBA form's text field. Can someone please guide me on the autoit script that can help me.
      Below is the sample code that I need help on:
      #include <Excel.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> @ScriptDir ="D:\\AutoIT\" $sFilePath = @ScriptDir & "\ExcelForm.xlsm" Local $oAppl = _Excel_Open() ;Local $oAppl = _Excel_Open(False, Default, Default, Default, True) Local $sWorkbook = $sFilePath Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ConsoleWrite('before opening macro.........1') $oAppl.Run('mymacro') Sleep(3000) ConsoleWrite('After opening macro.........1') Send('First text') ConsoleWrite('After opening macro.........2') Send('{TAB}') ConsoleWrite('After opening macro.........3') Send('Second text') ConsoleWrite('After opening macro.........4') Send('{TAB}') Send('{Enter}') ConsoleWrite('After opening macro.........5') thanks,
       
    • way1000
      array variable error
      By way1000
      i have a script that works but gives results and errors randomly

      #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <File.au3> #include <Date.au3> Global $result1s[5]=["a", "b", "c", "d", "e"] Global $result2s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"] Global $result3s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"] Global $result4s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"] Global $result5s[19]=["text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8", "text9", "text10", "text11", "text12", "text13", "text14", "text15", "text16", "text17", "text18", "text19"] _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1, $results2, $results3, $results4, $results5 Local $file = FileOpen("test.txt", 1) GUICreate("test", 600, 200, -1, -1) $button1 = GUICtrlCreateButton("Result", 460, 110, 50, 30) $output1 = GUICtrlCreateInput("", 60, 10, 450, 20, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlCreateLabel("1", 5, 12) $output2 = GUICtrlCreateInput("", 60, 30, 450, 20, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlCreateLabel("2", 5, 12) $output3 = GUICtrlCreateInput("", 60, 50, 450, 20, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlCreateLabel("3", 5, 32) $output4 = GUICtrlCreateInput("", 60, 70, 450, 20, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlCreateLabel("4", 5, 52) $output5 = GUICtrlCreateInput("", 60, 90, 450, 20, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlCreateLabel("5", 5, 72) GUICtrlCreatePic("", 0, 0, 600, 200) GUICtrlCreateLabel("Sample Pic", 75, 1, 53, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $die = GUICtrlCreateLabel("", 700, 500, 700, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Verdana") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 5, 1) GUICtrlSetData($output1, $result1s[$results1]) $read1 = GUICtrlRead($output1) $results2 = Random(1, 19, 1) GUICtrlSetData($output2, $result2s[$results2]) $read2 = GUICtrlRead($output2) $results3 = Random(1, 19, 1) GUICtrlSetData($output3, $result3s[$results3]) $read3 = GUIctrlRead($output3) $results4 = Random(1, 19, 1) GUICtrlSetData($output4, $result4s[$results4]) $read4 = GUICtrlRead($output4) $results5 = Random(1, 19, 1) GUICtrlSetData($output5, $result5s[$results5]) $read5 = GUICtrlRead($output5) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read1) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read2) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read3) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read4) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read5) FileClose($file) EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main  
       
      how to fix it?