![]() |
Function for clicking a button within a browser - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Function for clicking a button within a browser (/thread-9095.html) |
Function for clicking a button within a browser - NikonNorm - Mar-20-2018 I'm wondering if anyone show me how one would write a function that clicks a button within a flash game that's in a browser. Thanks for any tips you might be able to give me! RE: Function for clicking a button within a browser - nilamo - Mar-20-2018 You could use the wacky win32api if you're on windows, but it'd probably be easier to just use the PyAutoGUI library, which has examples of how to move the mouse and click right in the docs: https://pypi.python.org/pypi/PyAutoGUI RE: Function for clicking a button within a browser - wavic - Mar-20-2018 Consider that this involves an image recognition so it can be not so fast as you eventually need RE: Function for clicking a button within a browser - NikonNorm - Mar-21-2018 (Mar-20-2018, 11:13 PM)wavic Wrote: Consider that this involves an image recognition so it can be not so fast as you eventually needThanks. That's kind of what I assumed. However, I'm not looking for this info for any real serious reason. Just trying to take my limited knowledge of Python to the next level by finding random, while possibly completely unnecessary, things I can make work. Doing exercises in a book only goes so far for me. I need to branch out and start thinking of different things I can try on my own, even if there is no real purpose for it. (Mar-20-2018, 09:03 PM)nilamo Wrote: You could use the wacky win32api if you're on windows, but it'd probably be easier to just use the PyAutoGUI library, which has examples of how to move the mouse and click right in the docs: https://pypi.python.org/pypi/PyAutoGUI Thank you! This sounds very interesting. Here's what I'm trying to do. (it's going to come off as an attempt to cheat at a game, when in reality the game means nothing to me, just trying to come up with different "problems" I can try to fix on my own) A friend of mine was showing me one of those stupid IDLE clicker games the other day. While sitting down to think up something I can try to make work with Python I thought of a program that allows you to click on one of the buttons in certain situations. For example: There's a stock market type part of the game. They give you a percentage for the likeliness of an investment failing. I would like to find a way to have a program running in the background that purchases said investment when the probability of failure is less that 33%. Obviously that involves taking the percentage into a variable, and telling the mouse to move and where to click when said variable is < 33. Is this even possible? To extract a variable from a flash game like that? RE: Function for clicking a button within a browser - wavic - Mar-21-2018 Can't tell. I used pyautogui a few times but there was no flash. Try! That is the fun part. Not to know what will happen. :D RE: Function for clicking a button within a browser - NikonNorm - Mar-21-2018 (Mar-21-2018, 01:57 AM)wavic Wrote: Can't tell. I used pyautogui a few times but there was no flash. Try! That is the fun part. Not to know what will happen. :D I guess what I don't know right now is how to access the variable that is the probability. Are there functions that allow me to pull numbers off an image if I tell it where the numbers are? RE: Function for clicking a button within a browser - Grok_It - Jun-06-2018 I use pyautogui. It can click on anything on the screen you just need to know where it is. It can also take screenshots and find image elements. You can make images of the numbers and search for those. |