
Notechyuser
Members-
Posts
14 -
Joined
-
Last visited
Everything posted by Notechyuser
-
Not been able to look at this for a while, but I have tried reading up on the whole debug topic in Autoit and so much of it makes no sense to me at all, that I don't even know where to start. It seems that it's people who don't understand programming too well who could do with the debug info to see what's going on, yet to use it you need to be a competent programmer/experienced user in AutoIt.... So, to recap - the code below works fine on a local laptop using local networked folder locations, but in situ (at work) it displays the first networked folder and then AutoIt 'pauses' and it fails to open any other folders. if I specify non-networked drives in my text file then the folders all open fine using the very same compiled exe program on the very same work computer. Really frustrating!! #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; OU DIP folders v2 22/06/2022 #include <Debug.au3> #include <File.au3> Local $aFolder _FileReadToArray ("C:.\folders1.txt", $aFolder, Default, "|") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "File read failed on error " & @error) For $i = 1 to $aFolder[0][0] If WinExists("[TITLE:" & $aFolder[$i][0] & "; CLASS:CabinetWClass;]") Then ; WinActivate($aFolder[$i][0]) ; WinMove("[CLASS:CabinetWClass]", "",$aFolder[$i][1],$aFolder[$i][2],$aFolder[$i][3],$aFolder[$i][4]) Else Run("explorer.exe " & $aFolder[$i][0]) WinWait("[CLASS:CabinetWClass]", "", $aFolder[$i][5]) WinMove("[CLASS:CabinetWClass]", "", $aFolder[$i][1],$aFolder[$i][2],$aFolder[$i][3],$aFolder[$i][4]) WinWaitActive($aFolder[$i][0]) Send("^!" & $aFolder[$i][6]) EndIf Next Oh, the text file that defines the windows also only works if I add a \ to the end of the path of the networked drive within that file, so folders1.txt contains multiple entries similar to this: \\network-folder1\test forms\|1684|8|228|300|2|5 So, I am none the wiser as to why it isn't working beyond the first folder it opens up.
-
I have only just been able to test my AutoIt solution on the actual computer it needs to be run on, and only the first folder is opened when the compiled executable is run. On my laptop, the example folders I set up worked fine. I have checked the folder definitions in the text file I use, and they are all correct. I suspect this problem is because I might need to set the codepage to be 1252 for the folder definitions text file, because when I originally just had the folders opening using a simple .bat file that ran explorer for each folder, some of the folders didn't open due to the use of em dashes in the folder names. A combination of the codepage settings and ANSI encoding on the .bat file got that half-solution working. Unfortunately, I have no control over the folder names on the network drive, and so am unable to rename them and I suspect that is the problem I need to fix. If it isn't codepage that is causing the problem, then I'm not sure where else to look.
-
Ah, I had fiddled with that earlier (putting it in the string quotations) and forgot to put it back to how it was, but I didn't have the correct syntax so it wasn't working anyway. #include <File.au3> Local $aFolder _FileReadToArray ("C:.\folders1.txt", $aFolder, Default, "|") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "File read failed on error " & @error) For $i = 1 to $aFolder[0][0] If WinExists("[TITLE:" & $aFolder[$i][0] & "; CLASS:CabinetWClass;]") Then WinActivate($aFolder[$i][0]) WinMove("[CLASS:CabinetWClass]", "",$aFolder[$i][1],$aFolder[$i][2],$aFolder[$i][3],$aFolder[$i][4]) Else Run("explorer.exe " & $aFolder[$i][0]) WinWait("[CLASS:CabinetWClass]", "", $aFolder[$i][5]) WinMove("[CLASS:CabinetWClass]", "", $aFolder[$i][1],$aFolder[$i][2],$aFolder[$i][3],$aFolder[$i][4]) WinWaitActive($aFolder[$i][0]) Send("^!" & $aFolder[$i][6]) EndIf Next For some reason the enforced 'List view' on each window (sending a ctrl+shift+5 to the folder window) isn't working, but this otherwise seems to be doing the job now! 🙂 Example data (folders1.txt) C:\temp|1684|8|228|300|3|5 C:\temp\Linux|1454|8|228|300|3|5 C:\temp\retro|1224|8|228|300|3|5 C:\temp\desktop stuff|996|8|228|300|3|5
-
#include <File.au3> Local $aFolder _FileReadToArray ("C:.\folders1.txt", $aFolder, Default, "|") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "File read failed on error " & @error) For $i = 1 to $aFolder[0][0] If WinExists("[TITLE:$aFolder[$i][0]; CLASS:CabinetWClass;]") Then WinActivate($aFolder[$i][0]) WinMove("[CLASS:CabinetWClass]", "",$aFolder[$i][1],$aFolder[$i][2],$aFolder[$i][3],$aFolder[$i][4]) Else Run("explorer.exe $aFolder[$i][0]") WinWait("[CLASS:CabinetWClass]", "", $aFolder[$i][5]) WinMove("[CLASS:CabinetWClass]", "", $aFolder[$i][1],$aFolder[$i][2],$aFolder[$i][3],$aFolder[$i][4]) WinWaitActive($aFolder[$i][0]) Send("^!$aFolder[$i][6]") EndIf Next It defines the first window correctly in terms of size and position, but not in regard to the correct folder. It opens up 'Documents' instead. It then stops, so none of the other defined windows in the folders1.txt file are opened. I assume I'm not inserting the variables from the array correctly?
-
I am still struggling to fathom parts of the above? I understand the #include, and the declaration of the local variable $aFolder. I understand what the _FileReadToArray function is doing, by specifying the exact location of the file (a .txt file that contains the data I have defined for the folders), getting it to detect how many lines of data there are, and then useing the | as a delimiter, it reads my data into a 2D array, which I think is stored starting at $aFolder[0][0], up to $aFolder[21][6], if I have 21 lines of data, with 7 sets of data in each line (for example). However, what I don't understand from the above is why ConsoleWrite is needed, and how that helps me? Does my previously written code go before or after all those ConsoleWrite statements, and how do I get at the data that is (presumably) now stored in the array and use it in my existing code? Sadly 'do your things here' is not helping me understand this... Is anyone willing to help me with the latter part of this? I have no further code to post, as none of it has worked and it errors immediately when trying to read in what I thought would be the data from the array (see the example I gave in my previous reply). Thanks in advance.
-
Skeleton examples are good, but I should point out (again) that the Help files for AutoIt are not as helpful to a total beginner as you might think, and it is a hugely daunting task to trawl through dozens or hundreds of example scripts trying to find an example even close to what I am trying to achieve. I am not a programmer by profession, and I have not 'ordered' anyone to do anything in here. This is, after all, a Help & Advice forum. I've been polite, I've asked for pointers, and I've admitted from the start that I don't really know much about any of this. I provided example code to show that I had made a start, and I have been grateful for your responses, as I am grateful for your reply now. I will go through and read up on the various parts of the example you have given, but I still don't grasp how I then incorporate what I have working now (shown earlier) with what you have suggested. Once the data is read into the array, how would I (for example) express the variable that now contains the folder path that is stored as the first entry in each record and add that into my code? e.g. WinActivate("C:\temp") Is it meant to be ... WinActivate($aFolder[$i][0]) ... and where within the example you have given would I put my original code (with suitable variables inserted)?
-
Also, just thought that it would be useful to have some kind of check that looks for a specific entry in the text file to signify the end of the data. That way, the number of folders defined can presumably be different for each user. I am thinking that if I can get this working, I would compile the program into an exe and supply that and an example array text file to the other people to then define their own folder requirements. Some might need more folders open than I do, and so something like EOL at the end would signify no more entries to be read into the array. Is that possible?
-
I need help in implementing the _FileReadToArray into my code, as none of the examples I've read make any sense to me. I'm not really a programmer, and am finding the help files on the subject extremely confusing. I know what I need to do in principle, but I don't grasp the correct syntax required in AutoIt to do it. Is anyone willing to take my example code, and show me what needs to be done to it? There seems to be an assumption in many of the help text for AutoIt that you already know what you're doing, and that you understand the given examples, which is definitely not the case for me!
-
Working backwards, I don't know what you mean in regards to Scite?? I have no idea how to implement the array, or use variables instead of absolute values in my AutoIt script. My knowledge and understanding is really fairly basic. In the old days I would do some kind of for... next loop, but I am really am starting from the ground up on this.
-
Have added a little more to the requirements. I am also now checking to see if the folder is open already or not. If it is open then it moves it to the correct size and position (regardless of whether it was or not), before continuing to open and move the folder if it wasn't already open. Doing this means that if one or more folders have been accidently closed or moved, you can get them back just by running the script again, and it not opening duplicates of any folders already open. If WinExists("[TITLE:C:\temp; CLASS:CabinetWClass;]") Then WinActivate("C:\temp") WinMove("[CLASS:CabinetWClass]","",1684,8,228,300) Else Run("explorer.exe C:\temp") WinWait("[CLASS:CabinetWClass]","",3) WinMove("[CLASS:CabinetWClass]","",1684,8,228,300) WinWaitActive("C:\temp") Send("^!5") EndIf The variables I would need to change for each folder would be (from the above example) C:\temp, 1684, 8, 228, 300, 3, and 5 so I assume these are what would need to be stored in the array text file?
-
Run("explorer.exe <folder-name>") ;open the folder WinWait("[CLASS:CabinetWClass]","",<wait-in-seconds>) ;wait for a few seconds WinMove("[CLASS:CabinetWClass]", "",<pos1>,<pos2>,<size1>,<size2>) ;move the folder to the stated position and set the size WinWaitActive("<folder-name>") ;wait for the stated folder to be active Send("^!<view-type>") ;set the folder view to be the view-type (e.g. 5 for List) Here's what I've got so far, but I have to admit, looking at FileReadToArray is a bit daunting! The variables I need to use (as indicated above) are the folder name, wait time, position co-ordinates pos1, pos2, then dimensions of the open folder, size1, size2 and the view type, which is likely to always be List (e.g. 5). Any pointers on what I need to do to get this working for the 21+ folders I need to define would be much appreciated!
-
Hi, Great stuff. I have got explorer opening multiple folders working, including their size and position. I have also worked out how to get it to show each folder in List view, which I also needed. I could see that by using variables (folder name, size, position, view) and by then using some kind of array, I could make this much more efficient, so I will now read up on FileReadToArray. Thanks! 🙂
-
I am very new to using AutoIt, and am hoping it can be used to automate one hopefully straight-forward task. In my work, I have open a set number of folders on the Windows 10 desktop (typically 21 folders). However, sometimes a restart or software update closes some or all of the windows, and it's a pain to have to reopen and manually reposition them on a semi-frequent basis. What am I looking to do is record the size and position of each open folder. They are currently all launched using a separate explorer.exe instance via a simple .bat file, and I would like to run a simple AutoIt script to open them all and reposition them where they need to be. I am hoping that is possible, but am unsure how to achieve it. Any pointers gratefully received.