Python Forum
Function for clicking a button within a browser
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function for clicking a button within a browser
#1
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!
Reply
#2
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
Reply
#3
Consider that this involves an image recognition so it can be not so fast as you eventually need
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
(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 need
Thanks. 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?
Reply
#5
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#6
(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?
Reply
#7
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Sad Selenium: can't open a new window after clicking a button and I don't know why noahverner1995 0 1,985 Jan-22-2022, 09:55 AM
Last Post: noahverner1995
  Clicking Every Page and Attachment on Website shoulddt 1 1,748 Jul-09-2021, 01:08 PM
Last Post: snippsat
  Use a button in Tkinter to run a Python function Pedroski55 4 3,269 Jun-28-2020, 05:02 AM
Last Post: ndc85430
  Function assigned at a button in tkinter riccardoob 9 4,187 Oct-06-2019, 11:14 AM
Last Post: riccardoob
  Using IDLE, bug when clicking code StarBasket 4 2,477 Jul-31-2019, 12:30 PM
Last Post: Malt
  How to automate the clicking of GUI's menu? Hypermesher 3 3,224 Jul-26-2019, 08:55 AM
Last Post: Malt
  Pop up the Python shell after clicking a window aking76 0 2,152 Sep-18-2018, 02:27 PM
Last Post: aking76
  How to trigger a function by clicking the left mouse click? HelloBoyz 1 9,420 Jun-29-2017, 09:43 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020