Sign in to follow this  
Followers 0
tbird2340

Need script (EXE) help please.. Probably easy.

28 posts in this topic

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

Share this post


Link to post
Share on other sites



So with 25 views and no replies should I take it as it's not easy or not possible?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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" )

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#9 ·  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

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by czardas

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#12 ·  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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#17 ·  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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0