How to click on visible text under a class? - autoit

I created an AutoIt script for a program that has a navigator bar
like this :
Using Au3Info.exe I'm getting following info:
So the problem is Encode tab is active and I want the script to click on the Decode tab, but Au3Info.exe is only identifying the navigator bar :
I'm only getting mouse coordinates or Visible Text for both tabs. I tried :
Run("C:\Users\Dumpty\Desktop\Selenium\WebPconvPortable\WebPconv.exe")
WinWaitActive("Romeolight WebPconv")
Sleep(3000)
ControlFocus("Romeolight WebPconv", "", "WindowsForms10.Window.8.app.0.378734a62")
ControlClick("Romeolight WebPconv", "", "[CLASS:WindowsForms10.Window.8.app.0.378734a62;CONTROLCLICK COORDS:165, 9]")
I tried to click using mouse coordinates too but that's not working either.

You can try MouseClick as you have object position available.
Go to AutoIt v3 Window info and select the Mouse tab.
get the position mentioned over of object. and use in below code.
Below is code you can try:
Run("C:\Users\Dumpty\Desktop\Selenium\WebPconvPortable\WebPconv.exe")
WinWaitActive("Romeolight WebPconv")
Sleep(3000)
MouseClick("left",0,51)==> use actual value
Please let me know if this worked.

Related

Unable to find control

I want to find and click a button using Autoit. I tried AutoIt Window Information Tool but the button is not recognized so ControlClick() fails.
The button is active on the current window but Send("Enter") does not work. Tried using MouseClick() but the window does not appear in the same place every time, and I tried this script:
$hWnd = WinWait("vcredist_x86")
WinWaitActive("vcredist_x86")
ControlClick($hWnd, "", "[CLASS FROM AUTOITINFO]", "Left", 1)
but neither of them works. Is there any other way to identify and click the button?
If both version of AutoItWindowInfo(32 and 64bit) don't "see" the control you need to automate, here is what you can do:
Method 1 - Sending keystrokes:
Activate the window with WindowActivate
Send a number of TABs until the control is focused(if its not initially)
Send ENTER or SPACE
Method 2 - MouseClick:
Activate the window
Get the coordinates of a control relative to the application window(position the window at 0,0. Open Autoit Window Info, click on Mouse tab and get the position of the button). That position is usually always the same
When your code is running it must get the window position with WinGetPos and then add control position you got in step 2. That's your clicking position.
Method 3 - PixelSearch(If the control has unique color):
Get the desired color with AutoIt Window Info(mouse tab)
Search it using PixelSearch
Click the coords you got
Method 4 - ImageSearch:
Get ImageSearch UDF and DLL
Make a picture of the button
Search and click it
NOTE: Sometimes you need to give your script Admin rights in order to automate certain windows.
When AutoIt Window Information Tool failed me I had success using the text property of the button/ui control:
ControlClick($hwin, '', '[CLASS:Button; TEXT:Cancel]')
Experiment with "&" in front of one of the characters (underlined by Windows to indicate an Alt + key shortcut), so try "&Cancel" instead of "Cancel". If that fails try ControlFocus() first:
ControlFocus($hwin, '', '[CLASS:Button; TEXT:Cancel]')
ControlClick($hwin, '', '[CLASS:Button; TEXT:Cancel]')
Inspecting .exe files for GUI resources (using Resource Hacker for example) may expose text/properties of a control. Example:

Change color and back button title of Navigation Bar from Swift 3 code

Making UI of my app using code only.
Can't find how customize couple elements:
1. Button 'Back' now it looks like:
and it should looks like:
So, how I can get rid of 'Back' text from button title, keeping '<' system icon there? And how I can change colors of back button and title of navigation bar?
try
self.navigationController?.navigationBar.tintColor = UIColor.white
Try:
override func viewDidLoad(){
//any other initial stuffs
//for the bar
navigationController?.navigationBar.tintColor = UIColor.black
//for the button
navigationController?.navigationBar.backItem?.titleView?.tintColor = UIColor.white
}
Follow the instruction from your xcode. You can do this easily. I also marked on the image . Select 1. Select the Standard Editor, 2. Show the File inspector 3 Set global Ting
With XCode 12.3 can change the Title Color and Back Button using the following.

Next and previous control button in winAPI to go to next page (c++)

I am creating an winAPI application in c++ I have a photo in preview pane and I want to create two buttons NEXT and PREVIOUS on clicking them I will go to the next page .
Could you please give me the idea how to do that in c++ ??
Do I need to use QT libraray or it can be done using the in built function of WinAPI like -
HWND hwndButton1 = CreateWindow(L"BUTTON",L"NEXT",WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,550,800,100,30,m_hwndPreview,(HMENU)buttonid1,(HINSTANCE)GetWindowLong(m_hwndPreview, -6),NULL);
HWND hwndButton2 = CreateWindow(L"BUTTON",L"PREVIOUS",WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,650,800,100,30,m_hwndPreview,(HMENU)buttonid2,(HINSTANCE)GetWindowLong(m_hwndPreview, -6),NULL);
and then using WM_COMMAND for both the button clicks.
Am I going right?
I just want my API application work like a .pdf extension file...as in PDF files we have up and down arrow and on clicking upon them we can go to the next page..In winAPIc++ I couldn't find any such arrow function.. please tell me if there is any such arrow up/down function present to go to next page (because I am very less interested in creating NEXT and PREVIOUS button using createwindow function.. It looks odd).
You have not mentioned what tools you are using, so we don't know if you have a resouce editor. You should research that in a forum appropriate for the tools. If you think writing one line of code to create a button is "very complicated" then you need a better tool.
If you do not want the buttons to appear on top of the picture then you need another place to put them. One common possibility is a toolbar. It is a strip for buttons along the top or bottom of the main window:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760435(v=vs.85).aspx
With a resource editor you can draw an arrow on the button. Without a resource editor you can set the button text to a unicode arrow:
SetWindowText(hwndButton1, L"\x25bc"); // down arrow, use 25b2 for up arrow
Most buttons (and other controls) are created using a resource editor, placing the controls on a dialog template or a toolbar resource. If you do that Windows will create the buttons when you create the dialog or toolbar. This method is much preferred because Windows will adjust the size of the buttons as required for the screen settings in use.
If you can't do that you must use CreateWindow as you are doing.
Finally it is done.. I have created the buttons neither using Qt or nor using any createWindowEx..The best and easy approach to follow is resource editor ...just put some button on dialog and use IDD_MAINDIALOG (in my case)
m_hwndPreview = CreateDialogParam( g_hInst,MAKEINTRESOURCE(IDD_MAINDIALOG), m_hwndParent,(DLGPROC)DialogProc, (LPARAM)this);
and then
BOOL CALLBACK AMEPreviewHandler::DialogProc(HWND m_hwndPreview, UINT Umsg, WPARAM wParam, LPARAM lParam)
{
switch(Umsg) // handle these messages
{ .........
}
....
}
and thats done. Very easy task.

How to click on Toolbar element with Sahi for Test Automation?

Web page contain a button with some text for example "Test". This button actually is a toolbar element. (class ="tbButton" id="id",text="Test") and redirects to a certain table when press on it.
When I tried to use the following click methods, the button did not react.
browser.div("Test").click();
browser.click("id");
browser.click("");
browser.div("id").click();
browser.byId("id").click();
browser.containsText(browser.byId("id"),"Test");
browser.div("Test").in(browser.table("Generar")).click();
browser.byXPath("//div/Test").click();
Could anybody suggest me an alternative methods that is able to resolve the above problem?
Try with:
browser.xy(browser.div("Test"), 10, 10).click();
This will click a little inside the div.

anchor target blank - how to always open in same popup window

I have a number of anchors in a page. I want that when the user clicks on an anchor it would open a blank window. I have used target='_blank' and that works correctly. However, I want that if the user clicks on another link in the original page, I would like that it uses the same popup that was opened for the first window. What I do not want is that the user ends up with like 10 popups as this would be a bit messy for the user.
Is this achievable please?
Any assistance would be greately appreciated.
target is deprecated since HTML 4.01, you can however use JS like this:
test
<script>
var clicky = document.getElementById("clicky");
clicky.onclick = function(){
window.open(clicky.href, "test");
return false;
}​
</script>
in the window.open, the first attribute is the URL the link should go to, the second is the name of the window, clicking any link setup like this will open in the same window.
there's better and easier ways to do this to multiple elements with jquery etc. but it all hinges on the window.open.
Instead of using _blank (which is a special value for a new window), use a name - any name would do.
target="mySpecialPopup"
When naming a window this way, every time you call it by name it uses the same instance.
Just name your target.
target='mywindow'
This should open a blank window the first click and repopulate it when other target='mywindow' links are clicked.

Resources