Sign in to follow this  
Followers 0
adrigalilea

Controlsend and virtual machine

10 posts in this topic

#1 ·  Posted (edited)

Hi, im able to send or click on a vmware virtual machine, example:

WinActivate("[TITLE:M1 - VMware Workstation]", "")
MouseClick("Right",233, 979)
Sleep(100)
Send("x")

But when it comes to controlclick, or controlsend nothing happens:

Autoit window info:
>>>> Window <<<<
Title: M1 - VMware Workstation
Class: VMUIFrame
Position: -8, -8
Size: 1936, 1056
Style: 0x17CF0000
ExStyle: 0x00000100
Handle: 0x00000000000306D0
>>>> Control <<<<
Class:  MKSEmbedded
Instance:   4
ClassnameNN:    MKSEmbedded3
Name:   
Advanced (Class):   [CLASS:MKSEmbedded; INSTANCE:4]
ID: 
Text:   MKSWindow#0
Position:   202, 94
Size:   1699, 884
ControlClick Coords:    456, 374
Style:  0x50000000
ExStyle:    0x00000000
Handle: 0x00000000000E0AC0

Tested controlclick and controlsend code:

 
WinActivate("[TITLE:M1 - VMware Workstation]", "")
$tempo = ControlSend("M1 - VMware Workstation", "","","ic")
$tempo = ControlClick("M1 - VMware Workstation", "","","left",1,456, 374)
$tempo = ControlSend("[CLASS:MKSEmbedded; INSTANCE:4]", "MKSWindow#0","","x")
$tempo = ControlSend("[CLASS:VMUIFrame]", "","","x")

Thank you.

EDIT: Tested sending something to VMWare and it worked, but when it comes to the actual virtual machine it keeps doing nothing.

Tested code to send alt+h to vmware, not working when i try it with the virtual machine.

$tempo = ControlSend("M1 - VMware Workstation", "","","!H")

Ok, all control send are giving me a 0 as output wich means "Returns 0 if window/control is not found.", except the one thats being sent to VMWare software, wich gives me a 1, anyone able to help? :S

Edited by adrigalilea

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Is the VM station also a windows box?  If so, you could run a scripts from the host to the VM.

Can't run nothing inside the virtual machines. ;)

Edited by adrigalilea

Share this post


Link to post
Share on other sites

What app are you trying to automate?

i need to automate certain tasks, on different OS's on different VM's and the needs will be changing from time to time, "low interaction needed"  so my idea was a fast universal solution, nothing fancy: a autoit script runing on host, controlling the multiple VM's in the background.

Not as easy as i thought though.

Share this post


Link to post
Share on other sites

In my experience once you mouseclick in the VM the mouse becomes 'owned' by the VM OS until you release it back to the host.  You said you cannot automate inside the VM.  looks like you are using the VMware player.  Have you looked for an API the player?  I think you can automate it from this: https://www.vmware.com/support/developer/vix-api/


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Or if the VMs are on the same network, go the psexec route. I have a customer that works in a VDI scenario, and that is what they do.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

In my experience once you mouseclick in the VM the mouse becomes 'owned' by the VM OS until you release it back to the host.  You said you cannot automate inside the VM.  looks like you are using the VMware player.  Have you looked for an API the player?  I think you can automate it from this: https://www.vmware.com/support/developer/vix-api/

This is not what i've experienced, i can make multiple clicks or sends without trouble, but cant make CONTROLclick nor CONTROLsend, i checked the API and i thank you the idea, but nothing over there will help me :S

BTW Im using VMWare workstation 10

Or if the VMs are on the same network, go the psexec route. I have a customer that works in a VDI scenario, and that is what they do.

psexec wont work hence, i need this not for only other non windows platforms too but completely isolated from other networks machines (the VM's for testing suspicious exe's etc...).

Sorry for my english.

Share this post


Link to post
Share on other sites

You're probably going to have to use MouseClick because there are no controls that ControlClick can see other than the VM window, anything inside of it is invisible to the host computer.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

simple idea, create individual scripts (EXE´s) for each of the VM environments, and use the send command to launch the one you need in the specific VM...

Other idea (just something to explor, I don´t really have details here),  give a different IP address to each of the VM´s, create a TCP client script, which is running at all VMs at the same time,  then a TCP Server on the host machine, which will send commands/instructions to the specific Client....

sorry I can´t provide details / code, I´m not really an expert, just trying to help giving you some options.

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

  • Similar Content

    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf  
    • magmet00
      By magmet00
      Do you have a working imagesearch.au3 with working dll?
      and how can i gethandle and send keyboard/mouse commands to hidden d3d window?
       
      i have tried imagesearch2015 but im getting dll error every time and tried older imagesearchs too in forum what i found.
      i have tried many things to send commands to hidden/background d3dwindow still nothing works.
      Can you help me please?
       
    • Guy_
      By Guy_
      Was testing ControlSend("My Window Name", "", "", "^c") vs the normal Send("^c") or _SendEx("^c") to copy selected text from a window...
      In Windows, I have a setting that when I click the Ctrl key only, my mouse pointer is "highlighted" [that I could of course disable].
      If I use Send("^c"), or do this manually, the mouse pointer is never highlighted, as I wish it to be.
      With ControlSend it *does* highlight...
      I thought that maybe the Ctrl key goes up a few ms too soon in that one and increased AutoItSetOption("SendKeyDownDelay", 5) to way higher, but it doesn't make a difference.
      As it doesn't seem possible to do "^ down", could it be prevented in some way?
      Beside the slight annoyance, it simply alerted me that these seem to work differently [and of course, they are different].
      I also get the early impression that ControlSend [to copy] seems in no way quicker to get something on the clipboard, maybe even slower?
      Thanks 
    • SkysLastChance
      By SkysLastChance
      How would I go about writing a IF Then statement if the conrol send fails?
      Run ("Notepad.exe") WinWaitActive ("Untitled - Notepad") ControlSend("Untitled - Notepad", "", "Edit1", ("Provider Practice Record")) I have been running into lag alot. So my script has been missing input. I would like to be able to have it retry to put in "Provider Practice Record" if it misses. 
      I am assuming  a if then statement is what I need but I am not sure what ControlSend will return if it tries to send to Edit1 and it is not there. 
      Or do I need to just add a timeout? 
       
    • SkysLastChance
      By SkysLastChance
      Okay so I am not sure if I can do this or not with the code I currently have but, I would like to send lastname and the first name with a comma inbetween. 
      so it would look like "last name,first name" 
      right now I just have it sending the last name.
      any help or sugestions are appreciated. 
       
      $r = 1 Local $aArray = _Excel_RangeRead($oExcel, Default, Default) For $i = 1 To UBound($aArray) - 1 ;$i =0 Start from row A $sR1 = $aArray[$i][0] ;status $sR2 = $aArray[$i][1] ;first name $sR3 = $aArray[$i][2] ;Last name $sR5 = $aArray[$i][5] ;Email Address WinWaitActive ("[CLASS:MGUIWin]") Sleep (100) ControlSend("[CLASS:MGUIWin]", "", "Edit2", $sR3, & @CR) $r = $r + 1 If $r > $sBox Then Exit Endif Next