Sign in to follow this  
Followers 0
BastoZ

Newbie Help: SendControl

17 posts in this topic

How i use SendControl without WinActivate.

Ex: Using another window press any button and send:

ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{F5}")

without change window.

Share this post


Link to post
Share on other sites



just few minutes to reply me.

i think is an easy question.

Up.

Share this post


Link to post
Share on other sites

Are you trying to send this command without starting the Microsoft SQL Server GUI?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

no, my sql already open, i triing send some cmd without change my window.

Ex: if i use

WinActivate("Microsoft SQL Server Management Studio Express")

ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{F5}")

works fine, but my window come to SQL,

i just want to send cmd without call another window.

Edited by BastoZ

Share this post


Link to post
Share on other sites

1. You have to identify a control, not just a window, to receive the text. Open the AutoIt Window Info tool, click the Control tab, then drag the bullseye over the desired control. That will give you the ID, text, and other info for the control. The control is identified in the third parameter of the controlSend function. chances are that the control ID may change depending on how many SQL windows are appearing. It can get tricky. you will need to figure out which descriptor for the control will remain constant.

2. Minimize the SQL Server window after you login.

2. Even if you do the ControlSend for typing the query, you may have problems getting it to execute. sometimes working with minimized windows can be tricky. I would search the forum for related posts.

Share this post


Link to post
Share on other sites

just few minutes to reply me.

i think is an easy question.

Up.

Bumping your topic within 24hrs is considered bad forum behavior - just don't.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

1. You have to identify a control, not just a window, to receive the text.

Nothing wrong with your suggestion, just want to pick a technical nit: Though it would certainly be more reliable if the control is identified, ControlSend() can send to a window without any control defined.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

my question is just how i send any cmd with another window still minimized.

because if i use WinActivate() change my window,

and if i use only ControlSend() dont work.

EX:

ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{ENTER}"

Dont work :D

Edited by BastoZ

Share this post


Link to post
Share on other sites

my question is just how i send any cmd with another window still minimized.

because if i use WinActivate() change my window,

and if i use only ControlSend() dont work.

EX:

ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{ENTER}"

Dont work :D

You're missing the closing paren ")" there, but assuming that's just a typo in the post: How do you know that window's control focus was on the correct edit/input box when you sent the text?

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{ENTER}"

Dont work :D

You need to supply the Control ID parameter to make it work.

Check if AutoIt window info tool can read the control.


[font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font]

Share this post


Link to post
Share on other sites

I have code you can modify if you want and if this work around will work for you

It waits until there has not been any mouse or keyboard movement for 5 seconds, then it sets the input window to transparent, restores it, moves it off screen, sends the controlsend commands to it, brings it back onscreen (still transparent), minimizes it, sets the transparency back to normal and it sleeps for 9 minutes.

If the window is not minimized, but in the background, it makes it transparent, activates its it, sends keystrokes, minimizes it and makes it viewable again

Let me know if you want it

my question is just how i send any cmd with another window still minimized.

because if i use WinActivate() change my window,

and if i use only ControlSend() dont work.

EX:

ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{ENTER}"

Dont work :D

Share this post


Link to post
Share on other sites

ControlFocus("Microsoft SQL Server Management Studio Express","","")
ControlSend("Microsoft SQL Server Management Studio Express","","","Select * from sipar" & "{F5}")

Can't read id.

for sure im doing something wrong, thats all my cod, i just want to know how use this metod.

just send any complete example without ID.

Share this post


Link to post
Share on other sites

I defer to PsaltyDS, but if there are multiple controls on the window, there is no guarantee that what you send will be applied to the desired control. You say that you cannot identify the control? If you drag the bullseye over the SQL window, what appears in the AutoIT window information tool?

I don't know for certain that you will be able to accomplish what you want to do. I tried a similar action with TOAD. I was able to enter a query, but I could not get it to execute. So, you may have to find a plan B.

Share this post


Link to post
Share on other sites

I defer to PsaltyDS, but if there are multiple controls on the window, there is no guarantee that what you send will be applied to the desired control. You say that you cannot identify the control? If you drag the bullseye over the SQL window, what appears in the AutoIT window information tool?

No, show ID: (CLEAR)

i'll rename my tittles of everything, but i need to know how to send cmd with controlsend or how to use control focus because i already post before is not working the way im doing.

just post any Code using Controlsend and/or Control focus without ID only using title thats will helpme.

Share this post


Link to post
Share on other sites

Try what I have scripted in this post, obviously you'll have to tweak it to the values for your particular program, but this is the best way I have found to use controlsend, when a window needs to be active.

http://www.autoitscript.com/forum/index.php?showtopic=103163

No, show ID: (CLEAR)

i'll rename my tittles of everything, but i need to know how to send cmd with controlsend or how to use control focus because i already post before is not working the way im doing.

just post any Code using Controlsend and/or Control focus without ID only using title thats will helpme.

Share this post


Link to post
Share on other sites

Why all the bother with a minimized instance of MS SQL studio anyway? If you just need to execute a query use OSQL.exe from a hidden or minimized command line, or an ADODB connection.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This is simple.

1.) Use ControlGetHandle to ensure you are getting the correct handle

2.) ControlSend to Notepad to ensure the right text is being sent.

3.) Use WinSetState to control the window.

4.) Worse comes to worse, every control has a handle that can be used and there are always mouse commands to get the focus.

4.) ControlFocus - not going to work if the parent window is not in active.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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