Jump to content

Recommended Posts

Posted

Hey there,

I've written a script I use at work all day long to do a bunch of data entry - which works great. However I am now just basically sitting at my desk waiting for the script to finish each time I run it, and would prefer to be able to do other work on my PC. The problem is of course the window must have focus in order for the send to work.

Is there a way to send keys without having to keep the focus on the window itself?

Also a small peice of relevant information is the window I am sending all this data to is a DOS program, but I don't know if that helps at all.

Cheers!

-Chad Stout

Posted

You could try using StdInWrite, may work.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

  BigDod said:

You could try using StdInWrite, may work.

Hi, or

maybe ControlSend() if you know the title of the window. I guess, getting ControlId could be a bit specific.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

  th.meger said:

Hi, or

maybe ControlSend() if you know the title of the window. I guess, getting ControlId could be a bit specific.

So long,

Mega

I do not think that a dos window has a ControlId to send anything to.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

  BigDod said:

I do not think that a dos window has a ControlId to send anything to.

Hi,

I know as I mentioned above, but this should to the trick.

ControlSend("C:\WINNT\System32\cmd.exe", "", "", "Hello")

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted (edited)

  chad.stout said:

......is a DOS program...

May not be a DOS window.

Edit: I use ControlSend with several DOS programs...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

  th.meger said:

Hi, or

maybe ControlSend() if you know the title of the window. I guess, getting ControlId could be a bit specific.

So long,

Mega

The problem with ControlSend() is simpley that there is no control! It is a DOS prompt (more specifically - an emulated prompt seeing as it's an XP machine).

I'm not familar with StdInWrite... I'll have to look into that one.

Thanks!

-Chad

BTW... wow - I'm impressed how fast this thing got responded to! :P

Posted

  herewasplato said:

May not be a DOS window.

Edit: I use ControlSend with several DOS programs...

can't you use run to run commands from a dos window?

Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)
Posted (edited)

  th.meger said:
Hi,

I know as I mentioned above, but this should to the trick.

ControlSend("C:\WINNT\System32\cmd.exe", "", "", "Hello")
oÝ÷ Ù*%¢xz¿ªê-xíz·¬¶)àêÞÆÙ¨­ç(uëh¦º/{*.®"Ö®¶­se'VâgV÷C´3¢b3#µtäDõu2b3#·77FVÓ3"b3#¶6ÖBæWRgV÷C²¥våvBgV÷C´3¢b3#µtäDõu2b3#·77FVÓ3"b3#¶6ÖBæWRgV÷C²¥'VâgV÷C¶æ÷FWBgV÷C²¥våvBgV÷CµVçFFÆVBÒæ÷FWBgV÷C²¥vä7FfFRgV÷CµVçFFÆVBÒæ÷FWBgV÷C²¥våvD7FfRgV÷CµVçFFÆVBÒæ÷FWBgV÷C²¤6öçG&öÅ6VæBgV÷C´3¢b3#µtäDõu2b3#·77FVÓ3"b3#¶6ÖBæWRgV÷C²ÂgV÷C²gV÷C²ÂgV÷C²gV÷C²ÂgV÷C´VÆÆògV÷C²
Edit: It does indeed send to a window not in focus.
Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted (edited)

  Paulie said:

can't you use run to run commands from a dos window?

Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)
It's not a command line program, it's a command prompt - slight difference there :P

EDIT:

Also I tried the

ControlSend("blahblah/cmd.exe","","","text")

It works, but only when it has focus.

Edited by chad.stout
Posted
  chad.stout said:

It's not a command line program, it's a command prompt - slight difference there :P

Ahhh... Sorry :">
Posted (edited)

  chad.stout said:

It's not a command line program, it's a command prompt - slight difference there :P

So it is in a DOS window and not just a DOS program... then try the code that I posted via th.meger's suggestion.

Edit1: ...but the STD IN/OUT is the way to go - if it works for the app in question.

Edit2: as you can see from this post

http://www.autoitscript.com/forum/index.ph...mp;#entry173643

some apps are just too wierd to work with the STD IN/OUT method.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

  herewasplato said:

So it is in a DOS window and not just a DOS program... then try the code that I posted via th.meger's suggestion.

Edit1: ...but the STD IN/OUT is the way to go - if it works for the app in question.

Edit2: as you can see from this post

http://www.autoitscript.com/forum/index.ph...mp;#entry173643

some apps are just too wierd to work with the STD IN/OUT method.

I'm guessing STD In/Out isn't going to work for my problem, as it's a secured connection started by running an ActiveX control from a website to launch the DOS application - there really is no way for me to manually open the program and bypass the website.

Thanks for the help anyways!

-Chad

Posted

  chad.stout said:

I'm guessing STD In/Out isn't going to work for my problem, as it's a secured connection started by running an ActiveX control from a website to launch the DOS application - there really is no way for me to manually open the program and bypass the website.

Thanks for the help anyways!

-Chad

Since its a website your talking about, you might want to look at some IE.au3 functions to see if that can

solve your problem. Also, can you supply some code so we can see how this all gets started?

ViM

Posted (edited)

  vim said:

Since its a website your talking about, you might want to look at some IE.au3 functions to see if that can

solve your problem. Also, can you supply some code so we can see how this all gets started?

ViM

At the moment I manually start everything, but I'll check into the IE.au3 (I assume it must be used in conjunction with the latests Beta release?)

Anyways, here's my current script (I've been hacking this thing together over the last couple of weeks, so it's not all that pretty :P)

Discover_Re.au3

Edited by chad.stout
Posted

Wow, alot of Sends that you do. Some tips are in the helpfile for optimizing Sends.

For example, your method

Send('{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}')
Posted

Yeah, I know you didn't ask about this, but I would probably replace statements like this:

Case $formattedState = "al" Or $formattedState = "az" Or $formattedState = "ca" Or _
     $formattedState = "co" Or $formattedState = "ct" Or $formattedState = "de" Or _
     $formattedState = "fl" Or $formattedState = "ia" Or $formattedState = "ks" Or _
     $formattedState = "la" Or $formattedState = "mi" Or $formattedState = "mo" Or _
     $formattedState = "nj" Or $formattedState = "nm" Or $formattedState = "nd" Or _
     $formattedState = "oh" Or $formattedState = "or" Or $formattedState = "sd" Or _
     $formattedState = "tx" Or $formattedState = "ut" Or $formattedState = "wa" Or _
     $formattedState = "wa"oÝ÷ Û­Øb±«­¢+Ù
ÍMÑÉ¥¹%¹MÑÈ ÅÕ½Ðí°±è±±¼±Ð±±°±¥±­Ì±±±µ¤±µ¼±¹¨±µ¸±¹±½ ±½È±Í±Ñà±ÕбÝÅÕ½Ðì°ÀÌØí½ÉµÑÑMÑÑ

which works if you are sure that you will never get a comma in $formattedState.

I like the way your columns line up for a lot of stuff, though.

BlueBearrOddly enough, this is what I do for fun.
Posted

Thanks for those tips - I do need to optimize this script (which really is just 2000 lines of sends :nuke:)

I am learning AutoIt as I build this project, so yea.. some of it is not going to be very elegant :P

Thanks,

-Chad

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