OxygenSky Posted January 25, 2011 Posted January 25, 2011 Hi there! I've using AutoIT for about few days, but already have some questions )))What i've got:Windows Server 2003. Compiled Delphi application using DCOM. No sources, EULA. An user connected by mstsc.exe /admin and have start an Delphi application(some server soft). User has priveleges of local administrator. The Console for application that we will speak below. I need to do some action in this application every day. So i need to write script that do this action automaticaly and in schedule.What i want:1) Run console application. (just Run(""). it's ok)2) Send password in authorization form. (done by ControlSend("window_title", "", "Edit2", "password{ENTER}"))3) Click the toolbar button or send the shortcut (Ctrl+H) sic. look at troubles.What are my troubles:1) if i could use ControlClick... But cant reach toolbar button. does anybody know how?2) if i could use ControlSend... But there are just magic things that i cant understand: i think that all trouble in {CTRL}/^ key, because all other keys are work - i tried Alt+F4 or F10(some action) and all of this work without problems. Of course just Send() work fine. AutoIT script is my second script, first was in VBScript that used SendKeys() - is like AutoIT.Send() proc.Thank you. Questions, comments, answers...PS: I've experimented today with AutoIT functions and my script almost works. there will be code tomorrow.
OxygenSky Posted January 26, 2011 Author Posted January 26, 2011 (edited) So? Nobody knows the trouble i've seen? =) Please let me understand how it works and what's the differnce between Send() and ControlSend() applying CTRL-button. so the code i promised: Run('Console') ;i added full path to windows PATH variable Sleep(5000) ;time for loading auth form ControlSend("auth window title", "", "TEdit2", "password{ENTER}") Sleep(15000) ;time for loading console main form $console="console main window title" $handle=WinGetHandle("classname=" & $console) ControlFocus($console, "", "TTreeView1") ;donno why, but trying to do something. Send works fine on active application with no focus. Sleep(1000) ;time for changing focus ControlSend($console, "", $handle, "^h") ;or ControlSend($console, "", $handle, "^H") ;or ControlClick($console, "", "TToolButton2") ;or $control=ControlGetHandle($console, "toolbar button caption", "") ControlClick($console, "", $control) ;but! ControlSend($console, "", $handle, "!{F4}");works very fine! Edited January 26, 2011 by OxygenSky
hench Posted January 26, 2011 Posted January 26, 2011 AutoIt works pretty bad with Delphi control Test each step, each line of your code pairing with Autoit Info Tool to be certain you got all the proper handle needed. Even so, this is hardly a guarantee...good luck!hench
OxygenSky Posted January 26, 2011 Author Posted January 26, 2011 (edited) I've completed the task. My script works fine and stable and tasked in schedule. but... i really donno why it works in that way, but works and stable. so i think that the problem was in focus in this strange application.result code:Run('Console') Sleep(5000) ControlSend("auth window title", "", "TEdit2", "password{ENTER}")) Sleep(15000) $console="main form window name" $handle=WinGetHandle("classname=" & $console) ;WinMenuSelectItem($console, "", "&Configuration", "&Devices") doesnt works =) Sleep(500) ControlSend("", "", "", "text", 0) ;i take it from AutoIT wiki. this command represent unstuck method for virtual keys. Thanks guys, wiki was really helpful ControlSend($console, "", $handle, "^h") ControlSend($console, "", $handle, "^H") ControlSend("", "", "", "text", 0) ;the same ControlFocus($console, "", "TTreeView1") ;using focus ControlSend($console, "", "TTreeView1", "^h") ControlSend($console, "", "TTreeView1", "^H")The proc i need works only after TreeView had focus. but it doesnt work without using ControlSend by handle. Edited January 26, 2011 by OxygenSky
OxygenSky Posted January 26, 2011 Author Posted January 26, 2011 Update. Maybe famous UDF ControlSendPlus() can help to solve the problem completely... but who knows where i can find it?
OxygenSky Posted January 29, 2011 Author Posted January 29, 2011 (edited) solved completely! ^^ ;the following code is corrected part of code above $console="main form window name" $handle=WinGetHandle("classname=" & $console) ControlSend("", "", "", "text", 0) Sleep(500) ;doesnt work without pause ControlSend($console, "", $handle, "^h") all works fine! Edited June 2, 2011 by OxygenSky
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