Sign in to follow this  
Followers 0
OxygenSky

Delphi toolbar with {ctrl} shortcut

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by OxygenSky

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by OxygenSky

Share this post


Link to post
Share on other sites

Update.

Maybe famous UDF ControlSendPlus() can help to solve the problem completely... but who knows where i can find it?

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by OxygenSky

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