Hey
Just wrote this simple utillity in autohotkey. It copies the address form a folder which you have open in Windows Explorer and opens it in command line.
Just press a costumisable hotkey (default is win+c) while navigating in windows Explorer.
This can save you hours if you work with computer science and have to use the windows console in order to invoke different services.
SmartCMD can be downloaded from:
http://www.akosta.dk/en/smartcmd/
Tired of navigating in command line (cmd.exe)? use smartCMD
Started by
TobAlr
, Dec 07 2011 01:01 PM
11 replies to this topic
#1
TobAlr
Posted 07 December 2011 - 01:01 PM
#2
Guests
Posted 07 December 2011 - 02:00 PM
Why not post with source in Scripts & Functions?
You can host your files on <!-- w -->www.autohotkey.net<!-- w --> for free as well.
You can host your files on <!-- w -->www.autohotkey.net<!-- w --> for free as well.
#3
Posted 13 December 2011 - 12:35 PM
I have seen this exact functionality many times already
; Only do this within Explorer #IfWinActive ahk_class CabinetWClass ^!h:: ClipSaved := ClipboardAll Send !d Sleep 10 Send ^c Run, cmd /K "cd `"%clipboard%`"" Clipboard := ClipSaved ClipSaved = Return #IfWinActive ; Do this anywhere else #IfWinNotActive ahk_class CabinetWClass ^!h:: Run, cmd /K "cd `"%HOMEPATH%`\Desktop"" Return #IfWinActive
#4
Posted 20 December 2011 - 10:53 AM
still using XP, eh? 
startin from Vista you can shift+right click -> Open Cmd Window here in explorer window
startin from Vista you can shift+right click -> Open Cmd Window here in explorer window
#5
TheKingBoar
Posted 22 May 2012 - 10:56 PM
Sorry to bump such an old topic, but is there anyway to make this code compatible with Windows 7? I'm aware of the shift+right click trick, but this requires me to be outside of the folder, and I am already inside of it. Considering how often I do this, the extra 7ish seconds to go up a directory and make the stretch for shift+right click adds up to a lot of time over the year. Can't figure out why it doens't work in Windows 7, but it only works for the first window you use it in, and if you use it again in a second window, it re-opens the command prompt in the first.
#6
Posted 23 May 2012 - 04:39 AM
It already works in win7
You must have an option turned on.
within W.E.
choose tools->folder options...
view tab, advanced settings, set the check for "display the full path in the title bar"
press 'ok' to exit & save the change.
You must have an option turned on.
within W.E.
choose tools->folder options...
view tab, advanced settings, set the check for "display the full path in the title bar"
press 'ok' to exit & save the change.
#7
Posted 23 May 2012 - 10:56 AM
You can drag and drop folders on the cmd window to add paths.
#8
TheKingBoar
Posted 23 May 2012 - 05:58 PM
Thank you both for your replies. The full path setting doesn't seem to work even with the classic theme, AHK still opens the folder in a previous directory rather than a current. I haven't had a chance to reset yet due to a long running download, but will try that out as soon as possible. The drag and drop method is convenient if you're outside the directory and already have a command window open, but I generally don't fall in those circumstances. While I had hoped to stick with AHK, it's also surprisingly slow (5 seconds just to open the misplaced command prompt). The utility the OP posted is quite quick and doesn't have this issue. Although I will still try to get this to work with AHK, so far it's not looking great. But thanks again!
#9
Posted 13 July 2012 - 05:36 AM
Personally, I use this code which still works in Windows 7:

If somebody has a trick for that...
GetWindowsExplorerCurrentFolder()
{
local path
If (A_OSVersion = "WIN_XP")
{
ControlGetText path, Edit1, A
}
Else If (A_OSVersion = "WIN_VISTA")
{
ControlGetText path, toolbarwindow322, ahk_class CabinetWClass
; Remove prefix like "Address:" or "Addresse : " (depend on localization)
path := RegExReplace(path, "^.*?:\s*", "")
}
Return path
}But I had code to get the currently selected file, and it no longer works... If somebody has a trick for that...
#10
Posted 19 July 2012 - 04:48 AM
PhiLho, your function will do nothing at all on AutoHotkey_L on Windows 7 or later, as A_OSVersion will not contain WIN_XP or WIN_VISTA. I suppose the "most compatible" solution would be:
Afaik, the simplest method to get the currently selected file has always been to copy it to the clipboard by sending ^c, and that still works.
Alternatively, you can use code like the following (or equivalent code for AutoHotkey Basic):
if A_OSVersion in WIN_XP,WIN_2003,WIN_2000,WIN_NT4,WIN_95,WIN_98,WIN_ME
{
; Pre-Vista code
}
else
{
; Code for Vista and later
}Afaik, the simplest method to get the currently selected file has always been to copy it to the clipboard by sending ^c, and that still works.
Alternatively, you can use code like the following (or equivalent code for AutoHotkey Basic):
hwnd := WinExist("A")
for window in ComObjCreate("Shell.Application").Windows
if (window.hwnd = hwnd)
{
MsgBox % window.Document.FocusedItem.Path
break
}
For multiple selected items, you can use the SelectedItems collection in place of FocusedItem.
#11
Posted 26 July 2012 - 07:08 PM
Thanks Lexikos.
Since I code very little in AHK today (but still use it daily!), I stick to classic AHK...
After posting my question, I indeed saw a script using the clipboard to get the selected file names. I forgot the trick, perhaps because in general I am reluctant to mess with the clipboard.
Although the script was restoring it afterward. And I have now a clipboard manager, anyway.
So, thanks for the advices and tricks. (I can't use the last one, I suppose, with classic AHK.)
Time to re-hack my old permanent script, I think...
Since I code very little in AHK today (but still use it daily!), I stick to classic AHK...
After posting my question, I indeed saw a script using the clipboard to get the selected file names. I forgot the trick, perhaps because in general I am reluctant to mess with the clipboard.
Although the script was restoring it afterward. And I have now a clipboard manager, anyway.
So, thanks for the advices and tricks. (I can't use the last one, I suppose, with classic AHK.)
Time to re-hack my old permanent script, I think...
#12
Posted 06 August 2012 - 07:52 PM
I wrote one awhile back called PromptHere. You may download from this page:
<!-- m -->http://www.favessoft.com/hotkeys.html<!-- m -->
It also requires "show path in title bar" but it uses the text from the window rather than getting it from the edit control. On Vista and W7 it uses "blur behind" effect. You can disable thins in the .ini file using UseGlass option.
If Explorer window is active with nothing selected it opens a prompt in containing folder(see Readme.txt for limitations.) Also you may select multiple folders and hit the hotkey to open a prompt for each.
The zip includes ahk source as well as compiled exe and custom icon. The script compiles with latest AHK_L 32 bit English Unicode. (I just recompiled and uploaded v. 2.9.2.0.) Also it has a "check for update" command in the Tray Menu. The check works by downloading an .ini file FavesVersions.ini and comparing the current version you are running to the ini version setting. No info about your machine is sent to my site other than the download commands.
(In fact the "check for update" function is included in the MilesAhead.ahk script that's in the zip.)
<!-- m -->http://www.favessoft.com/hotkeys.html<!-- m -->
It also requires "show path in title bar" but it uses the text from the window rather than getting it from the edit control. On Vista and W7 it uses "blur behind" effect. You can disable thins in the .ini file using UseGlass option.
If Explorer window is active with nothing selected it opens a prompt in containing folder(see Readme.txt for limitations.) Also you may select multiple folders and hit the hotkey to open a prompt for each.
The zip includes ahk source as well as compiled exe and custom icon. The script compiles with latest AHK_L 32 bit English Unicode. (I just recompiled and uploaded v. 2.9.2.0.) Also it has a "check for update" command in the Tray Menu. The check works by downloading an .ini file FavesVersions.ini and comparing the current version you are running to the ini version setting. No info about your machine is sent to my site other than the download commands.
(In fact the "check for update" function is included in the MilesAhead.ahk script that's in the zip.)




