AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cmd window freezes after running a command

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
rocknrollgolfer



Joined: 03 Oct 2009
Posts: 8

PostPosted: Sat Oct 03, 2009 1:36 pm    Post subject: cmd window freezes after running a command Reply with quote

I am trying to run this code:
Code:
sWindump = windump.exe -A -q -i 2 -p >>D:\bumblebee\windump.txt

Run, %comspec% /k

ControlSend,,%sWindump%`n,ahk_Class ConsoleWindowClass
sleep, 3000
ControlSend,,^c,ahk_Class ConsoleWindowClass


What is supposed to happen is the windump program starts, and i need to close it later using a CTRL-C command. If windump is not closed with CTRL-C it does not output what it's seen (packets).

If I start windump manually outside autohotkey it works fine. And I can send the CTRL-C using autohotkey controlsend and kill it clean.

If I start windump using the autohotkey comspec command, after the windump command executes the cmd window is "frozen" and won't accept anymore controlsends. I can't figure out why. Even if I manually press CTRL-C at the cmd window started by autohotkey, it is frozen. It only freezes after the windump line starts. I'm guessing something in comspec is not right. Maybe a switch I need, or quotes.
Back to top
View user's profile Send private message
!Guest
Guest





PostPosted: Sat Oct 03, 2009 2:09 pm    Post subject: Reply with quote

Code:
Run, %comspec% /k

This /k means KEEP open.Try with /C (c=close)
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Sat Oct 03, 2009 2:13 pm    Post subject: Reply with quote

you might be better off using CMDRet
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
Z_Gecko
Guest





PostPosted: Sat Oct 03, 2009 3:03 pm    Post subject: Reply with quote

why using comspec at all? try:
Code:
sWindump = windump.exe -A -q -i 2 -p >>D:\bumblebee\windump.txt
Run, %sWindump%
Back to top
rocknrollgolfer



Joined: 03 Oct 2009
Posts: 8

PostPosted: Sat Oct 03, 2009 8:23 pm    Post subject: Reply with quote

CMDret seemed like a good idea so I've implemented that. It works great but something on my command line is still breaking my command. It is in the section of the command that has the brackets. Something in that part is not executing correctly or being passed on correctly. I tried putting the command line in a batch file and it still doesn't work. Although the batch file works fine if run outside of autohotkey. Very strange still.

Code:
windump.exe -A -q -i 2 -p (udp[17:1] == 0x2b or udp[22:1] == 0x64)


Something with the brackets or maybe == sign does not translate when run through autohotkey. If I omit everything between the brackets, the code runs perfect. I've tried escaping them all. The command looks fine when I inspect the variables. The command also starts and runs and does not syntax error. I'm assuming autohotkey or CMDret does something that alters the special characters when it's passed into a dos box. I'll do some more testing but if anyone has any suggestions I'll try them out.

Thank you all for your suggestions so far. I've tried them all. I also never heard of CMDret. Nice bit of code.
Back to top
View user's profile Send private message
rocknrollgolfer



Joined: 03 Oct 2009
Posts: 8

PostPosted: Mon Oct 05, 2009 3:51 pm    Post subject: Reply with quote

Just a note that I never resolved this problem. I did a workaround by running the windump command manually in a batch file (ie:autohotkey does not start it, I do) and leaving the rest of the code in autohotkey. Autohotkey still communicates with the cmd window as needed, but I am unable to start it via autohotkey code.

It's good enough for what I need to do.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group