Sign in to follow this  
Followers 0
kania

need help for send a certain string to a window by using ControlSend

5 posts in this topic

#1 ·  Posted (edited)

hi all,

here is my code

HotKeySet("{PAUSE}", "EndScript")
while 1
    sleep(1000)
;if you wnat to test this script please replace the [cmd.exe] with your program's wintitle
    ControlSend("cmd.exe","","","aBck))")
wend
Func EndScript() 
    Exit 
EndFunc

its quite simple but it dosen't work in the right way everytime though.in most case,the cmd.exe window would NOT get the exact string but something as "abck00" or "aBCk0)" or others.

i have figure out how this happen:coz the ControlSend work as simulating keyboard press,when it meet a UPCASE char in the string,it hold down the shift and simulate press the char key,but sometime it dosen't release the shift before it press the next key,or sometime it press down shift before 1 char of the UPCASE char.

so as the example code,the string is "aBck))",when it meet the first ")",it press the shift down and then press ")/0" key then release the shift,but it dosen't press the shift in time when it meet the second ")",so it just press ")/0" without the shift down,so the cmd.exe recieve a string as "aBck)0".

i have try the ControlSend flag parameter and SendKeyDelay and SendKeyDownDelay,it still don't 100% work.i think if i translat all the string into a ascii code then send them one by one may work,but in my script the string is quite long and solve the problem in this way may make my codes unreadable.

would any one have any idea?

any further info is appreciate.

Edited by kania

Share this post


Link to post
Share on other sites



Try using just Send() with the cmd window. PID = Run()/ProcessWait(PID)/WinWait(cmd.exe)/WinActivate(cmd.exe)/Send()


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

thx for your reply,SmOke_N

but i need ControlSend coz the target window is in background and i don't want to active it.

currently i trying the UDF _SendKeys(),but it seem that _SendKeys() ingore char CASE...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

thx for your reply,SmOke_N

but i need ControlSend coz the target window is in background and i don't want to active it.

currently i trying the UDF _SendKeys(),but it seem that _SendKeys() ingore char CASE...

search for _ControlSendPlus

The problem cannot be solve for application with no ControlID which is the case of cmd.exe.

You need to adapt the _ControlSendPlus to the keyboard you are using. :whistle:

Edited by jpm

Share this post


Link to post
Share on other sites

thx jpm,_ControlSendPlus work well.

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