w0uter Posted November 28, 2005 Posted November 28, 2005 (edited) i hate having to type the full path when i need to run a commandline appthis way you can just browse to the app and hit #c and you have a dos prompt with the correct dir.(that is atleast if you have full path names in your titles)hope it is use to someone:ty gafrost#NoTrayIcon HotKeySet('#c', '_CMD') While 1 Sleep(1000) WEnd Func _CMD() $path = ControlGetText(Wingettitle(''),"","Edit1") Run(@comspec & ' /k ' & StringLeft($path, 2) & ' & cd "' & $path & '" & cls', @SystemDir) EndFunc Edited November 28, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
GaryFrost Posted November 28, 2005 Posted November 28, 2005 (edited) might try this, had a problem using #c, so changed it alt-c, had the command incorrect also, was \k fixed /k HotKeySet('!c', '_CMD') While 1 Sleep(1000) WEnd Func _CMD() $path = ControlGetText(Wingettitle(''),"","Edit1") Run(@comspec & ' /k cls & cd "' & $path) EndFunc Edited November 28, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
ryeguy Posted November 28, 2005 Posted November 28, 2005 (edited) its been done. #include <Process.au3> _RunDOS( $sCommand ) and btw, the window stays open if you use /k, using /c closes it after the command is executed so you don't need cls. Edited November 28, 2005 by ryeguy
w0uter Posted November 28, 2005 Author Posted November 28, 2005 did you even read it ? or did you just post in the wrong topic My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
GaryFrost Posted November 28, 2005 Posted November 28, 2005 (edited) ryeguy said: its been done.#include <Process.au3>_RunDOS( $sCommand )and btw, the window stays open if you use /k, using /c closes it after the command is executed so you don't need cls. Think you missed the point of what w0uter is attempting to do, he needs to go to the dos promptKeeps the program running so that he can do that when he needs to _RunDOS would be a little bulky for that, why run a @ComSpec & " /C " & $sCommand (command would be equal to: (@comspec & ' /k cls & cd "' & $path) so now you have@ComSpec & " /C " & (@comspec & ' /k cls & cd "' & $pathNow if _RunDOS had a parameter for keep open or close then that would be usefull. Edited November 28, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Klaatu Posted November 28, 2005 Posted November 28, 2005 Doesn't work with UNC paths, of course. What might make it work is to replace the 'cd' command with 'pushd'. Doing that, though, may make it work on only certain versions of Windows. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
kpu Posted November 28, 2005 Posted November 28, 2005 Klaatu said: Doesn't work with UNC paths, of course. What might make it work is to replace the 'cd' command with 'pushd'. Doing that, though, may make it work on only certain versions of Windows. I never knew about the "pushd" command. Thnks for that. =) Here's it with that command. I can't take any credit of course, I didn't really do anything... Func _nCMD() $path = ControlGetText(Wingettitle(''),"","Edit1") Run(@comspec & ' /k cls & pushd "' & $path & '"') EndFunc The fun part is now trying to do a "if" or "case" so you can do it under one hot key. http://www.kpunderground.com
busysignal Posted November 29, 2005 Posted November 29, 2005 @w0uter, nice idea. It is nice to write scripts that can get you where you want to be faster then M$ way of doing things. It's simplicity wins you four stars.. Cheers..
dabus Posted November 29, 2005 Posted November 29, 2005 (edited) And stupid me uses this old bastard [HKEY_CLASSES_ROOT\Directory\shell\cmd\command] cmd.exe /k "cd %L" @w0uter: That idea's just way too cool Edited November 29, 2005 by dabus
GaryFrost Posted December 6, 2005 Posted December 6, 2005 (edited) kept forgetting if i had the program running or not, so added to it a lil bit expandcollapse popup#NoTrayIcon $G_SZVERSION = "_CMD Center ver 1.2" & @LF & @LF & "Made with AutoIt ver " & @AutoItVersion If WinExists($G_SZVERSION) Then Exit; It's already running AutoItWinSetTitle($G_SZVERSION) opt("TrayOnEventMode", 1) opt("TrayMenuMode", 1) AdlibEnable("_ReduceMemory") HotKeySet("!e", "_Exit") HotKeySet('!c', '_CMD') $cmditem = TrayCreateItem("Open CMD Window") TrayItemSetOnEvent(-1, "_CMD") $aboutitem = TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") $exititem = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") $dll = DllOpen("psapi.dll") TraySetIcon(@SystemDir & "\cmd.exe", 0) TraySetState() $Current_Window = "" While 1 If WinGetTitle('') <> $G_SZVERSION Then $Current_Window = ControlGetText(WinGetTitle(''), "", "Edit1") _ReduceMemory($dll) Sleep(50) WEnd DllClose($dll) Func OnAutoItExit() DllClose($dll) EndFunc ;==>OnAutoItExit Func ExitScript() Exit EndFunc ;==>ExitScript Func _CMD() Run(@ComSpec & ' /k pushd "' & $Current_Window & '"') EndFunc ;==>_CMD Func About() MsgBox(64, "About:", $G_SZVERSION) EndFunc ;==>About Func _Exit() Exit EndFunc ;==>_Exit Func _ReduceMemory($dll = "psapi.dll") Local $ai_Return = DllCall($dll, 'int', 'EmptyWorkingSet', 'long', -1) Return $ai_Return[0] EndFunc ;==>_ReduceMemory Edited December 6, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Gigglestick Posted December 6, 2005 Posted December 6, 2005 (edited) @wOuter On Windows 2000 and above you can use a '/d' with the CMD instead of the old way of 'D:' followed by 'cd D:\foo\bar'. Run(@comspec & ' /k cd /d "' & $path & '" & cls', @SystemDir) @Klaatu Pushd doesn't allow for authentication, but is a very handy way of cd'ing to a UNC. Also, for those who didn't know, pushd and popd use a stack, so you can use multiple pushd's (it will create one drive letter for each call, going down from Z: or the last available letter), and popd to climb back up the chain. You should use a popd after you're done because on some OS's (XP I think, but not Windows 2000), the drive letter will stay mapped after you exit the command line window. You could have your program watch for drive letters create while CMD windows are open and unmap them when no CMD windows exist. Just a thought. If you need authentication, you can use something like this first, which will get you access to all shares on the remote machine to which you have access... Run(@comspec & ' /c net use \\remotemachine\IPC$ ' & $password & ' /user:' & $domain & "\" & $username & ' /persistent:no') and close the connection if you want with a... Run(@comspec & ' /c net use \\remotemachine\IPC$ /del /y') Of course, you'd have to check for a '\\' in the $path to know it's a UNC, then split the remote machine name from that UNC for the net use command. Also, the '/y' only works on Windows 2000 and above. Edited December 6, 2005 by c0deWorm My UDFs: ExitCodes
GaryFrost Posted December 6, 2005 Posted December 6, 2005 Quote You should use a popd after you're done because on some OS's (XP I think, but not Windows 2000), the drive letter will stay mapped after you exit the command line window.XP Pro SP2 un-maps drive when closing command window SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Gigglestick Posted December 6, 2005 Posted December 6, 2005 gafrost said: XP Pro SP2 un-maps drive when closing command windowI just checked and Windows 2000 SP4 unmaps also. I don't remember which OS/SP-level didn't unmap, but there is at least one, so it's best IMO to plan for it. My UDFs: ExitCodes
Koder Posted December 7, 2005 Posted December 7, 2005 Good idea! A CMD hotkey should be mandatory! AutoIt hotkeys can interfere with other programs so I just use start menu hotkeys. This script puts a hotkey onto the default shortcut for these apps. It only runs once with no need to leave an AutoIt app running. ; ; Hot keys on shortcuts ; dim $a_Lnks[5][2] ; DOS Ctrl+Alt+D $a_Lnks[0][0] = @StartMenuDir & "\Programs\Accessories\Command Prompt.lnk" $a_Lnks[0][1] = "^!d" ; Notepad Ctrl+Alt+N $a_Lnks[1][0] = @StartMenuDir & "\Programs\Accessories\Notepad.lnk" $a_Lnks[1][1] = "^!n" ; Wordpad Ctrl+Alt+W $a_Lnks[2][0] = @StartMenuCommonDir & "\Programs\Accessories\WordPad.lnk" $a_Lnks[2][1] = "^!w" ; Calulator Ctrl+Alt+Shift+3 $a_Lnks[3][0] = @StartMenuCommonDir & "\Programs\Accessories\Calculator.lnk" $a_Lnks[3][1] = "^!+3" ; Paint Ctrl+Alt+P $a_Lnks[4][0] = @StartMenuCommonDir & "\Programs\Accessories\Paint.lnk" $a_Lnks[4][1] = "^!p" For $i = 0 to ubound($a_Lnks, 1) - 1 If FileExists($a_Lnks[$i][0]) == 1 then $det = FileGetShortcut($a_Lnks[$i][0]) If StringInStr($det[3],"-HK") == 0 then; Skip shortcuts that have already been modified FIleCopy($a_Lnks[$i][0], $a_Lnks[$i][0] & ".bak", 0) FileSetAttrib($a_Lnks[$i][0] & ".bak", "+H") FileCreateShortcut($det[0],$a_Lnks[$i][0], $det[1], $det[2], $det[3] & "-HK", $det[4], $a_Lnks[$i][1], $det[5], $det[6]) EndIf EndIf Next I also have a context menu for folders. This will open a DOS prompt, even to UNC paths using pushd. ; Open a Command Prompt to current folder RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd", "", "REG_SZ", "Open CMD Here") ; This will open the command prompt on UNC shares RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd\command", "", "REG_SZ", 'cmd.exe /k "pushd %L"')
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