simple click button in telegram?

Get help with using AutoHotkey and its commands and hotkeys
densch
Posts: 86
Joined: 29 May 2018, 15:10

simple click button in telegram?

22 Jan 2021, 19:00

Hi,
I am currently totally failing on a simple thing:
I am in the telegram desktop app and am interacting with a bot, where I want each 5 minutes to click the "claim" button presented by the bot.

so I did my thing down there but it doesnt seem to work.

got ahk_class and ahk_id with windows spy, so it should be legit.
same for the coordinates, they are literally in the middle of the damn button.

but no matter which controlclick I use, it doesnt seem to do anything.
the tooltips show up at the expected time too, so the script doesnt seem to encounter any error.

it jsut simply doesnt work, no idea if the click isnt performed or if for whatever reason telegram doesnt register the clicks or ignores them.

I am using controlclick isntead of nomral click or send event cause I want the button to be clicke whent he telegram window is minimized in the background, so I can do my normals tuff in the foreground.

any idea why this might not work?

Code: Select all

SetControlDelay -1

time:=0


while true{

ControlClick,1118 900,ahk_ip 88984,,Left,1,D NA Pos,

ControlClick,1118 900,ahk_class Qt5152QWindowIcon,,Left,1,D NA Pos,

 Tooltip, button down
Sleep, 500


ControlClick,1118 900,ahk_ip 88984,,Left,1,U NA Pos,

ControlClick,1118 900,ahk_class Qt5152QWindowIcon,,Left,1,U NA Pos,
 Tooltip, button up
 
 
ControlClick,1118 900,ahk_class Qt5152QWindowIcon,


Random, time,300000,501000
	sleep, time

}
User avatar
boiler
Posts: 6872
Joined: 21 Dec 2014, 02:44

Re: simple click button in telegram?

22 Jan 2021, 19:57

You have ahk_ip instead of ahk_id in your script, but more importantly, the window ID is different every time the window is created, so getting the ID and putting that in your script will not be able to identify that window the next time you run that program.

Also, your ControlClick by location syntax is not correct. You have just the numbers representing the coordinates, but as the documentation shows, they need to be preceded by x and y.
densch
Posts: 86
Joined: 29 May 2018, 15:10

Re: simple click button in telegram?

22 Jan 2021, 21:00

oh, so process id is different each time?

so I'll stick with ahk_class then.

fixed some things and it seems to work now, more or less.

reloading the script somehow doesnt always make it click though, gotta let it run for an hour or so, so I'll see if it clicks every 5+ minutes.

but seems to work for the msot part so far! :-)
User avatar
boiler
Posts: 6872
Joined: 21 Dec 2014, 02:44

Re: simple click button in telegram?

22 Jan 2021, 21:31

Yes, both the window ID (also known as the window handle or HWND), which is used with ahk_id, and the process ID, used with ahk_pid, change every time. (Note that ahk_ip is not correct for either of them.) That doesn’t mean they’re not useful. You just don’t hard code in the values into your script because they will be different each time the program is run. They are useful for when their values are found dynamically by the script.

That also doesn’t mean you should only use ahk_class as that can often be the same across programs. You can use the process name (e.g., ahk_exe notepad.exe) and the window title itself to help ensure you are uniquely identifying the window of interest.

Return to “Ask For Help”

Who is online

Users browsing this forum: braunbaer, Google [Bot], mikeyww, scissors, swub, yumuffin and 53 guests