 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
mandiom
Joined: 03 Mar 2008 Posts: 34
|
Posted: Thu Apr 10, 2008 7:57 pm Post subject: Cmd Help |
|
|
Hello guys. I need some help both with AHK and with a DOS command
The following command merges "files.rar" and "image.jpg" (it hides the files in the image and the rar file is opened only if someone tries to open the image (a perfect jpg as far as Windows is concerned) with WinRar or something similar:
COPY /B image.jpg + files.rar newimage.jpg
The new image with the files is named "newimage.jpg"
Obviously, the files must be where cmd is "run from" (if you fire it up while you are in the desktop, the files should be in the desktop). Alternatively, you can move your way to the right place.
My problem is the following:
I am trying to make a gui for the above function. I have two edits where file1 and file2 (image) are dropped. Then, it runs cmd and sends the above above command, but instead of "files.rar" and "image.jpg" it puts the filepaths of the files. The problem is that the command does not seem to work with the entire filepaths. Any ideas?
Also, is there a better way to execute DOS commands rather than having to run command prompt and send the input?
Thanks in advance!  |
|
| Back to top |
|
 |
TheIrishThug
Joined: 19 Mar 2006 Posts: 381
|
Posted: Thu Apr 10, 2008 8:01 pm Post subject: |
|
|
Maybe it is due to spaces in the full path. Try this | Code: | | COPY /B image.jpg + "c:\some\path\files.rar" "c:\some\other\path\newimage.jpg" |
|
|
| Back to top |
|
 |
mandiom
Joined: 03 Mar 2008 Posts: 34
|
Posted: Thu Apr 10, 2008 10:03 pm Post subject: |
|
|
Oh my God! Quotation marks!!!! It works beautifully now! thank you so much
No, to make it prettier, is there a way to execute that command without showing the cmd window? Or, is there a way to send input to a hidden window? |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Fri Apr 11, 2008 4:12 am Post subject: |
|
|
| mandiom wrote: | | is there a way to execute that command without showing the cmd window? |
| AHK Help File wrote: | | Run, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID] |
_________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
mandiom
Joined: 03 Mar 2008 Posts: 34
|
Posted: Fri Apr 11, 2008 3:20 pm Post subject: |
|
|
Yes, I know about that However, if it is hidden, anything sent with the "Send" command will not go to the command prompt, right? Any way to send input to a specific (hidden) window? |
|
| Back to top |
|
 |
TheIrishThug
Joined: 19 Mar 2006 Posts: 381
|
Posted: Fri Apr 11, 2008 3:37 pm Post subject: |
|
|
| You can Run all the commands using ComSpec instead of Send input to the cmd. |
|
| Back to top |
|
 |
ChalamiuS
Joined: 04 Jun 2006 Posts: 189
|
Posted: Fri Apr 11, 2008 4:04 pm Post subject: |
|
|
You could use ControlSend too
| mandiom wrote: | | Also, is there a better way to execute DOS commands rather than having to run command prompt and send the input? |
Yes
| Code: |
Run,%ComSpec% /c "Commands" ;Add ,,Hide to hide it too :)
|
_________________ IRC Mibbit
Last edited by ChalamiuS on Fri Apr 11, 2008 4:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1185 Location: switzerland
|
Posted: Fri Apr 11, 2008 4:08 pm Post subject: |
|
|
examples
| Code: | ;---- 1st example minimized
Run,%comspec% /k, , Min UseErrorLevel, CMDPID
WinWait, ahk_pid %CMDPID%
ControlSend, ,dir{Enter}, ahk_pid %CMDPID%
return
; 2nd example hidden -------
mycommand=dir
Run, %comspec% /c %mycommand%, ,Hide
return
|
|
|
| Back to top |
|
 |
mandiom
Joined: 03 Mar 2008 Posts: 34
|
Posted: Sun Apr 13, 2008 8:08 pm Post subject: |
|
|
Thanks for the replies guys
Since I'm pretty new, I was will focus on the simplest line of code I saw:
| Code: | | Run,%ComSpec% /c "Commands" ;Add ,,Hide to hide it too :) |
So, isn't %ComSpec% a variable? Does the command just work with that syntax and I only change whatever is in "Commands" ?
And the how do I close cmd.exe beside winclose?
Thank again  |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1185 Location: switzerland
|
Posted: Sun Apr 13, 2008 8:50 pm Post subject: |
|
|
%comspec% is for cmd.exe (or command.exe )
examples:
| Quote: |
command1=dir
command2=ver
command3=charmap
Run, %comspec% /c %command1%, ,Hide ;see nothing
Run, %comspec% /k %command1%
Runwait, %comspec% /k %command2% ;waits until close
Run, %comspec% /k %command3%
Run, %comspec% /k %command1%
|
to close DOS window with GUI see command process
| Code: | STREAMRIPPER =c:\streamripper\streamripper.exe
run,%COMSPEC% /K %streamripper% http://collectors.no-ip.org:8000 --xs_padding=6000:8000 -t -d _STREAM
Process,wait,streamripper.exe
PID2 = %ErrorLevel%
return
Guiclose:
process,close,%PID2%
exitapp
|
|
|
| Back to top |
|
 |
mandiom
Joined: 03 Mar 2008 Posts: 34
|
Posted: Sun Apr 13, 2008 9:14 pm Post subject: |
|
|
The command I want to send is the following:
| Code: | | COPY /B{Space}"%path2%"{Space}+{Space}"%path1%"{Space}"A_ScriptDir%\newimage.jpg"{Enter} |
It does not seem to work when I put
| Code: |
Command1 = COPY /B{Space}"%path2%"{Space}+{Space}"%path1%"{Space} |
and then
| Code: | | Run, %comspec% /c %Command1%, , ;Hide see nothing |
EDIT: Never mind. I think it's ok now! Thank you so much!
The closing method you mentioned looks a bit complicated... Also, it seems to be connecting to a website, and I'm not too fond of that (if it isn't please pardon my ignorance). Is it still ok if I leave
?? |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1185 Location: switzerland
|
Posted: Mon Apr 14, 2008 7:46 am Post subject: |
|
|
example above closes the right process depending PID when quit ahk script
some examples
example below closes DOS not depending from PID
| Code: | ;WinClose [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]
DetectHiddenWindows, ON
SetTitleMatchMode, 2
winclose,cmd.exe
exitapp
|
opens DOS window folder from activated window ctrl+alt+d
| Code: | ^!d::
ID := WinExist("A")
WinGetClass, Class, ahk_id %ID%
ControlGetText,ePath, Edit1, ahk_id %ID%
Run,%comspec% /k, %epath%
return
|
opens ahk helpfile ctrl+alt+h
| Code: |
^!h::
run,%A_programfiles%\AutoHotkey\AutoHotkey.chm
return
|
copy with DOS or Autohotkey command filecopy
| Code: | RU1=c:\test1
RU2=c:\test2
;filecopy,%RU1%\*.mp3,%RU2%
runwait,%comspec% /c xcopy %RU1%\*.mp3 %RU2% ;/c DOS window will close when xcopy finished
msgbox, 262192, COPY all MP3 from %RU1% to %RU2%,Copied all mp3 files from %RU1% to %RU2% is now finished
return
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|