ControlClick not working with AutoItX3 - automation

I am currently trying to use AutoItX3 to do some automation.
My script opens up an application and now I want it to click on the certain button within the app. This is my code for the ControlClick (parameters were acquired from the AutoIt v3 Window Info Tool) :
Local $sText = WinGetTitle("[ACTIVE]")<br>
ControlClick($sText, "", "[CLASS:WindowsForms10.Window.8.app.0.33c0d9d; INSTANCE:62]", "left", 1, 21, 12)
Unfortunately, this code does not seem to do anything at all. I replaced it with a regular mouse click with coordinates, but then this script won't work on any computer with a different resolution.
Any ideas?

Try this to understand what I meant.
Example()
Func Example()
; Run Notepad
Run("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
WinWaitActive("[CLASS:Notepad]", "", 10)
ControlSetText("[CLASS:Notepad]", "", '', 'HELLO WORLD!')
; Wait for 2 seconds to display the Notepad window.
Sleep(2000)
ControlSend("[CLASS:Notepad]", "", '', '{Right 20}{ENTER}NEW LINE!')
; Close the Notepad window using the classname of Notepad.
WinClose("[CLASS:Notepad]")
WinWaitActive("Editor", "", 10)
ControlSend("Editor", "", '', '!n')
EndFunc ;==>Example

Are you sure that AutoIt spy tool identifies the button individually?Some times AutoIt info tool identifies a some portion of a application(multiple buttons or multiple tabs)as single object.In that situation you have to use the mouseclick opration and after that use control click function like below
mouseclick("",21,21)
Controlclick("","","button1",21,21)
this might help you.make sure to capture the x and y coordinates from the Mouse tab of autoIt info tool.

Sometime it could happend on some windows protected with an anti-bot/macro systems such as games, java clients etc...
You could by-pass this using a VM with a third-party desktop controler such as teamviewer/RDP/... You will be able to run your script thru the RDP session.
Please Note: AutoIt is not made to make GameBots :)
Vlu.

Related

How can I reverse "action.KeyDown(Keys.Alt).SendKeys("N").Perform();" in C#, Seleium/Appium/Visual Studio

I am testing uploading from file explorer window that has been opened via web browser application - for some reason it can find the open window but can't find File name field and doesn't actually click the Open button (despite passing that step).. As a result I have had to use alt + N to select the File name field, which is all well and good, but that results in disabling my keyboard for all other apps.
I presumed that I would only need to do a KeyUp on the alt button as there is no equivalent for the N key, which is obviously sent using SendKeys method... The code below DOES run, but it is far from ideal if I'm going to have to keep coding key strokes that I can't reverse unless manually...
if (open != null)
{
Actions action = new Actions(session);
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
Thread.Sleep(1000);
action.KeyDown(Keys.Alt).SendKeys("N").Perform();
action.KeyUp(Keys.Alt).SendKeys("19th December 1932 (2).xlsx").Perform();
action.KeyDown(Keys.Alt).SendKeys("o").Perform();
action.KeyUp(Keys.Alt).Perform();
Does it work if you write the actions like this?
action.KeyDown(Keys.Alt).SendKeys("N").KeyUp(Keys.Alt).SendKeys("19th December 1932 (2).xlsx")Perform();
action.KeyDown(Keys.Alt).SendKeys("o").KeyUp(Keys.Alt).Perform();

Opening a new browser tab

I've tried several functions but none seems to be working? For example:
element, _ := webdriver.FindElement(selenium.ByCSSSelector, "body")
element.SendKeys(selenium.ControlKey + "t")
Selenium is capable of executing javascript within the browser.
To open a new tab get selenium to run the following:
window.open()
I've not used Selenium & Go before - so I can't comment on the syntax. However it's normally along the lines of driver.ExecuteScript("window.open()"). See if your IDE will help you plug the gap.
After you get a new tab, you typically need to use the .switchTo in order to move selenium to another tab.
updated:
Docs suggest....
// ExecuteScript executes a script.
ExecuteScript(script string, args []interface{}) (interface{}, error)
see here

AutoIT send() commands not working properly

So I have a game client with 2 input fields: id pass and 1 button: login.
My login credentials are: $id=1234 and $pass=a_bCd.
I'm using AutoIT scripting to automate the login process (my script automatically inputs the id and pass in the login fields) and my AutoLogin() function looks like:
send($id + "{tab}")
Sleep(10)
send($pass + "{enter}")
Sometimes it works fine, but sometimes my script introduces 1234a- or 1234a_ in the ID field and the rest of the characters in the pass field. I tried many solutions like controlsend("Game","","","1234{tab}a_bCd{enter}"), or changing sleep() values, etc. but the input still goes wrong sometimes. Figured the send delay or sleep would have the problem, still don't know what to do.
Manually inserting the id and pass works properly. What would be a good solving of this problem? Thanks
I have had the same troubles with send. This post on autoitscript.com may help you with WinAPI_Keybd_Event() (documentation here):
#include <WinAPISys.au3>
_WinAPI_Keybd_Event(0x11, 0) # Push CTRL down
_WinAPI_Keybd_Event(0x11, 2) # Lift CTRL up again
This helped me with my problems.
NOTE: Sometimes, when your script breaks because of an error, it may happen that one of the keys on your keyboard is still pressed (i.e. pushed down but never lifted up). I use the on-screen keyboard that is integrated in Windows for these moments...
2 Solutions:
You add Strings with &:
send($id & "{tab}")
send($pass & "{enter}")
If that does not work just separate it:
send($id)
send("{tab}")
send($pass)
send("{enter}")
And you don't need that sleep

Nightwatch.js: Drag and Drop

I am trying to test a drag and drop operation using Nightwatch.js 0.8.18, Selenium Server 2.53.0 and Chrome Driver 2.21.2.
Basically, I take the approach described at https://github.com/RobK/nightwatchjs-drag-n-drop-example/blob/master/spec/drag-and-drop.js – i.e.: something like ...
.moveToElement('some-xpath-expression', 10, 10)
.pause(100)
.mouseButtonDown(0)
.pause(100)
.moveToElement('other-xpath-expression', 30, 30)
.pause(100)
.mouseButtonUp(0)
The cursor moves to the element to be dragged (perceivable by the :hover style of the icon the mouse is over), but then nothing happens. It looks to me like the mouseButtonDown() action has no effect. (But who knows for sure?)
It makes no difference if I use Firefox instead of Chrome – the behavior is exactly the same.
Any ideas?
Guys you have to try this and it works fine in Chrome, Firefox and IE.
Just you have to install "html-dnd" using npm, as well as this is a link: https://www.npmjs.com/package/html-dnd
After installing you just have to execute this command
browser.execute(dragAndDrop, ['#draggable', '#droppable']);
For Example:
var dragAndDrop = require('html-dnd').codeForSelectors;
browser.execute(dragAndDrop,['#elemendId1','#elemendId2']).pause(2000);
Hope this will work fine for your test cases.
The moment you click the element the expression changes and thus the tests 'forgets' what they were supposed to be clicking.
It's recommended to use an action build approach as so:
http://elementalselenium.com/tips/39-drag-and-drop
Currently at Nightwatch Version 1.5.1 I'm able to drag and drop with the following example.
Example:
"Step 1: Drag and Drop": function (browser) {
browser.moveToElement('yourLocator', '#startingElement', 0, 0);
browser.mouseButtonDown(0);
browser.moveToElement('yourLocator', '#endingElement', 0, 0);
browser.mouseButtonUp(0);
}

Automatic download of created file in Sencha Touch 2

My Sencha Touch 2 application has an 'Export' button, which creates an Excel file with the data of the selected offer.
After the user clicks the button, i want the (server side) export process to be started, and, once completed, the user to be prompted to select a filename and location, OR that the file is automatically downloaded. How do i do that? Does anyone have an example?
For Excel specifically I'm not 100% sure, but this might help you get started or if a CSV is acceptable...
I'm sure you could pass the file reference to a var instead of the string but I have yet to try it.
If you paste the js below into the console you can see how this works. Pretty basic. Maybe try the returned value from the server to see if that works then if it does you can build a function around it to happen when needed.
csvHeading = 'HA, HB, HC, HD \n';
csvData = 'r3a, r3b, r3c, r3d \n' +
'r2a, r2b, r2c, r2d';
CSVFile = csvHeading + csvData;
window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(CSVFile);