Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Command Prompt in Explorer Address Bar


  • Please log in to reply
18 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
I believe this will be a very usable script. This script gives an easily accessible command prompt right into windows explorer's address bar.

Posted Image

In any explorer window first go to Tools > Folder Options > View and enable 'View full path in Title Bar'

After that when this script is running just type '/' in the address bar of explorer window and type a DOS command to run it hidden.

And to run it visibly and keep the command prompt window after that command, just use '//' instead of '/'

;___________________________________________
;______Easy Command Prompt  - Rajat_________

; Type '/' in the address bar of explorer window and type
; a DOS command to run it hidden.

; And to run it visibly and keep the command prompt
; window after that command, just use '//' instead of '/'



Hotkey, Enter, Prompt
Hotkey, Enter, Off
exit

~/::
	do = n
	ControlGetFocus, ctl, A
	IfWinActive, ahk_class CabinetWClass,, IfEqual, ctl, Edit1, setenv, do, y
	IfWinActive, ahk_class ExploreWClass,, IfEqual, ctl, Edit1, setenv, do, y
	IfEqual, do, n, Return
	
	WinGetActiveTitle, pth
	Hotkey, Enter, On
Return


Prompt:
	Hotkey, Enter, Off
	do = n
	ControlGetFocus, ctl, A
	IfWinActive, ahk_class CabinetWClass,, IfEqual, ctl, Edit1, setenv, do, y
	IfWinActive, ahk_class ExploreWClass,, IfEqual, ctl, Edit1, setenv, do, y
	IfEqual, do, n
	{
		Send, {Enter}
		Return
	}
	ControlGetText, cmd, Edit1, A
	StringLeft, check, cmd, 2
	IfEqual, check, //
	{
		StringTrimLeft, cmd, cmd, 2
		run, %comspec% /k %cmd%, %pth%
	}
	
	IfNotEqual, check, //
	{
		StringTrimLeft, cmd, cmd, 1
		run, %comspec% /c %cmd%, %pth%, hide
	}
	ControlSetText, Edit1, %pth%, %pth%
Return

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
That's a great way to integrate with the system. It makes that under-utilized address bar do something useful!

  • Guests
  • Last active:
  • Joined: --
I should mention that this would be the easiest way to to run something with command line parameters, when one is using explorer.

one just has to type something like this '/myscript.ahk param'

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
err.. i made the above post.
(just logged in)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I see that it extracts the path from the active title. I think this might require that a certain option be turned on in the Explorer (maybe it defaults to On, but I don't think so).

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

I see that it extracts the path from the active title. I think this might require that a certain option be turned on in the Explorer (maybe it defaults to On, but I don't think so).


er, i've mentioned this:
In any explorer window first go to Tools > Folder Options > View and enable 'View full path in Title Bar'

After that when this script is running just type '/' in the address bar of explorer window and type a DOS command to run it hidden.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Sorry, I have to learn to read the entire post!

modah
  • Members
  • 8 posts
  • Last active: Jun 03 2005 10:13 AM
  • Joined: 02 Mar 2005
great script! thanks for the good idea and then posting it! :D

Decarlo110
  • Members
  • 303 posts
  • Last active: Feb 12 2006 02:15 AM
  • Joined: 15 Dec 2004
I'm not sure how many are aware of the following feature, so I'm posting this link. The page has some other info you might find helpful regarding the commandline. It works for Win2000 and 98SE. I dont have XP, and probably wont "upgrade" to the next 1. I'm predicting SourceForge or another similar software community will give rise to a worthy, better, and fully compatible O/S.

Use Address Bar as a Command Line:
http://www.itnworks....ps/tipsw2kp.htm

just to make sure...
- the "Address" title is removable (right-click)
- to remove the "Go" icon: Internet Options > Advanced > Browsing > uncheck "Show Go button in Address Bar"
- the AddressBar is draggable, as it is in IE

With that said, Raj writes nifty progs, and this CommandLine one is another definitely based on a practical concept.
1) The Open Source Definition http://www.opensourc...ition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <>

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Thats a nice tip Decarlo, i didn't know that! by the way there's a li'l benefit of my script, the cmd gets carried out in currently browsed folder... that's all!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Lode
  • Guests
  • Last active:
  • Joined: --
I wonder if there is any way to extract the path of an active explorer window without changing the windows to show the entire path in the title bar?

It's a bit chaotic with long paths.

Thx for help
Lode

urlwolf
  • Members
  • 150 posts
  • Last active: Feb 26 2012 07:56 PM
  • Joined: 16 Mar 2006
and...

Is there any way to tell the cmd prompt to stay open after the command is run so you can actually see the output? :)
thanks, great tip

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

Is there any way to tell the cmd prompt to stay open after the command is run so you can actually see the output? :)

And to run it visibly and keep the command prompt window after that command, just use '//' instead of '/'


@Lode: there is a big topic on the tricks with Explorer. One suggested that the Edit1 control of the Explorer (the Address bar) can be read even if it is hidden. I didn't tried, I always have it active and the full path in the title bar. I don't find it so chaotic...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

badmojo
  • Members
  • 204 posts
  • Last active: Jul 23 2014 01:39 AM
  • Joined: 11 Nov 2005
Rajat, can you adapt this script for Firefox users as well?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I doubt it, or it will be hard, as the address bar isn't really visible from AHK point of view. Perhaps some extension allows to do it.

Note that originally, the trick was for Windows Explorer, not Internet Explorer, but since they are now closely related, I am not surprised if it works for IE.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")