Jump to content

Recommended Posts

Posted

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!!

Posted

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.

Posted

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
Posted

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

Posted

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" )
Posted (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 by tbird2340
Posted

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)
Posted (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 by czardas
Posted

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
Posted (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 by taietel
Posted

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.

Posted

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)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...