Search code examples
google-chromegoogle-colaboratory

How to enable auto click in google colab?


I need to enable a script that clicks every N second on my google colab session within my Chrome browser, so that the session doesn't get deleted. I have encountered this post here, but it doesn't give full details so I don't know how to implement it. Can someone provide some more info?


Solution

  • Using a Chrome extension might be an easy solution, you can download something like Auto Clicker - AutoFill. Once you have it proceed as follows:

    1.) Right-click somewhere within your google colab session, preferably on an icon that is interactive so that you can verify that the action is working (in this example I use the looking glass). The right-click will display a drop-down menu, go to "Auto Click - AutoFill" -> "Configure for this field"

    enter image description here

    2.) You will be led to a menu. There are 3 things that you want to adjust:

    • "Init wait" which controls with what delay the clicking action to start after the google colab session is loaded. I have used a value of 10 secs
    • "Repeat" is the number of repeated clicks. It doesn't need to be a high number. I have set it to 50, meaning after 50 clicks there will be no more click actions
    • "R-interval" is the repetition interval, you can set it to something high, I have used the value 60*30=1800sec=half an hour

    So in my case I will have 51 clicks (1+50 repetitions) on the looking glass, each click spaced 30 min away from the next and the first click is delayed by 10 sec.

    enter image description here

    3.) To activate the action you should go back to the google colab notebook and reload it. Make sure to have done a save. The best is to wait up the delay time and validate that the first click gets executed.

    Sometimes when reloading the session the action sequence gets initialized again, sometimes not. If you want to be sure, create a new configuration as described above.

    If you want to delete the clicking configuration you can do it from the 3 dots in the configuration menu.