tbird2340 Posted October 9, 2010 Posted October 9, 2010 Here is what I do from inside Windows but want to get this in an EXE to accomplish.. 1. Enter cmd prompt. 2. Type: MODE COM1 96,n,8,1 3. On the next line type: TYPE CON>COM1 4. After that, on the next line hold down Ctrl and hit G. Then, hit Enter. That's it.. Any takers? Thanks!!
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 So with 25 views and no replies should I take it as it's not easy or not possible?
taietel Posted October 10, 2010 Posted October 10, 2010 So with 25 views and no replies ...tbird2340, that's because you didn't even tried!Read in the help file about these functions: Run, ShellExecute, Sleep, Send... then try for yourself. AFTER that, post your nonworking script and you will get help.M.I. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
PsaltyDS Posted October 10, 2010 Posted October 10, 2010 Any takers?Takers? That's not how it works around here. We'll help you learn to do it yourself. The task is quite simple and you won't have any problem doing it after learning some basics. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 Takers? That's not how it works around here. We'll help you learn to do it yourself. The task is quite simple and you won't have any problem doing it after learning some basics.Geez fellas.. If it is something incredibly easy for experienced users I just figured someone could whip it up real quick.. I'm not a coder and trying to learn languages is tough for me..I'll dig into the documentation (some more) and try to get something together.Thanks
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 OK.. I'm trying it out and stuck.. This works: Opt("WinTitleMatchMode", 2) Run("notepad.exe") WinWait("[TITLE:Notepad]") ControlSetText("[TITLE:Notepad]", "", "Edit1", "New Text Here" ) This opens cmd prompt but no text is entered: Run("cmd.exe") WinWait("[TITLE:cmd]") ControlSetText("[TITLE:cmd]", "", "Edit1", "New Text Here" )
czardas Posted October 10, 2010 Posted October 10, 2010 (edited) There's may be a better way to do this, but have you tried using the Send function? Hmm, it doesn't seem to be working. Edited October 10, 2010 by czardas operator64Â Â ArrayWorkshop
czardas Posted October 10, 2010 Posted October 10, 2010 (edited) How about this? ShellExecute("C:\Windows\system32\cmd.exe") Sleep(500) Send("Hello World") Edited October 10, 2010 by czardas operator64Â Â ArrayWorkshop
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 (edited) OK.. I got it working but wondering if there is some better way to do it.. Run("cmd.exe") Send("MODE COM1 96,n,8,1{ENTER}") Send("TYPE CON>COM1{ENTER}") Send("^G{ENTER}") I want to make sure it sends the text to the correct window but the below isn't working: Run("cmd.exe") ControlSend("[CLASS:ConsoleWindowClass]", "", "Edit1", "MODE COM1 96,n,8,1{ENTER}") I also want it to be hidden and this isn't working for me: Run("cmd.exe") WinSetState("[CLASS:ConsoleWindowClass]", "", @SW_HIDE) Thanks Edited October 10, 2010 by tbird2340
czardas Posted October 10, 2010 Posted October 10, 2010 (edited) If you hide the window, I don't think you will be able to write to it using the Send function. Why does the window need to be hidden? Maybe this: ShellExecute ( "C:\Windows\system32\cmd.exe", "", "", "", @SW_HIDE) Sleep(500) ControlSend("[CLASS:ConsoleWindowClass]", "", "", "Hello World") Edited October 10, 2010 by czardas operator64Â Â ArrayWorkshop
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 If you hide the window, I don't think you will be able to write to it using the Send function. Why does the window need to be hidden? Maybe this: ShellExecute ( "C:\Windows\system32\cmd.exe", "", "", "", @SW_HIDE) Sleep(500) ControlSend("[CLASS:ConsoleWindowClass]", "", "", "Hello World") When I use that the text doesn't get added.. ShellExecute ( "C:\Windows\system32\cmd.exe", "", "", "", @SW_HIDE) Sleep(500) ControlSend("[CLASS:ConsoleWindowClass]", "", "", "Hello World") Sleep(500) ShellExecute ( "C:\Windows\system32\cmd.exe", "", "", "", @SW_SHOW)
czardas Posted October 10, 2010 Posted October 10, 2010 (edited) But you are running two instances of the same program. The first instance is still hidden, and I believe that it does contain the text. That window is probably still running, only you can't see it. See below: ShellExecute ("C:\Windows\system32\cmd.exe", "", "", "", @SW_HIDE) Sleep(500) ControlSend("[CLASS:ConsoleWindowClass]", "", "", "Hello World") Sleep(1000) WinSetState ("[CLASS:ConsoleWindowClass]", "", @SW_SHOW) Edited October 10, 2010 by czardas operator64Â Â ArrayWorkshop
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 But you are running two instances of the same program. The first instance is still hidden, and I believe that it does contain the text. That window is probably still running, only you can't see it. See below: ShellExecute ("C:\Windows\system32\cmd.exe", "", "", "", @SW_HIDE) Sleep(500) ControlSend("[CLASS:ConsoleWindowClass]", "", "", "Hello World") Sleep(1000) WinSetState ("[CLASS:ConsoleWindowClass]", "", @SW_SHOW) Da! Didn't see that.. Thanks
czardas Posted October 10, 2010 Posted October 10, 2010 No problem. I am still wondering what you need this for. operator64Â Â ArrayWorkshop
Delta Posted October 10, 2010 Posted October 10, 2010 I really recommend using StdinWrite for this kind of thing. $cmd = Run("cmd.exe", @WindowsDir & "\system32\", @SW_HIDE, 1) $command = "Echo Hello World" StdinWrite($cmd, $command & @LF) [size="1"]Please stop confusing "how to" with "how do"[/size]
czardas Posted October 10, 2010 Posted October 10, 2010 I really recommend using StdinWrite for this kind of thing.I thought there would be a better method. I haven't used these functions before. Thanks! operator64Â Â ArrayWorkshop
taietel Posted October 10, 2010 Posted October 10, 2010 (edited) tbird2340, try this: ShellExecute("cmd.exe","","","open",@SW_HIDE) _WinWaitActivate("[CLASS:ConsoleWindowClass]","") Send("MODE COM1 96,n,8,1") Send("{ENTER}") Send("TYPE CON>COM1") Send("{ENTER}") Send("^g") Send("{ENTER}") Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc If I'm not mistaken, you try to send commands from the console to a modem? [edit] modem or other peripheral Edited October 10, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 This is for popping a cash drawer.. A client of mine switched softwares and his new software doesn't pop his cash drawer after completing a sale.. Doing those commands pops the drawer and the new software has a spot for entering an EXE to pop the drawer so that's what I'm doing.. I should probably kill the cmd.exe with WinKill after as well.. Thanks guys.
taietel Posted October 10, 2010 Posted October 10, 2010 (edited) or add this: Local $PID = ProcessExists("Excel.exe") If $PID Then ProcessClose($PID) [edit] bad formated text Edited October 10, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
tbird2340 Posted October 10, 2010 Author Posted October 10, 2010 So then use this for the complete task? ShellExecute("cmd.exe","","","open",@SW_HIDE) _WinWaitActivate("[CLASS:ConsoleWindowClass]","") Send("MODE COM1 96,n,8,1") Send("{ENTER}") Send("TYPE CON>COM1") Send("{ENTER}") Send("^g") Send("{ENTER}") Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc Local $PID = ProcessExists("Excel.exe") If $PID Then ProcessClose($PID)
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