hatchetman Posted May 20, 2005 Posted May 20, 2005 I am trying to send some text to the dos window while it is minimized (or the PC is locked) via ControlSend. The problem is that my message I need to send is mixed case and contains parentheses. The issue is that the text getting sent to the window is incorrect For example if I send (Hello) It comes out as 9hello0 no capitals, and no () I have tried various combinations of {SHIFT up} {SHIFTUP} ... etc. With no luck. Please help me out and provide examples. I am not interested in a solution that uses window activation or the send function. Since they are not an option for me. Thanks in advance!
Ejoc Posted May 21, 2005 Posted May 21, 2005 (edited) This works for raw mode, it sends "(Test)" not "9test0", have to think about making it support ctrl & other such things, probably can just do a stringreplace. _ControlSend("Command Prompt","","(Test)") Func _ControlSend($title,$text,$string) Local $hwnd,$i If IsString($title) Then $hwnd = wingethandle($title,$text) Else $hwnd = $title EndIf $string = StringReplace($string,"{enter}",CHR(0xd)) $string = StringReplace($string,"{space}"," ") For $i = 1 To StringLen($string) DllCall("user32.dll","long","SendMessage",_ "hwnd",$hwnd,_ "int",0x0102,_ "int",ASC(StringMid($string,$i,1)),_ "int",0) Next EndFunc Edited May 21, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
herewasplato Posted May 21, 2005 Posted May 21, 2005 @hatchetman You did not mention if you are using the flag with ControlSend "flag = 1, keys are sent raw." @Ejoc Why the UDF? I assume that it does something that ControlSend can not do. [size="1"][font="Arial"].[u].[/u][/font][/size]
GaryFrost Posted May 21, 2005 Posted May 21, 2005 check the bug reports SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
MHz Posted May 21, 2005 Posted May 21, 2005 ControlSend() does not support the dos window, as no ControlID is available ! Send() does send (hello) in raw mode.
hatchetman Posted May 21, 2005 Author Posted May 21, 2005 Sorry about not mentioning the ControlSend mode... I did try both modes with similar results. The above function does work well... Thanks, I didn't think about using the windows API. I can't fully test the app until Monday but I will let you know the final results then.
herewasplato Posted May 21, 2005 Posted May 21, 2005 @gafrost I searched the bug reports forum before I posted my question and did not come up with the thread that I came up with today when I repeated the search. That makes me wonder what I could have used as a search string. Today's search was just my "normal" copy/paste of the function of interest, in this case - ControlSend, and a very long thread was top of the list... anyway, thanks for your work on this. @Ejoc Thanks for the UDF. I knew there had to be a reason for it... quite a few it seems. I just could not think of them at the moment. @MHz No control ID in a DOS window - of course! The most obvious reason of all and I forgot it. @everyone, Thanks for tolerating my senility on this one. Once I saw that bug thread on ControlSend, I remembered reading some of the earlier posts about it; in particular, the post where Larry states, "is not a workaround, it is the answer...". I've stolen that line for use at work. later [size="1"][font="Arial"].[u].[/u][/font][/size]
jpm Posted May 21, 2005 Posted May 21, 2005 @herewasplato no "senility" at all just put a complete script repoducing your problem. I amnot sure you did'nt find a bug but to be for sure put the entire script repoducing what you experience. It is still true reading other thread that some Controlsend does not react as other sending the same kind of data. I am not sure we can make all equivalent sending acting the same due to the way AutoIt has to simulate the keyboard stroke. We do our best but !!!
herewasplato Posted May 23, 2005 Posted May 23, 2005 @herewasplatono "senility" at all just put a complete script repoducing your problem.<{POST_SNAPBACK}>Actually, I've been very lucky.ControlSend has done everything that I've asked it to do.I was claiming senility for asking Ejoc "Why the UDF?" and for suggesting to hatchetman that just setting the flag on ControlSend might work. But as MHz pointed out - DOS window - no ControlID!Thanks for all that you guys do. [size="1"][font="Arial"].[u].[/u][/font][/size]
Ejoc Posted May 23, 2005 Posted May 23, 2005 Why the UDF? because ControlSend wont send ( to a DOS window, the UDF will... Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
hatchetman Posted May 23, 2005 Author Posted May 23, 2005 Well, the function above works great in when the cmd window is minimized or behind other windows but... If the screen is locked all i get is a random partial message. For example if the message was: I Love AutoIt (Because It's so cool!) I might get: le AI eca's oco) It is a subset of the intended message... Any ideas?
Blue_Drache Posted May 23, 2005 Posted May 23, 2005 Well, the function above works great in when the cmd window is minimized or behind other windows but...If the screen is locked all i get is a random partial message. For example if the message was:I Love AutoIt (Because It's so cool!)I might get:le AI eca's oco)It is a subset of the intended message... Any ideas?<{POST_SNAPBACK}>Locking the workstation is dropping the proverbial "Iron Curtain" on it. From what I understand, you were lucky to even get that. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
hatchetman Posted May 23, 2005 Author Posted May 23, 2005 Locking the workstation is dropping the proverbial "Iron Curtain" on it. From what I understand, you were lucky to even get that.<{POST_SNAPBACK}>Very funny.... So there is no hope! That's too bad. Conflicting interests of automation and system security.The true goal of this little exercise is to remotely stop a service running on another windows machine. I was using telnet with the "net stop" command but since the system must be locked is there another way that I can stop a service? DLL call perhaps?
MHz Posted May 24, 2005 Posted May 24, 2005 Simplier ways to stop a service. expandcollapse popupsc.exe DESCRIPTION: SC is a command line program used for communicating with the NT Service Controller and services. USAGE: sc <server> [command] [service name] <option1> <option2>... The option <server> has the form "\\ServerName" Further help on commands can be obtained by typing: "sc [command]" Commands: query-----------Queries the status for a service, or enumerates the status for types of services. queryex---------Queries the extended status for a service, or enumerates the status for types of services. start-----------Starts a service. pause-----------Sends a PAUSE control request to a service. interrogate-----Sends an INTERROGATE control request to a service. continue--------Sends a CONTINUE control request to a service. stop------------Sends a STOP request to a service. config----------Changes the configuration of a service (persistant). description-----Changes the description of a service. failure---------Changes the actions taken by a service upon failure. qc--------------Queries the configuration information for a service. qdescription----Queries the description for a service. qfailure--------Queries the actions taken by a service upon failure. delete----------Deletes a service (from the registry). create----------Creates a service. (adds it to the registry). control---------Sends a control to a service. sdshow----------Displays a service's security descriptor. sdset-----------Sets a service's security descriptor. GetDisplayName--Gets the DisplayName for a service. GetKeyName------Gets the ServiceKeyName for a service. EnumDepend------Enumerates Service Dependencies. The following commands don't require a service name: sc <server> <command> <option> boot------------(ok | bad) Indicates whether the last boot should be saved as the last-known-good boot configuration Lock------------Locks the Service Database QueryLock-------Queries the LockStatus for the SCManager Database EXAMPLE: sc start MyService
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