Sign in to follow this  
Followers 0
kmetski

Need help whit WINDOWS COMMAND LINE

6 posts in this topic

#1 ·  Posted (edited)

AutoItSetOption("WinTitleMatchMode",3)
AutoItSetOption("WinDetectHiddenText", 1)
Opt("TrayIconHide", 0) 

Run("SQLCMD",@SW_HIDE)
$sql = "use test"
WinWait("SQLCMD")
ControlSend("SQLCMD","","",$sql,0)
ControlSend("SQLCMD","","","{enter}",0)
ControlSend("SQLCMD","","","go",0)
ControlSend("SQLCMD","","","{enter}",0)
Sleep(10000)
WinKill("SQLCMD")
Exit

I can`t make it work when using @SW_HIDE

Probably because the windows command line don`t have a controlID.

When the window of the windows command line is visible everything is fine, but when i hide it does not work.

Any ideas.

Edited by kmetski

Share this post


Link to post
Share on other sites



You need to wait for the window to exist, otherwise $win is nothing but 0.

Opt("WinTitleMatchMode",3)
Opt("WinDetectHiddenText", 1)
Opt("TrayIconHide", 0)

Run("SQLCMD", '', @SW_HIDE)

WinWait("SQLCMD")
$win = WinGetHandle("SQLCMD")
$sql = "use test"

ControlSend("SQLCMD", "", "", $sql)
ControlSend("SQLCMD", "", "", "{enter}")
ControlSend("SQLCMD", "", "", "go")
ControlSend("SQLCMD", "", "", "{enter}")
Sleep(10000)
WinKill($win)
Exit

Share this post


Link to post
Share on other sites

the real problem is that i cant send the commands to the windows cmd

Share this post


Link to post
Share on other sites

What about ControlSetText or specifying a control in the third paramter?

Share this post


Link to post
Share on other sites

I will try that but WINDOWS COMMAND LINE does not have a control ID

Share this post


Link to post
Share on other sites

Does the app respond to StdIn? Maybe that might be better than trying to use send()

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