Champak Posted October 23, 2006 Share Posted October 23, 2006 (edited) I'm sending a path to an install application. Problem is, sometimes the entire string is sent, most times it is not. I haven't come across this issue before, and I haven't found it in the search. Anyone tell me why or a workaround? The string being sent is $Root = "C:\Documents and Settings\TEST\Desktop\Setup\" ---------------------- Send($Root & "Corel Paint Shop vX\Paint Shop Pro install") It is usually crapping out around in and around "Settings". As I said, most times it is crapping out not all. Thanks Edited October 23, 2006 by Champak Link to comment Share on other sites More sharing options...
PaulIA Posted October 23, 2006 Share Posted October 23, 2006 Do you have your SendKeyDelay set to 0? Sometimes this can cause problems. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
gamerman2360 Posted October 23, 2006 Share Posted October 23, 2006 (edited) Does it cut off some of the beginning? If so, make sure the input control is selected before sending the text. If this is not the problem, you may need to include more information. If you want, you can look at the control functions to work directly with the control instead. (docs) The control function you want to use is probably ControlSetText(). Edited October 23, 2006 by gamerman2360 Link to comment Share on other sites More sharing options...
Champak Posted October 23, 2006 Author Share Posted October 23, 2006 Thanks both of you. I figured out what is happening, but don't know how to solve it. It is not the actual send function that is messing up, but the window it self wont stay "active". I have noticed this in the past with installing other applications by hand but never really thought too much of it except bad programming on the creators side. But I have installed this before by hand and never lost the window being active without me clicking on another window, but using the script, it is loosing focus, so I know it isn't with this installation file. Does anyone know what could be causing this? This is everything up to that point. $TitlePaintShop1 = "Corel Paint Shop Pro X - Installation Files - InstallShield Wizard" $TitlePaintShop2 = "Corel Paint Shop Pro X" Run($Root & "Corel Paint Shop vX\setup.exe") WinWait($TitlePaintShop1 ,"Location to Save Files") ControlClick($TitlePaintShop1, "Location to Save Files", "Button3") WinWait("Choose Folder" ,"Please select the installation folder") Send($Root & "Corel Paint Shop vX\Paint Shop Pro install") gamerman2360, thanks for that, never noticed it before, I was actually messing with controlsend. Link to comment Share on other sites More sharing options...
PaulIA Posted October 23, 2006 Share Posted October 23, 2006 Not sure if this is the problem, but WinWait only waits until the window exists. It does not wait until the window is active. If you're going to use WinWait, you might want to add WinActivate afterwards to make sure the window is activated. You might have better luck using ControlSend instead of Send. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Champak Posted October 23, 2006 Author Share Posted October 23, 2006 (edited) I was just about to edit that post to say, when I cut everything off after the ControlClick, the same thing happens, because the same thought dawned on me. So it doesn't seem to be the winwait. Edited October 23, 2006 by Champak Link to comment Share on other sites More sharing options...
PaulIA Posted October 23, 2006 Share Posted October 23, 2006 I guess what I'm saying is that I don't know what is stealing the focus, but WinActivate will get the focus back to the correct control before you send the text. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Champak Posted October 23, 2006 Author Share Posted October 23, 2006 Yeah, I tried that already too, but that was no help because the focus keeps going away. And it can't be a an app/system running in the background (I don't think) because when I shut down the script, and do it manually, I don't lose focus at all. Also, when I turn the script in to an .exe, the same lost focus thing happens. I'm just stuck. Link to comment Share on other sites More sharing options...
herewasplato Posted October 23, 2006 Share Posted October 23, 2006 ...I'm just stuck...Did you try ControlSetText as suggested above? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Champak Posted October 24, 2006 Author Share Posted October 24, 2006 I actually took it and put it to other areas, but in part, yes I did try it with the same results. Link to comment Share on other sites More sharing options...
herewasplato Posted October 24, 2006 Share Posted October 24, 2006 (edited) I actually took it and put it to other areas, but in part, yes I did try it with the same results.Using ControlFocus then ControlSetText followed by a ControlGetText to verify the info in the field. That should work. You can loop that until it works. I cannot imagine what could be going on with that window or windows.Edit: The following is in the help file under ControlClick, but I'm not sure if it will help before a ControlSetText:RemarksThe control might first need to be given focus with the ControlFocus command. Edited October 24, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 24, 2006 Moderators Share Posted October 24, 2006 Is this a child window? You may need Opt('WinSearchChildren', 1) at the top of your script, but what herewasplato said may work, if not use both. 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. Link to comment Share on other sites More sharing options...
cprowse Posted October 24, 2006 Share Posted October 24, 2006 Just a thought - if it gets half way in and then falls over, the focus must be being lost during the key sends. How would windows handle a paste from the clipboard? I'm thinking clipput() the text onto the clipboard, select the control, and then clipget() to paste all of the text - maybe windows will make sure it either all goes in, or nothing at all? Kind Regards, -Chris Link to comment Share on other sites More sharing options...
Champak Posted October 26, 2006 Author Share Posted October 26, 2006 It turns out controlsettext does work. The lack of sleep wouldn't allow me to see that there was a change in the path set up during install.....or maybe it just worked the couple of times I tried iand will mess up down the line when I do it again....who knows, time will tell and I'm too tired and fed up to keep testing it out right now. But it still leaves the question of why the window was losing focus in the first place anyway. One of life's mysteries. cprowse, I tried that before I came here, it pretty much behaved like send. Thanks. Link to comment Share on other sites More sharing options...
herewasplato Posted October 29, 2006 Share Posted October 29, 2006 ...But it still leaves the question of why the window was losing focus in the first place anyway. One of life's mysteries...So it only loses focus when your code runs and not when you do it manually... you might want to post your entire code (as an attachment) and someone might see the answer... but glad to hear that ControlSetText worked for you. ...cprowse, I tried that before I came here, it pretty much behaved like send...If you ever want to use the Windows clipboard to send info "quickly", try this little test script from inside SciTE:Opt("SendKeyDelay", 300) ClipPut(";some text") Send("^{END}") Send(ClipGet()) ;slow Send("^v") ;fast ; ; ;...but ControlSetText should be faster. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
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