Jump to content

why these statements can't execute


sirius10
 Share

Recommended Posts

Dim $seconds

Dim $active

Dim $color

$seconds = 1

$active = 0

Run("C:\WINDOWS\system32\mstsc.exe")

Sleep(300)

While $seconds < 15 AND $active = 0

WinActivate("远程桌面连接", "")

Sleep(100)

ControlSetText("远程桌面连接","","Edit1","192.168.0.1")

Sleep(100)

Send("{ENTER}")

WinWaitActive("192.168.0.1 - 远程桌面","")

Sleep(100)

WinActivate("Log On to Windows","")

Sleep(100)

Send("!u")

Send("administrator")

Sleep(100)

Send("!p")

Send("com.oracle8i.www")

Sleep(100)

Send("{ENTER}")

$active = 1

End

If $active <> 1 Then

MsgBox(0,"Notice","Please start Notes manually")

EndIf

Link to comment
Share on other sites

This line of code:

WinWaitActive("192.168.0.1 - 远程桌面","")

should work if you have your window title information correct.

This line of code will not work:

WinActivate("Log On to Windows","")

because it is on the remote computer and not local where the script is being run.

You can send some keys to a remote desktop session - but you cannot use any of the Win... functions.

You might want to consider creating a shortcut with all of the computer information and password and using your script to start the shortcut.

have fun...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Can you send an example to me? Thank you very much!

Send you an example of what:

"...creating a shortcut with all of the computer information..."

or

"...using your script to start the shortcut..."

or

all of the above?

The Remote Desktop with in XP Pro program has the ability to create a shortcut that contains a lot of information. Start the program and look in the lower right corner for the options button. You should be able to set and save the computer name, password... I would make one shortcut for each computer of interest.

As for a script that starts a shortcut there are several ways to do that.

Run('explorer "???FullPath???.rdp"')

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Send you an example of what:

"...creating a shortcut with all of the computer information..."

or

"...using your script to start the shortcut..."

or

all of the above?

The Remote Desktop with in XP Pro program has the ability to create a shortcut that contains a lot of information. Start the program and look in the lower right corner for the options button. You should be able to set and save the computer name, password... I would make one shortcut for each computer of interest.

As for a script that starts a shortcut there are several ways to do that.

Run('explorer "???FullPath???.rdp"')

I want these examples:creating a shortcut with all of the computer information and how to start the shortcut

thanks!

Link to comment
Share on other sites

It was a rhetorical set of questions.... that I thought I had asked and answered.

I was suggesting that you manually make the shortcut for each computer of interest (I assumed that there were only a few of them). I thought that I had conveyed one method for manually creating each shortcut. Then I gave you an example of AutoIt code to run that shortcut:

Run('explorer "C:\temp\192.168.0.1.rdp"')

Im beginning to think that you do not wish to manually create the shortcut I get the impression that you want to script that part too... but there is little reason to script the creation of a shortcut and then run that same shortcut for an RDT (Remote Desktop) connection. If you are going to script that part, then just go ahead and connect to the computer of interest with code like this:

AutoItSetOption("SendKeyDelay", 1) ;(milliseconds)
AutoItSetOption("WinWaitDelay", 1) ;(milliseconds)

Run("C:\WINDOWS\system32\mstsc.exe")

WinWait("Remote Desktop Connection", "")
WinActive("Remote Desktop Connection", "")
WinWaitActive("Remote Desktop Connection", "")
ControlFocus("Remote Desktop Connection", "", "Button4")
ControlClick("Remote Desktop Connection", "", "Button4", "left", 1)

WinWait("Remote Desktop Connection", "my password")
WinActivate("Remote Desktop Connection", "my password")
WinWaitActive("Remote Desktop Connection", "my password")
ControlSend("Remote Desktop Connection", "", "Edit1", "{HOME}+{END}192.168.0.1")
ControlSend("Remote Desktop Connection", "", "Edit2", "{HOME}+{END}administrator")
ControlSend("Remote Desktop Connection", "", "Edit3", "{HOME}+{END}com.oracle8i.www")
ControlSend("Remote Desktop Connection", "", "Edit4", "{HOME}+{END}{DEL}")

ControlFocus("Remote Desktop Connection", "", "Button6")
ControlClick("Remote Desktop Connection", "", "Button6", "left", 1)
If you still want to script the creation of an "RDT" shortcut, then modify the code above to do a "Save As" and give it a name.

hope this helps...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

It was a rhetorical set of questions.... that I thought I had asked and answered.

I was suggesting that you manually make the shortcut for each computer of interest (I assumed that there were only a few of them). I thought that I had conveyed one method for manually creating each shortcut. Then I gave you an example of AutoIt code to run that shortcut:

Run('explorer "C:\temp\192.168.0.1.rdp"')

Im beginning to think that you do not wish to manually create the shortcut I get the impression that you want to script that part too... but there is little reason to script the creation of a shortcut and then run that same shortcut for an RDT (Remote Desktop) connection. If you are going to script that part, then just go ahead and connect to the computer of interest with code like this:

AutoItSetOption("SendKeyDelay", 1);(milliseconds)
AutoItSetOption("WinWaitDelay", 1);(milliseconds)

Run("C:\WINDOWS\system32\mstsc.exe")

WinWait("Remote Desktop Connection", "")
WinActive("Remote Desktop Connection", "")
WinWaitActive("Remote Desktop Connection", "")
ControlFocus("Remote Desktop Connection", "", "Button4")
ControlClick("Remote Desktop Connection", "", "Button4", "left", 1)

WinWait("Remote Desktop Connection", "my password")
WinActivate("Remote Desktop Connection", "my password")
WinWaitActive("Remote Desktop Connection", "my password")
ControlSend("Remote Desktop Connection", "", "Edit1", "{HOME}+{END}192.168.0.1")
ControlSend("Remote Desktop Connection", "", "Edit2", "{HOME}+{END}administrator")
ControlSend("Remote Desktop Connection", "", "Edit3", "{HOME}+{END}com.oracle8i.www")
ControlSend("Remote Desktop Connection", "", "Edit4", "{HOME}+{END}{DEL}")

ControlFocus("Remote Desktop Connection", "", "Button6")
ControlClick("Remote Desktop Connection", "", "Button6", "left", 1)
If you still want to script the creation of an "RDT" shortcut, then modify the code above to do a "Save As" and give it a name.

hope this helps...

These problems have been solved, thanks a lot:)
Link to comment
Share on other sites

  • 1 month later...

If both os is xp sp2 in chinese,it works.

But in this situation,it doesn't work:

My os is xp sp2 in chinese,and i want to connect to another machine(it's os is server 2003 in english).

when it come to the server 2003 remote destop,it can't auto enter user and password!

The code is:

AutoItSetOption("SendKeyDelay", 1) ;(milliseconds)

AutoItSetOption("WinWaitDelay", 1) ;(milliseconds)

Run("C:\WINDOWS\system32\mstsc.exe")

WinWait("远程桌面连接", "")

WinActive("远程桌面连接", "")

WinWaitActive("远程桌面连接", "")

ControlFocus("远程桌面连接", "", "Button4")

ControlClick("远程桌面连接", "", "Button4", "left", 1)

WinWait("远程桌面连接", "登录设置")

WinActivate("远程桌面连接", "登录设置")

WinWaitActive("远程桌面连接", "登录设置")

ControlSend("远程桌面连接", "", "Edit1", "{HOME}+{END}122.6.15.194")

ControlSend("远程桌面连接", "", "Edit2", "{HOME}+{END}administrator")

ControlSend("远程桌面连接", "", "Edit3", "{HOME}+{END}com.oracle8i.www")

ControlSend("远程桌面连接", "", "Edit4", "{HOME}+{END}{DEL}")

ControlFocus("远程桌面连接", "", "Button6")

ControlClick("远程桌面连接", "", "Button6", "left", 1)

Link to comment
Share on other sites

If both os is xp sp2 in chinese,it works.

But in this situation,it doesn't work:

My os is xp sp2 in chinese,and i want to connect to another machine(it's os is server 2003 in english).

when it come to the server 2003 remote destop,it can't auto enter user and password!...

What happens when you manually perform the steps that the script does?

Try this maunally (without the script)

Start mstsc.exe

Type in the correct information

Press the button to make the connection

Does the system with the English OS respond correctly?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

What happens when you manually perform the steps that the script does?

Try this maunally (without the script)

Start mstsc.exe

Type in the correct information

Press the button to make the connection

Does the system with the English OS respond correctly?

If do it manually,it can success!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...