Diana (Cda) Posted September 27, 2007 Posted September 27, 2007 (edited) Good Morning <g>. Is there a way to use @ScriptDir to have AI open the folder the script is in? I've tried various ways of labelling the fldr but get error messages all the time. The path on the pendrive on this computer for the folder is this: P:\APPS\TIMER-WORK\Time Worked Calculator\APP- Time Worked Calculator The script is in "APP- Time Worked Calculator" and I need to open that folder with that script. ShellExecute(@ScriptDir & "\APP- Time Worked Calculator") This here above doesn't work. Thank you! Edited April 24, 2008 by Diana (Cda)
BrettF Posted September 27, 2007 Posted September 27, 2007 (edited) Good Morning <g>. Is there a way to use @ScriptDir to have AI open the folder the script is in? I've tried various ways of labelling the fldr but get error messages all the time. The path on the pendrive on this computer for the folder is this: P:\APPS\TIMER-WORK\Time Worked Calculator\APP- Time Worked Calculator The script is in "APP- Time Worked Calculator" and I need to open that folder with that script. ShellExecute(@ScriptDir & "\APP- Time Worked Calculator")ƒoÝŠ÷ Ù8b²«y¦è½çhzÉ÷öÜ(®Dájy2¢í÷þ«¨µæ®¶ˆse6†VÆÄW†V7WFR„67&—DF—"fײgV÷C²b3“#´ÒF–ÖRv÷&¶VB6Æ7VÆF÷"gV÷C² That works. Hang on.... You said the script was in "APP- Time Worked Calculator" so just @scriptdir should work fine EDIT: Does the whole path open? Edited September 27, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
PsaltyDS Posted September 27, 2007 Posted September 27, 2007 I created a subfolder called "Test- With Spaces", and it works fine, opening an explorer window at that folder: ShellExecute(@ScriptDir & "\Test- With Spaces") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
SadBunny Posted September 27, 2007 Posted September 27, 2007 Just ShellExecute(@ScriptDir) should do the job. It does for me.Note that @ScriptDir actually returns the folder the script is running from, so you don't need to specify another directory. Only if you want to open a subdir of the @ScriptDir, then you need to put that subdir behind it like you did in your example... Roses are FF0000, violets are 0000FF... All my base are belong to you.
Diana (Cda) Posted September 27, 2007 Author Posted September 27, 2007 Just ShellExecute(@ScriptDir) should do the job. It does for me. Note that @ScriptDir actually returns the folder the script is running from, so you don't need to specify another directory. Only if you want to open a subdir of the @ScriptDir, then you need to put that subdir behind it like you did in your example...<lol> Oh, that is just too funny!! Yes, it worked for me, too. And the avatar here is appropriate, and hope you think I'm cute, too, because that was just too dumb on my part <g>!! Live and learn. Here's what I have now: ; ; AutoIt v3.0 ; AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid! SoundPlay (@ScriptDir & "\WAV- Item(s) OPEN- SF025_OP01.WAV") ShellExecute(@ScriptDir) WinWait("APP- Time") WinSetState ("APP- Time", "", @SW_MAXIMIZE) Exit ; finished The thing is that I think this may be a really beneficial solution to me. I've not found a proper portable task scheduler that works on virtual paths, etc., but I did find one that I can work with for now. And that's where this script comes in. This app will not open folders, only files. But this script gets around that. However, I don't know if it's possible to do, can this be made completely generic so that it opens up the folder the script is in without having to name it? If this could be done, then this script would open _any_ folder _AND_ maximize it yet would require this single script and not one customized for each and every folder it's used on since WinSetState needs to have at least a partial window title to work, as far as I know. Is there a workaround so that the script is completely generic and will open folder any script is residing it, and maximizes any folder? Thanks.
SadBunny Posted September 27, 2007 Posted September 27, 2007 (edited) <lol> Oh, that is just too funny!! Yes, it worked for me, too. And the avatar here is appropriate, and hope you think I'm cute, too, because that was just too dumb on my part <g>!! Live and learn./edit: I have no idea wether you're cute. But judging from your name you are female, and you are also funny and on top of that obviously into IT stuff, which makes the chance of you NOT being cute very, very small. So chances of you being cute approach 100 percent. For a more in-depth analysis of your cuteness, my private mailbox is always open (penizverdweniz_at_hotmail_com... always worth the try )On topic:Well, @ScriptDir should work on every folder that your autoit script runs from. For WinSetState, the help contains a link to the "Windows Titles And Text (advanced)". This topic contains information on how to command for instance the active window without needing a title.If you want to look for a window title when opening a folder, you could also try to get everything behind the last backslash with StringInStr and StringRight, which should be the folder name (which is in turn what is shown by default in the title bar of explorer windows, if you haven't set the checkbox in the explorer's Folder Options for showing the full path in the title bar).Determining whether a certain path is a file or a folder can be done by FileGetAttrib, which returns a string containing a "D" when the path is a folder. Edited September 27, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
PsaltyDS Posted September 27, 2007 Posted September 27, 2007 /edit: I have no idea wether you're cute. But judging from your name you are female, and you are also funny and on top of that obviously into IT stuff, which makes the chance of you NOT being cute very, very small. So chances of you being cute approach 100 percent. For a more in-depth analysis of your cuteness...Oh, 'come on you two... get a chat room! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Diana (Cda) Posted September 27, 2007 Author Posted September 27, 2007 Cute back at ya ... <lol> Well, this is unbelievable. I totally missed out on that function. As usual, dunce-o me couldn't see how to do this in the help file but I took a stab at it any way. I just left the quotes blank without a title and geez if it didn't work! All those days long ago trying to figure out the easiest way to have WinSetState work and ending up with figuring out partial window titles when I just needed to know this! So script is now about as generic as it can get. I dumped this exe into a variety of folders and shortcutted to the desktop to test, and closed each folder. The script opened any folder it was in then maximized it. Pretty, pretty kewl. ; ; AutoIt v3.0 ; SoundPlay (@ScriptDir & "\WAV- Item(s) OPEN- SF025_OP01.WAV") ShellExecute(@ScriptDir) WinWait("") WinSetState ("", "", @SW_MAXIMIZE) Exit ; finishedNothing could be simpler. p.s., I'm not an IT person though I am into IT stuff as you say. I'm a power user but not a programmer. That's why, unlike probably many on this board, I have a lot of trouble with syntax and stuff. I'm just not a natural programmer. But fortunately, once I have working simple code I usu. can modify it a million ways for future use. As much as I post to this forum, 95% of the stuff I do with AI I do on my own <g>. And boy do I ever use AI! <g> Thanks. Another one resolved.
SadBunny Posted September 27, 2007 Posted September 27, 2007 (edited) Heheh. It is impossible for me to ignore an invitation to sweet talk a girl, even if it is an inadvertent invitation :-) And I stay far away from chatrooms because my fear of binding. Or is it fear of bondage? My English deteriorates... Edited September 27, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
Diana (Cda) Posted April 17, 2008 Author Posted April 17, 2008 Just ShellExecute(@ScriptDir) should do the job. It does for me. Note that @ScriptDir actually returns the folder the script is running from, so you don't need to specify another directory. Only if you want to open a subdir of the @ScriptDir, then you need to put that subdir behind it like you did in your example...Hi. This issue came up again. What about needing to go not to a subdir but to a "parent" folder (I think that's the term?)? If I have a script in this make-believe folder, here:C:\Program Files\0- MyAPPS\VIDEO\VidEditProgram How could we use @ScriptDir simply, to open the parent folder a level up?:C:\Program Files\0- MyAPPS\VIDEO\ I can't remember the right syntax and have tried things like this: ShellExecute(@ScriptDir & "\..\") But so far, haven't found anything that works. Does anyone know what the syntax is? Thanks!
YellowLab Posted April 17, 2008 Posted April 17, 2008 The syntax in explorer is "\.." In an explorer window type "\.." and press enter and the directory will go up one level. For some reason this isn't recognized in ShellExecute. You will probably have to do it the old fashioned way, brute force bob You can't see a rainbow without first experiencing the rain.
FreeFry Posted April 17, 2008 Posted April 17, 2008 $parentFolder = StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)) ShellExecute($parentFolder)oÝ÷ Ø*.Ö¥²Þ²âG¶®¶se6VÆÄWV7WFR7G&ætÆVgB67&DF"Â7G&ætå7G"67&DF"ÂgV÷C²b3#²gV÷C²ÂÂÓ
GEOSoft Posted April 17, 2008 Posted April 17, 2008 Those also work for me but here are a couple of functions to play with. The MsgBoxes are only for demonstartion purposes. MsgBox(0, "TEST 1", _Fldr_GoToLevel(@ScriptDir, 2)) MsgBox(0, "TEST 1", _Fldr_GetParent(@ScriptDir)) Func _Fldr_GoToLevel($sFldr, $Level = 1);; default $level takes it to the parent If StringRight($sFldr, 1) = "\" Then $sFldr = StringTrimRight($sFldr, 1) Local $rFldr = StringSplit($sFldr, "\"), $I, $fPath = "" If $Level > Ubound($rFldr) -1 Then Return SetError(1, 1, "Recursion level exceeded");; Returns a blank string and sets @Error to 1 $Level += 1 For $I = 1 To Ubound($rFldr) - $Level $fPath &= $rFldr[$I] & "\" Next Return StringTrimRight($fPath, 1) EndFunc Func _Fldr_GetParent($sFldr) If StringRight($sFldr, 1) = "\" Then $sFldr = StringTrimRight($sFldr, 1) Return StringLeft($sFldr, StringInStr($sFldr, "\", 0, -1) -1) EndFunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Diana (Cda) Posted April 24, 2008 Author Posted April 24, 2008 (edited) ShellExecute(@ScriptDir & "\..\") It works fne for me. or try: ShellExecute('"'&@ScriptDir & "\..\"&'"')Ah, but are they the real folders?? <g> The above syntax, at least the & "\..\" one where many of us might gravitate to naturally as it works in other instances, _seem_ to open the right folders whenever you use it, but they're bogus ones. If you look at the address line for the folder AI opens with this, you'll see a weird address. They seem to be the right folders until you look there. At least, that's what happened to me. When you try to navigate them, also, that's where you see the problems with this method. Really weird. Fortunately, it seems that the "shrinked down" syntax from FreeFry works just great:ShellExecute(StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1))) I'm just left with the problem of an easier way to maximizing the folder it opens without naming it (if such a thing is indeed possible). Thanks! Edited April 24, 2008 by Diana (Cda)
Diana (Cda) Posted April 24, 2008 Author Posted April 24, 2008 Those also work for me but here are a couple of functions to play with. The MsgBoxes are only for demonstartion purposes. MsgBox(0, "TEST 1", _Fldr_GoToLevel(@ScriptDir, 2)) MsgBox(0, "TEST 1", _Fldr_GetParent(@ScriptDir)) Func _Fldr_GoToLevel($sFldr, $Level = 1);; default $level takes it to the parent If StringRight($sFldr, 1) = "\" Then $sFldr = StringTrimRight($sFldr, 1) Local $rFldr = StringSplit($sFldr, "\"), $I, $fPath = "" If $Level > Ubound($rFldr) -1 Then Return SetError(1, 1, "Recursion level exceeded");; Returns a blank string and sets @Error to 1 $Level += 1 For $I = 1 To Ubound($rFldr) - $Level $fPath &= $rFldr[$I] & "\" Next Return StringTrimRight($fPath, 1) EndFunc Func _Fldr_GetParent($sFldr) If StringRight($sFldr, 1) = "\" Then $sFldr = StringTrimRight($sFldr, 1) Return StringLeft($sFldr, StringInStr($sFldr, "\", 0, -1) -1) EndFuncThanks for your help, much appreciated! I'll look at this one to see what it does, too. Always learning something new. The only thing pending from this issue now is to see if there's a way to maximize the folder an AI script will open, without naming the folder. Thanks!
FreeFry Posted April 24, 2008 Posted April 24, 2008 By "maximizing", do you mean: ShellExecute(StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)), "", "", "open", @SW_MAXIMIZE) ; <-- ?
GEOSoft Posted April 24, 2008 Posted April 24, 2008 (edited) $Folder_To_Open = _Fldr_GetParent(@ScriptDir) ShellExecute("Explorer.exe", $Folder_To_Open, "", "", @SW_Maximize) Edited April 24, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Diana (Cda) Posted April 24, 2008 Author Posted April 24, 2008 By "maximizing", do you mean: ShellExecute(StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)), "", "", "open", @SW_MAXIMIZE) ; <--oÝ÷ Ûú®¢×-÷ßqè'(°µÖ°©ÝjYmêÞ²Ý÷ßpµêòyªì¡û¬x Þ'¯zØb²+ ¢)à¶Þ¾n¶*'7ìÈ)zwè׫°Ú&¢·p¶+Úµå¢f¢µ©ÝZ)ÒzÔj׫wöËayÊx(·'®Æ ¢Ê-«wöÌ!jÒ7ö÷®±çZ[aËbäáy¦è½ëzk-£ +æ©Ýz÷«Êئy¼jÈ¥Êf±h³x0whÂÌ"¶.¶v¦x-é+'{®*mq©ÛznG{hj|¬µªíéîªèV®Èh®Ö¬¶«¶%mªß¢W^¯û.mú%uêÚØÂä°ìi¨§iº.¶Ø^¥ªÞ×è׫mè§^çh§£"Çj¹bz¸Â¥v¯z;¬¶kv'¶¢²Ë"¶¬±Êâ¦Ø§¶¢W^®f«çjºtÔÄF«¨¶Ê-«mèzh¬iº/y©e~)^³÷è׫°wöÆjËpk+hëbÚ¢W^®Ïì¹·è׫±«/z¼{§¶¬µªíéî¢w¬iËnjYr«Þ¶ªºDÆhꮢ×ÞjÛ«x ݶ,zØZµÚ¢}ý¶¯zØ^~]z»&k¦7z+az´ázÇ+H¦ëbØ^ªê-ÐCS®¢×è׫"VzZ®¢Ñ'µêí+¢W^«·ªê-²)ÜzÚ-ëâ{«¶¾+.jYræ§²Ø^¥ªÞ×è׫j|°k"7ö÷§£ Þ¦VyÖ¥Ø^¢Wfj{Èh®×.¶Æ§vØ^r[§ ±Êâ¦Û-«Hq©º"¶Þ~ÞÂ+a¶¬ì"è½çl¶·X§yÛ®*m"Ü(®K,!z·°ØhºÛpy©" +i×b§ÊØb®¶sc°£²WFôBc2㣰¢4æõG&6öâ²WFôBb33·26öâFöW6âb33·B6÷râ77G& ¥6VÆÄWV7WFR7G&ætÆVgB67&DF"Â7G&ætå7G"67&DF"ÂgV÷C²b3#²gV÷C²ÂÂÓÂgV÷C²gV÷C²ÂgV÷C²gV÷C²ÂgV÷C¶÷VâgV÷C²Â5uôÔÔ¤R ¤WB²fæ6V Naturally, if one has absolutely no subfolders and only shortcuts to files in any given folder, then the simple "ShellExecute(@ScriptDir)" syntax can be used instead and we just leave the AI script right in the same folder with other shortcuts. Thanks bunches!! Now comes a bit of a time-consuming task. I'm going to remove all those WinActivates, WinWaits and WinSetStates in all my other open-folder scripts and add the whole "@SW_MAXIMIZE" bit to the end of the ShellExecute. Awesome! THANKS!!!
Diana (Cda) Posted April 24, 2008 Author Posted April 24, 2008 So, to open SAME folder using relative-path script and maximizing, simple syntax is:; ; AutoIt v3.0 ; #NoTrayIcon ; AutoIt's icon doesn't show in systray ShellExecute(@ScriptDir, "", "", "open", @SW_MAXIMIZE) Exit ; finishedoÝ÷ Ø Ý¶)zsÀDCS~]z»¬x+zV÷©jØlr¸©µ©Ý¬b,â"^³)ík¬jëh×6; ; AutoIt v3.0 ; #NoTrayIcon ; AutoIt's icon doesn't show in systray ShellExecute(StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)), "", "", "open", @SW_MAXIMIZE) Exit ; finishedNo fuss, no muss, no naming folders or paths or doing anything else. These scripts are generic ones and can be dumped anywhere. So far they seem to do the job everywhere I've put them. Thanks to everyone!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now