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

    • 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?
    • GHOSTYAIRO
      Send file path not working when there's a "#" in the var
      By GHOSTYAIRO
      I have a script that changes the path to a file inside a program, the program itself is a pain in the @## I have no idea what language was coded with but the autoit windows info doesn't even recognize 90% of the gui.
      Anyway I need to send the new path which is inside the local app folder, I'am using a variable to hold it. but the User folder has the "#" character in the name and for some reason autoit won't send it, it just stops right before the "#" and doesn't send the rest of the path either. it doesn't return any error it just stops sending, the rest of the script is still executed.
      I'm using the Send() command to send the keys.
      Here's what I have:
      $dbPath = @UserProfileDir & '\AppData\Local\database\db.mdb' Run("Notepad.exe") WinWait("Untitled - Notepad") WinActivate("Untitled - Notepad") Send($dbPath) Now in my case @UserProfileDir is called Tech #1 so what I'm expecting Send() to type is 
      C:\Users\Tech #1\AppData\Local\database\db.mdb But what I'm actually getting is just
      C:\Users\Tech notice there's the space after the "h", so it is stopping exactly before the "#"
      Now you might say why I need to use a var instead of just sending the actual string path, well I don't want to do a separate script for all the computers and guess what, they all have the "#" in their user names, yes Tech #2, Tech #3, Tech #4, Front #1, Front #2, Shipping #1... and so on.
      BTW on a side note, I noticed the autoit macros page shows the  @LocalAppDataDir  as a viable macro but it's not working for me, it return "unknown macro", I had to use @UserProfileDir and and the \AppData\Local, because the @AppDataDir takes me to Roaming anyway. 
      While I was writing that last paragraph, I said to my self, yeah why not just copy and paste the script and compile as many as I need but use plain text instead of a variable, so I went back and did just
      Run("Notepad.exe") WinWait("Untitled - Notepad") WinActivate("Untitled - Notepad") Send("C:\Users\Tech #1\AppData\Local\database\db.mdb") Guess what!!!, yeah you guessed it, it did the same thing, it stopped right before the "#".
      I know most will be thinking, nah he's crazy why would that happen, go ahead and try for yourself, I'll wait... (because I tried in 3 different computers).
      Ok so you are back, did it work for you? can you explain why it's not working for me, or it didn't work for you as well and you are as clueless as me?
      And while I was writing all this my brain was working on the background and I just had an idea to work around it, I'll be right back...
      $dbPath = @UserProfileDir & '\AppData\Local\DiGital WorkShop\POS Panic\PM229.mdb' Run("Notepad.exe") WinWait("Untitled - Notepad") WinActivate("Untitled - Notepad") ClipPut($dbPath) Send("{CTRLDOWN}v{CTRLUP}") Ok so this actually works for me and I can finally breath, but I'm still annoyed by the fact that autoit won't Send("#1") or Send("#2"), yes I actually tried just sending that and nothing, and I just realize what is doing, (this lecture will annoy most people lol), by sending #1, #2, #3 ans so on it is activating windows in the same order they are pinned in the taskbar, I had autoit first, then chrome, the my mail app, so every time I use Send("#1") activates autoit, which I didn't noticed at all because well I was using autoit, but then when I Send("#2") and it brought chrome to the front, then Send("#3") and activated my mail app (which btw was minimized).
      What in the world is happening some please explain me this behavior and please tell me how would you workaround the issue.
      Thanks.
       
    • twixt
      Send command
      By twixt
      I am having trouble getting the send command with one of the defined macros.  I need to send to the active window a function with parameters.
      Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("RUN(""@IPAddress1"", port_number, ""conf_option"")") What I am looking for is something like this to be sent to the active window
      RUN("192.168.1.1", 52535, "filename.conf")
      getting the @IPAddress in quotes seems to screw up the send command syntax.  Any help?