How can I select a window that is open in the background - pyautogui

I am trying to select a window that is open in the background and I have no idea what to do.
So far I have tried two methods:
First, I tried using PYAutoGUI to find the Taskbar Image then left click on the image in the taskbar (I assumed this didn't work because it was an image in the taskbar, but that assumption is completely unfounded (On a semi-related note, if you know where taskbar images are saved, please let me know about that as well)].
Second, I have tried to use pyautogui.getWindowsWithTitle(), which has given me a list with two elements that I have absolutely no idea how to use. I've tried the .active() method, but I may be misunderstanding how that works.
As a side note, I have also looked into pywinauto, but I just didn't have the knowledge necessary to understand the "Getting Started" page.
If it isn't obvious, I'm pretty inept with coding. I could probably figure something out if I had 4 or 5 hours, but I figured it'd be easier to ask for help. (I can't post any code for this because I have none. I have literally no idea what to do).

Found this, check it out:
import win32gui
import time
def windowEnumerationHandler(hwnd, top_windows):
top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
if __name__ == "__main__":
results = []
top_windows = []
win32gui.EnumWindows(windowEnumerationHandler, top_windows)
for i in top_windows:
if "windows title" in i[1]:
win32gui.ShowWindow(i[0],5)
win32gui.SetForegroundWindow(i[0])
time.sleep(0.01)
pass
Here is the full explanation

Related

Sikuli How to Use "while not" with "and not"

I've been trying to program my Sikuli bot to find a certain item on Google's webpage results, and then if it doesn't find either of two different things, then it needs to refresh the page.
What I've got is:
while not exists("1613966501287.png") and not exists("1613966531551.png"):
click("1613905413870.png")
wait(3)
//click(<image>) is to click the refresh button.
So far, it has been able to detect both of the images I'm asking to find and then refresh the page if it can't, so I'm assuming I've done something wrong with my logic of using while/not/and.
The current code will wait until one of the two images appear. In other words the 'while' loop will continue until bot images are not present on the screen.

How to create popup windows in html

I want to know how the pop up windows integrated into websites are built. I am trying to create one for my websites but i don't really know it is created whether they are plugins or not. Any help as to how to go about it.
Below is an example of what i want to do.
You can use hotjar.com to put a feedback box in your page, there is a lot of services that provides this feature, but hotjar gets the job done
Beginner! To make a pop-up like the one you provided, you would need to write backend code (Node.JS, PHP, Python, etc.). But for just a simple info pop-up with a button that activates the pop-up refer to this jsfiddle I created:
https://jsfiddle.net/d706dyg7/1/
$("#whateverid").click(function(){
//whatever code
});
That mean when that element is clicked blah happens.
Hope that helps,
Ben A.K.A BlackSky
P.S. If you want a solution in pure javascript and not jQuery just let me know and I will edit my fiddle!
I know I'm like .. 10 years late. But for anyone still wondering I thought I could be of some help!
If you want to do this using ONLY html and css (using a framework in visual studio like ASP.NET) for example.. here's what I did:
First, I made sure I had multiple "divs" in my code. For me specifically, I had two main ones. The first one whose id="main", and another whose id="popup" with the 'visible' property initially set to 'false' for the popup div.
Then, on whichever event you're looking for (button click for example) you'll simply set main.Visible = false and popup.Visible = true, then you could have more buttons in your popup (yes, no, cancel, confirm, etc.) which do the exact same thing, but in reverse!
The most important thing to make sure of is that you have the 'runat="server"' property in your divs so that you can access them in your CS code
Hope this was helpful! :)
Your looking for something called a modal. Depending how you wrote your HTML there are different ways of approaching this issue.
If your wrote your website in Plain HTML you can use the following tutorial to create one
www.webdesignerdepot.com/2012/10/creating-a-modal-window-with-html5-and-css3/amp/
However if you wrote your website with a library such as Bootstrap they have built in pre made modules that you can attach to your cpde. These can Ben found in the library's documentation.

Is it possible to search in PhpStorm debugger view?

Like in topic, is there any option to find something in PhpStorm Debugger view?
For example I want to find element 39001421 in:
How I can achieve this?
I don't think a simple Ctrl-F works here. Here's one way to do it.
When you hit your breakpoint, press Alt-F8 or from the menu, choose Run -> Evaluate expression. In the window that opens, simply input the expression you would like to evaluate; in your case, something like
$items[39001421]
You'll get the value you're looking for at the bottom of the window.
#LazyOne Did a great job. With his help i think that i have found most effectively way to find something in PhpStorm debugger view. (if you are curious how we were looking for that answer please read comments beneath first post)
Firstly You should shut off variable adress view. (picture 1)
Secondly You should ensure that You have got "Sort Values Alphabetically" option sellected. (dropdown menu inside "gear" icon, picture 2)
Thirdly You should expand what You want to looking in (picture 3)
Next, You can type what You want to search for, If You don't find what you want to find, simply press up or down arrow to show next "occurence".

Is there a maximum number of clicktag variables allowed in a banner ad?

So, this is pretty silly. I'm working on a banner ad that utilizes the clicktag. It's a surprisingly fancy one that uses pointroll, and when you hover over the 300x250 banner ad, it pulls up a larger one overtop of it that is bigger and much more interactive. In total, the larger banner has 29 clicktags, all using the variables "clickTag1" to "clickTag29".
The banners are all done, everything fires correctly (according to my trace statements). However, I'm in the middle of QA, testing all of the clicktags using this validator: https://flashval-temp.appspot.com/validator/ , when suddenly, it stops working after clickTag20. I thought it may have been the validator at first, so I tried other validators. No luck. I went back into my code (everything is a duplicate of one template, so the only code changes made were the changes to the string), and made sure to test it again. They're firing off just fine according to my trace statements.
Finally, and this doesn't seem to make sense to me, but I switched the variables clickTag20 and clickTag21. The button that fired off clickTag20 worked, so I assigned it clickTag21. The button that was assigned clickTag21 was the first to stop working, so I assigned it clickTag20. When I ran that through the validator, the button that was assigned to clickTag20, regardless of which button it was, worked! The one that was assigned clickTag21 never did, also regardless of which button it was fired off from.
The variable is a string of a paramObj. How does the content of that string matter? I would have assumed it was compile order, but even in that case, clickTag21 should have fired and not clickTag20. What is going on here? Has anyone else experienced this? If so, did you have a workaround? Please and thank you!!
Here is the thing... when you set a clicktag you're waiting for a flashvar. A parameter sent from the HTML to your SWF file. (more: http://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html)
Usually you'd test, if this parameter doesn't exists, the banner should do nothing, otherwise, open the link.
Turns out, and this is a guess, that these validators don't know how many clicktags you have in your flash file - or how many parameters you're waiting for - , so they pass up to 20 variables to your flash file, which is more than reasonable.
The bottom line is: if your events are working, you should be fine. Pointroll has a QA team, if something comes up, they will let you know, but as far as I can see from here, you should be fine.
Good luck

Adding a interactive gui to my VB.net application

OK. So first, I will try my best to explain so good. My friend has gotten cursed out on this forum for not explaining, so I will explain. :)
Ok so I have my program built and all. But then it hit me! Wouldn't it be better to add a news feature? One teeny tiny problem? I cant? How would I implement a interactive code into an HTML page.
Like can i connect a button to a URL that will make the program do something. Almost like you can open cydia tweaks with there identifier and url EXAMPLE: http://handleopenurl.com/scheme/cydia And then i can add urls so i can update the program, without updating the files.
Or even just a featured news thing would be nice. But how would i implement this perfectly. I tryed a webrowser, but the page is too big for it. I am good at html, not much at css, i mostly use Adobe Muse http://www.adobe.com/Muse
Last question. Kinda defies the first thing i said about having my program finished.
Is there a way i can add a plus button and make it add more buttons and more labels and all?
This would help with allowing users to customize more then what the program can handle. By The Way, its a winter board Theme Maker. So I have a bunch of icons with there bundle identifiers and I create the folders with VB.net and all that stuff. But i want users to be able to click a plus button to add MORE text boxes and file browsers.
Any ideas? Maybe DIM 1 as NewFileBrowser? But i need to move all the buttons and i need it to be able to be clicked an infinity amount of times. I can do the coding for all of these buttons, but i jest need to know how to create them <1 Move them and the button so that the button goes further down each time, and more boxes will go further down. Much help apreciated. THANKS:)
EDIT:
Are you trying to say that you're wondering how to have a web browser control in a vb.net >app, which displays a web page, and when a button is clicked on the page, your app detects >it and does something? – Thraka
That sums up the top part. I am using windows forms, and it is coded in VB.net
If you get the object you want, like the button, you can hook the event and have it call code in your form.
Find the object using the Browser.Document.GetElementById method.
With that object, add an event handler to the Click event.
See http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelementeventhandler(v=vs.110).aspx for information about the event handler used