Help with a Background script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Help with a Background script

12 Sep 2019, 23:58

Im here in search of help because i have been looking all day for this without any results.

I would like to create a script to repeatedly click in a specific location in a windows wich needs to be in the background or minimised, for me to be able to work while the script is clicking in the background window.

I have tried with ControlClick but it doesnt work as intended.

Other possibility could be to hide or make the windows invisible but keep it active.

I would appreciate a lot your help!
User avatar
Chunjee
Posts: 1429
Joined: 18 Apr 2014, 19:05
Contact:

Re: Help with a Background script

13 Sep 2019, 10:48

Does the script otherwise work when the window is open but not active in the foreground?

I believe that was my experience with ControlClick, but it may depend on the app being clicked.
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 11:25

Chunjee wrote:
13 Sep 2019, 10:48
Does the script otherwise work when the window is open but not active in the foreground?

I believe that was my experience with ControlClick, but it may depend on the app being clicked.
Is a browser windows, and i dont have any script at the moment, but i imagine it may work
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script

13 Sep 2019, 13:02

If that browser is Google Chrome, then give up. There's no way of clicking on a Chrome window unless it's focused.

Your only option is to inject Javascript into the desired page and simulate a click event. But that's not a true click, so depending on the page, that might not work either.
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 13:06

Getfree wrote:
13 Sep 2019, 13:02
If that browser is Google Chrome, then give up. There's no way of clicking on a Chrome window unless it's focused.

Your only option is to inject Javascript into the desired page and simulate a click event. But that's not a true click, so depending on the page, that might not work either.
I may change browsers if that helps, or i may try the javascript, but im clueless about that, how it should be or how may look for it?
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script

13 Sep 2019, 13:29

Try ControlClick with Internet Explorer, I believe that should work.
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 14:33

Getfree wrote:
13 Sep 2019, 13:29
Try ControlClick with Internet Explorer, I believe that should work.
im not able to use Internet explorer for this. I tried with Microsoft edge tho and the windows resizes and it doesnt work
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script

13 Sep 2019, 14:50

There's no generic solution for what you want to do.
If you describe in detail what you want to accomplish (instead of how you want to do it), an ad-hoc solution can be found.
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 14:52

Getfree wrote:
13 Sep 2019, 14:50
There's no generic solution for what you want to do.
If you describe in detail what you want to accomplish (instead of how you want to do it), an ad-hoc solution can be found.
May i ask you to give me your discord or something to talk faster? as im new i have to wait till an administrator approves every message
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script

13 Sep 2019, 15:24

Just do a Google search with this text click on page site:autohotkey.com and you'll get lots of examples.
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 15:30

Getfree wrote:
13 Sep 2019, 15:24
Just do a Google search with this text click on page site:autohotkey.com and you'll get lots of examples.
I have been already searching, and didnt find anything useful
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script

13 Sep 2019, 16:07

May be it would be easier to send clicks to a focused window, and you do your work and stuff on a different desktop.
Read this topic for the different methods of doing that:
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=67844

If you insist in doing the clicks on an unfocused Chrome window, you can use the library chrome.ahk which you can find here:
https://www.autohotkey.com/boards/viewtopic.php?t=42890
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script

13 Sep 2019, 16:15

Here, yet another interesting topic about injecting Javascript into Chrome:
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=67687&p=290936#p290936
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 17:46

Thats a lot of very useful information, Thankyou. But i think i almost got this

Code: Select all

SetTitleMatchMode, 2
#SingleInstance, Force
#NoEnv
SendMode Input
sug := 0

NumpadDiv::SetTimer, Macro, % (sug := !sug) ? "25" : "Off"

Macro:
ControlClick, x1477 y667,  Page,,,, Pos
 return
thats my code and now is clicking on the background, the only problem is that clicks in wherever my mouse is in the active window position, so its ignoring my cordinates, any idea of why it could be?
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: Help with a Background script  Topic is solved

13 Sep 2019, 20:43

There was a reason for saying this:
Getfree wrote:
13 Sep 2019, 13:02
If that browser is Google Chrome, then give up. There's no way of clicking on a Chrome window unless it's focused.
Chrome's input system is centralized. All windows belong to a single thread and that thread handles the input to THE active tab in the focused window.

But wait, you might have heard that Chrome is a multi-process browser, where each tab is a process on its own and that's why it's so stable and crashes on one tab don't affect others and blah, blah, blah...

What exist in different processes are the webpages, not the windows nor the tabs. Each visible page is rendered on a different process and the resulting image is sent to the one thread that owns all windows. That one thread, as it owns all windows, is responsible for handling the input messages sent to all of them. And that thread has one policy: "ALL INPUT GOES TO THE ONE FOCUSED TAB. PERIOD."
lavatario
Posts: 8
Joined: 12 Sep 2019, 23:50

Re: Help with a Background script

13 Sep 2019, 21:05

Thankyou for all your answers, i managed to get the solution!, Have a great day

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 329 guests