0

如何使用 autoit 将键盘和鼠标命令从主机发送到 VMware?

有没有其他解决方法?

谢谢,华

4

2 回答 2

0

The main issue with automating VMware is getting feedback from software running in the guest system. For instance, you cannot wait on a window in a guest by executing WinWait() on the host.

One way to get around that is to implement a master/slave dependency where an AutoIt controller script on the host OS issues commands (via VMware shared folder, a network share, etc) and the AutoIt executor script on the guest OS makes stuff happen and reports back (again, over a share).

An example (simplified, but based on what I'm using right now):

WinWait("VMware")
WinActivate("VMware")
Send("{CTRLDOWN}g{CTRLUP}") ; Ctrl+G, give focus to the guest OS
Send("{LWINDOWN}r{LWINUP}") ; Win+R, brings up command entry dialog on the guest
Send("...the actual command with job ID as the argument")
; this last command given to host is actually a compiled AU3 script 
; that does something useful and reports back over a network share
Do
    Sleep(15000) ; now wait for the script on the guest to report back
Until GuestHasResponded()

Func GuestHasResponded()
   ; ... check if the guest has created a flag file on the network share
EndFunc

On the other hand, if you simply need to automate the VMware client itself (e.g. automate creation of virtual machines), you can get by with basic AutoIt approach of which examples are plenty on the AutoIt forum.

于 2012-05-18T21:36:44.307 回答
0

你会想要WinActivate()你的 vmware 窗口,然后使用你需要的任何Send()MouseMove()/MouseClick()功能。

编辑:

之后WinActivate(),执行 Send("^g") 以获得对 VM 的 GUI 控制,然后再尝试Send()MouseMove()/MouseClick()对 VM 进行任何其他操作。

于 2012-05-14T16:10:18.953 回答