Running Pyautogui on a different computer with different resolution - python-3.4

I have a python script which runs perfectly on my work computer (1600 x 900 resolution). It is on this computer that I took all the screenshot images used by pyautogui.locateOnScreen. I tried to run this program on my home laptop with a different resolution (1340 x 640) and the script does not seem to find the image location. I am guessing that it is because of the different resolution. (I have copied the script folder from my work computer to the home computer, so the path to the image file is exactly the same). Is there anything I can change in my script so that pyautogui.locateOnScreen would identify the image on any computer resolution?

I'm the creator of PyAutoGUI. The problem you have isn't with the screen resolution, but the screen scaling. Your program will work fine on monitors at different resolutions. But at high resolutions, the text and buttons of your programs become too small and so Windows and macOS fix this with "screen scaling", which can increase the size of UI elements like text and buttons by 150% or 200%. If you have multiple monitors, each monitor can have it's own screen scaling setting; for example one monitor at 100% and another at 150%.
If you take a screenshot while a monitor is at, for example, 100% and then try to use it on a monitor that is scaled at 200%, the image won't match because the screenshot is literally half the width and length of what it would have been on the 200% monitor.
So far, there is no work around for this. Resizing the screenshot might not work because there could be subtle differences and the screenshot mechanism currently needs a pixel-perfect match. You just need to retake the screenshots on the monitor with the different screen scaling setting.

I think you'll need to take a screenshot of the image on the different resolution, and at the start of your program have it detect whether it's on the 1600x900 screen or the 1340x640 screen. Then make all the 'locateOnScreen' pieces take a variable, and depending on the screen size, replace those variables with the path to the correct image.
import pyautogui
def function():
pyautogui.locateOnScreen(x)
...
pyautogui.locateOnScreen(y)
...
screen = pyautogui.size()
if screen = (1600, 900):
x = 'image1_1600_900.png'
y = 'image2_1600_900.png'
else:
x = 'image1_1340_640.png'
y = 'image2_1340_640.png'
function()

Related

Responsive Design on Screens Bigger Than Yours- How Can I Do It?

So I'm relatively new to responsive design and I have a very newbie question. Essentially, how can I test how my code looks on devices larger than my own?
For example, let's say I'm building a data visualization with d3. I know I can open up the chrome inspection tools - and input some of the more popular screen resolutions (1920 x 1080; 1366 x 768), etc for responsive up at the top.
But let's say I'm using a 13 inch macbook. If I type in those precise dimensions at 100%, (let's use the 1920 x 1080 as an example here at 100%), it will automatically revert to 1330 x 558. How can I make changes to my css file to make it look good responsive-wise if I don't have some type of simulation to tell me how it would actually look on an actual device? If I use 1920 x 1080 at 50%, it still looks different than how I'd originally like (at 100%).
I know of sites like browserstack. But even when I test it out on their site, I can only adjust the dimensions so much.
I hope this post makes sense. It's been eating at me for quite some time now and I'm about to purchase a 27 inch macbook :/
Browser zoom follows #media querys
Best practice is to design your site to look presentable at all resoultions.
But you should allways decide the largest viewspace for your design and set a max-width on your wrapper-element. This is fundamental to ensure a good user experience. Small resolutions limits to zero, hi resolutions is basically infinite.
If a user renders your site with a width: 100% on a hi-res full-scale projector your page could be several meters wide.
Use:
width: 100%;
max-width: 1920px; //2048px, 4096px or whatever you decide
If a user renders your site on a desktop, laptop, ultrabook, phone or what ever, the #media querys should serve the best UI for that resolution.
If you wish to see actual result use browser zoom.
Try responsive design mode in Safari.
Develop > Enter Responsive Design Mode. Also you can enter with shorcut option + cmd + R.
There are side bars on the right and bottom. Just drag and set as you want.

Chrome mobile device screen emulator

I'm a bit confused about how device screen emulation works in chrome and how to use it to write affordable media-query. e.g.
IPhone X
Real device screen-size: 1125x2436px
Emulated device screen-size: 375x812px
I know that a resolution like that easily take two full-hd screen to be shown at 1:1 scale with the actual monitor resolution (pixel density), but the emulated res is not simply the result of a zoom-out, because if I zoom in or out the view, pixel size is about the same, and this make me think that chrome is suggesting me that the emulated resolution should be my reference for layout, like it is the real-device res.
But if it is, how this resolution is calculated? Why I should use this instead of the actual device screen-size?
While phone screens are usually high resolution like Full HD or Quad HD, their browser viewports are not, instead they are the resolutions Chrome shows you in the developer tools.
This helps you when setting up your CSS media-queries as you don't have to handle every single resolution of every specific device.
But if it is, how this resolution is calculated?
It is just a scaled down version of the actual screen resolution for that given device.
Why I should use this instead of the actual device screen-size?
Because the actual resolution of the viewport is that one and not the device screen size.
You can read more about this here: https://mediag.com/blog/popular-screen-resolutions-designing-for-all/

Using high DPI images with QtStyleSheet

I have a Qt Widgets application using Qt styleSheet for the app look and feel. We want to add support for high-DPI displays, as on these, the app looks very small. The first step was thus to call:
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
This does most of the job and the app window is big enough. The only remaining issue is the resolution of the images used in style sheet.
Say that we have:
QCheckBox::indicator::unchecked {
image: url(:/res/checkbox_off.png);
}
MainWindow QFrame {
background-image: url(:/res/background.png);
}
When using high DPI scaling, these images get upscaled accordingly which is a problem. For high DPI, I would prefer to use higher resolution images to make them look as crisp as possible.
As expected, a naive approach of simply providing the images in higher resolution does not work - it makes images and controls twice as large (on both low and high DPI screens).
Qt documentation on QImageReader states that
The high resolution version is marked by the suffix #2x on the base name. The image read will have its device pixel ratio set to a value of 2.
However, I have provided these resources with twice the resolution, added them to qrc file, but the images displayed are still the same on device with pixel_ratio of 3.
Are there any other steps needed to make this automatic image loading work with stylesheets?

media queries for screen resolution of kiosk device

I am trying to create website in kiosk device. It is working fine when I test it in my browsers(chrome). But when it comes, to kiosk device, the page is fully distorted. The kiosk screen resolution is 1980 x 1020. Actually my page has two columns width 50% each. And each column has some fields arranged.Can somebody please guide me as how to start with the media queries for this resolution.
If you have made the website for smaller resolutions and then you will put kiosk resolution, the images and other elements are going to be bigger (so will be distorted).
You need to implement in your website different resolutions (thinking in different devices) and in this case you need to think in the big resolution that you can put your web, ie: Full HD and then resize to smaller resolutions.

Mediawiki Images no resize

How can I force mediawiki to disable resizing and use the original size of my image? My main problem is that I'm uploading small parts of screenshots. If I don't use the original size then they look awful. (Imagine a 237px wide image resized to 400px....) But I don't see any option for that.
http://www.mediawiki.org/wiki/Help:Images#Size_and_frame
By simply using the image name, it will fit the image to screen which is really bad! For example, a 300px wide screenshot cutout looks awful on a full hd monitor... You could say that the image may be too large for the users' screen but in my particular case that is not the case. I'll always be using small images (300px and smaller) and the users will always watch these pages on desktop monitors.
I'm sorry I was very dump. If I don't use any option then it is displayed in its original size. I was mistaken because somebody has changed the zoom level of my browser, but I did not realize this because the monitor resolution was so high...

Resources