PyAutoGui LocateOnScreen() - multiple locations - pyautogui

How does this function work if there are several exact images on the screen?
I'm trying to write a program that goes down a list of rows, checks for that image, if there, click, then keep looping.

If you want to do that, you should use locateAllOnScreen().

Related

Selecting/highlighting next adjacent cell in row after function has been executed in google script

I am not really experienced with coding so I apologize in advance if this is a stupid question with an obvious answer...
I use a google sheet to keep track of things at work, and my employees use it multiple times a day. They will either type one of three phrases into a certain cell on a row, so I have created buttons using the drawing feature that they can simply click, which will insert the appropriate text into the highlighted cell.
Once this text is inserted into the cell, I would like to add something to the end of the function that automatically selects the next adjacent cell in the row (to the right) so they can continue typing in. Currently, once they click the button to insert text into one cell (e.g., B23) they have to use the mouse to manually select C23 before typing into that cell. For some reason you cannot use the right arrow key or tab key on the keyboard to move over, so I am wondering if there is a way to add the selecting process into the script (or even a workaround for allowing the tab or right arrow keys to work).
I realize this may seem like a tedious question and folks may think it is awfully lazy of me to ask for a more efficient way to move over to a cell than using the mouse, but my employees use the sheet hundreds of times a day, so I'd really like to maximize the efficiency for them to make it as easy and convenient as possible. Inputting data can be tedious enough, so I am trying to simplify things and make it as least painful as possible :)
Thanks so much!
There are several ways to select the cell at the right. One way is to use offset(rowOffset,columnOffset):
range.offset(0,1)
You are correct. When using a button the focus stays in the button when it is clicked. After some trial and error, I think I found a way that will work fot you. I created a html sidebar that is opened from a custom menu. Once opened, you can leave it opened, HTML allows control over the focus using 'google.script.host.editor.focus()'. Then you can type in the cell. Attached is my sample spreadsheet you can copy and try. Let me know if you need any help changing the button names or text. Sorry my first try didn't work correctly. https://docs.google.com/spreadsheets/d/1KlNSJnZDNIb2chUK3SlKJg79VNIrsAbIbUvHyLwTLWk/edit?usp=sharing

How to find same logos, UI elements using sikulix

I am new to sikuli.
I am using it for functional test automation of my java spring standalone application. I am having the same set of images(logos) at multiple locations on the screen. and they are generated dynamically as per the application data. In that case how can I find and click on certain buttons/elements in the UI.
Example: like, share, comment text/image will be there several times in facebook page. in that how to we click on particular buttons out of all.(facebook is just an example) i want the similar solution for my application.
I think what you're asking is- given a case where the same image or UI element is present multiple times on the same page, how can I specify one of these elements in one location versus the same element in another?
The quick and easy way to do this would be to capture a larger picture, like as much of the window as you can, and click the image in parentheses after the click action; this opens a window reading file, matching preview, and target offset. Click target offset, use the mouse wheel to zoom in, and click on the exact point of the picture that you'd like to click.
It's possible to click in multiple places on a captured image, provided you use different click() commands, and you can set the target offset for each click() command without needing a new picture.
With just this one image, you can potentially click every square on the board provided you take the time to set the offset for each of the 64 click() commands it'd take to do so. http://files.chesscomfiles.com/images_users/tiny_mce/cigoL/Chessboard.png
The more difficult solution would be setting up regions, and searching those regions for the matching pictures, but for what you're looking for this should- for more about regions and setting it up check links below. Cheers!
http://sikulix-2014.readthedocs.io/en/latest/index.html
Based on your FB example you could use setROI() to focus on the top post on the page (imagine a rectangle that covers a complete post on the news feed) from there I would loop:
if exists(profile pic):
click(like button)
elif exists(profile pic 2): # If you are testing more than one user
click(like button)
else : type(Key.DOWN) #repeat as needed
Getting the next post into the ROI may be tricky but using WHEEL_DOWN may help if you can adjust your lines traveled with each wheel click on your system.

How to parse html for a specific <div>?

I'm trying to write a very simple client application for iOS to go to a website with three buttons. Each of these buttons load a different webpage and run a command in an application on the server, takes the results from that command and displays them on a map on the very same page that the button loaded.
What I'm trying to achieve is to be able to do the following:
Click on one of the three buttons.
Have it then run the query.
JUST PULL THE DIV WITH THE MAP TO SHOW THE DATA instead of the entire page, which is what I currently have happening.
I was going to go about this by parsing the html with "libxml2" and "hpple" but I thought that I would ask here before I got started instead of spending a few days on this to realise that I am going about it the wrong way.
So with all of that said I guess my main questions are:
Is this possible?
Is the way I'm going about it correct?
2a. If the way I am going about it is wrong, how best should I go about it?
Normally on the webpage the map, that I am trying to pull, updates dynamically every second or so. In order to make the map dynamic in my application will I have to poll the site every time I want the map to update? or will it automatically update?

QTableView drag move rows

I'm using a QTableView with a QAbstractTableModel and a QSortFilterProxyModel so that I can sort the items by clicking on the table headers. I'd like to add the option for the user to sort the rows in the view manually, by dragging them. I don't need to be able to do drag and drop from/to any external application, just to change the order in the list. I also don't need to change the data in the model, I only want the order to be different in the view.
I've been looking through the documentation, and it seems like I have to implement mimeTypes, mimeData, and dropMimeData, but this gets very complicated fast! Some of the data in my model is not actually displayed in the view, and like I said I don't want to change the order of data in the model. Is there a way to simply drag items to change their sorting (just like the headers are already able to do) without a huge amount of coding?
Updated for QT5 to remove deprecated methods
If you are using PyQT All you need to do for your requirements is this:
your_tableview.verticalHeader().setSectionsMovable(True)
your_tableview.verticalHeader().setDragEnabled(True)
your_tableview.verticalHeader().setDragDropMode(QAbstractItemView.InternalMove)
Then rinse and repeat with horizontalHeader if you want those rearrange-able too.
You are absolutely right, you shouldn't need to touch or even know what the model is for this functionality. This is further demonstrated by your proper use of the QSortFilterProxyModel decorator over the model itself.
The stuff you saw about mimeTypes and all of that stuff is for drag-and-drop of actual objects of varying sources from other windows/applications/desktop/etc and isn't needed for what you are trying to accomplish currently.

Rendering 20 large identical listBoxes

I have an HTML table with rows (20 rows).
Every row has a listbox of countries (about 250 countries) that are filled using a single dataset from the database.
Loading time is quick enough, but rendering time is really a mess.
Is there any way I can speed the rendering of those listboxes?
You could load it only once, and then copy the DOM element everywhere you need it...
I'm not sure if this would improve a lot since it would rely more on the user's computer, but I guess it's worth trying if it's too slow the way it is right now.
edit: here's how I'd do it. Use with caution, I haven't tested it and there is most likely tons of errors with this code, it's just to give you an idea of what I was saying.
<mylistbox id="listboxtemplate"> ... </>
<div class="thisPlaceNeedsAListbox"></div>
<div class="thisPlaceNeedsAListbox"></div>
<div class="thisPlaceNeedsAListbox"></div>
on document ready, using jquery:
jQuery(".thisPlaceNeedsAListbox").append( jQuery("#listboxtemplate").clone() )
You could try to add next select box only after user has selected previous one (using JavaScript).
I'm quite sure that you can rethink the form or the process, but I can't suggest anything specific since you haven't given enough information. For example depending on situation you could use multi-select or some fancy JavaScript widget.
EDIT based on your comment:
Then how about serving the table without selects. And if user double clicks on a country field you change the text element to select element using javascript. And once user has selected the country you can change back to text element. You can submit results back to server using Ajax (after user has selected the country) or using hidden fields a submit button. This way DOM will never contain more then 1 select element.
You can pass countries to javascript using inline JSON object/array (in script tags). To make things even more faster after user has edited the first element, just hide (css: display: none;) the first build select element and clone/move it around each time user wants to edit a row.
As you can see there are a lot of paths you can take using this approach, it all depends how much you want to optimize/work on it.