Click on facebook LIKE button script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AndyRal123
Posts: 21
Joined: 10 Oct 2020, 12:32

Click on facebook LIKE button script

Post by AndyRal123 » 10 Oct 2020, 12:38

Hello, is there a way to click on facebook like button under the post via script?
I use this, but it doesn't find an image:

Code: Select all

!1::
CoordMode, Pixel
ImageSearch, xpos, ypos, 0, 0, A_ScreenWidth, A_ScreenHeight, F:\done\like.png
if (ErrorLevel)
{
	MsgBox, 16, Error, Not found.
	return
}
Click, %xpos%, %ypos%
return
[Mod edit: [code][/code] tags added.]


I include the image after cropping:
https://drive.google.com/file/d/1kC8PjGqFMAhLd_5h3sGNQ3BAOxE953i9/view?usp=sharing


Any help would be great, coz im stuck.
Cheers
Attachments
like.png
like.png (690 Bytes) Viewed 653 times
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: Click on facebook LIKE button script

Post by boiler » 10 Oct 2020, 13:48

Try cropping it to just a small rectangular portion of that image that doesn’t have any transparent pixels.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Click on facebook LIKE button script  Topic is solved

Post by mikeyww » 10 Oct 2020, 14:02

This worked for me using my own screenshot of the "like" hand (I tried a MouseMove). You don't need CoordMode for this purpose.

Code: Select all

!1::
ImageSearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, [pathToImage]
If ErrorLevel {
 MsgBox, 64, Error, Image not found.
 Return
}
x += 10, y += 10
MouseMove, %x%, %y%
Return
Note that if you are using an ImageSearch and a Click, they should have the same CoordMode for Pixel and Mouse. Your script does not do that-- so best to remove CoordMode.

Incidentally, you might be able to improve search speed by looking just inside the window of interest, rather than the entire screen. WinGetPos can find the window's dimensions if needed.
AndyRal123
Posts: 21
Joined: 10 Oct 2020, 12:32

Re: Click on facebook LIKE button script

Post by AndyRal123 » 11 Oct 2020, 12:14

mikeyww wrote:
10 Oct 2020, 14:02
This worked for me using my own screenshot of the "like" hand (I tried a MouseMove). You don't need CoordMode for this purpose.

Code: Select all

!1::
ImageSearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, [pathToImage]
If ErrorLevel {
 MsgBox, 64, Error, Image not found.
 Return
}
x += 10, y += 10
MouseMove, %x%, %y%
Return
Note that if you are using an ImageSearch and a Click, they should have the same CoordMode for Pixel and Mouse. Your script does not do that-- so best to remove CoordMode.

Incidentally, you might be able to improve search speed by looking just inside the window of interest, rather than the entire screen. WinGetPos can find the window's dimensions if needed.
----------------
mikeyww thank You kindly for reply, it is very helpful for me :)
But there are 2 things:
1. If we use mouse move only where is the click on like button then?
2. Still it shows image not found. I have already tried using portion of image, for example only thumb part, or even only line of finger, but it doesn't work neither, to find a like button. For standard one i sent in attachment i cropped in photoshop to fit crop to image lines, made transparent background, left it white inside, saved as png - interlaced. Maybe it's something wrong with reference image. Before the path of image there is a space on purpose.


Any help would be really appreciated and returned if possible.
Greetings :thumbup:
AndyRal123
Posts: 21
Joined: 10 Oct 2020, 12:32

Re: Click on facebook LIKE button script

Post by AndyRal123 » 11 Oct 2020, 12:27

boiler wrote:
10 Oct 2020, 13:48
Try cropping it to just a small rectangular portion of that image that doesn’t have any transparent pixels.
Hello and thank You for reply :)

Well, I have already tried using portion of image, for example only thumb part, or even only line of finger, but it doesn't work neither, to find a like button. For standard one i sent in attachment i cropped in photoshop to fit crop to image lines, made transparent background, left it white inside, saved as png - interlaced. Maybe it's something wrong with reference image. So i am stuck and i dont know how to crop it correctly maybe. I assume to delete white background around thumb, and leave it transparent (empty) and inside the thumb I leave original - white. I have another idea - the thumb changes to grey style when you move the mouse over it on desktop facebook. So maybe it can be worth noting, but not in case of searching i guess, but maybe clicking.


I would be truly grateful for help.
regards
Attachments
like.png
like.png (690 Bytes) Viewed 611 times
2.png
2.png (1.07 KiB) Viewed 611 times
5.png
5.png (88 Bytes) Viewed 611 times
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: Click on facebook LIKE button script

Post by boiler » 11 Oct 2020, 13:36

No, don’t delete background and leave it transparent. You have to crop it so there are no transparent pixels. Perhaps some of the other pixels are semi-transparent and that’s why it’s not finding it. Don’t crop it to parts near the edge like the finger. Crop a piece of the middle like some of the vertical line on the wrist.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Click on facebook LIKE button script

Post by mikeyww » 11 Oct 2020, 14:10

like.png
like.png (885 Bytes) Viewed 601 times
I have attached the image that I used. My image saving did nothing except crop. I agree with @boiler. In addition: never use a lossy format such as JPG for an image match. Use a lossless image format such as PNG (that is usually the best choice of lossless format).

Why? Saving to JPG alters the image itself (unless your software specifically does a lossless JPG save), via discarding data during image compression.

I see you have PNG here, so you should be OK here. I agree that your transformation of the transparency may be the issue at hand.

I used MouseMove just to see if my code worked. You would want the Click that you had originally.
AndyRal123
Posts: 21
Joined: 10 Oct 2020, 12:32

Re: Click on facebook LIKE button script

Post by AndyRal123 » 28 Oct 2020, 10:15

mikeyww wrote:
11 Oct 2020, 14:10
like.png

I have attached the image that I used. My image saving did nothing except crop. I agree with @boiler. In addition: never use a lossy format such as JPG for an image match. Use a lossless image format such as PNG (that is usually the best choice of lossless format).

Why? Saving to JPG alters the image itself (unless your software specifically does a lossless JPG save), via discarding data during image compression.

I see you have PNG here, so you should be OK here. I agree that your transformation of the transparency may be the issue at hand.

I used MouseMove just to see if my code worked. You would want the Click that you had originally.


Thank You kindly for tips, code and an image that You sent. It was truly helpful and I appreciate that You wrote :) It worked and I learned something new with Your help, thank You and good luck :) If I can repay to You anyhow, let me know, greetings :)
AndyRal123
Posts: 21
Joined: 10 Oct 2020, 12:32

Re: Click on facebook LIKE button script

Post by AndyRal123 » 28 Oct 2020, 10:18

boiler wrote:
11 Oct 2020, 13:36
No, don’t delete background and leave it transparent. You have to crop it so there are no transparent pixels. Perhaps some of the other pixels are semi-transparent and that’s why it’s not finding it. Don’t crop it to parts near the edge like the finger. Crop a piece of the middle like some of the vertical line on the wrist.
Thank You for the tip. Eventually it found the whole image, but cropping for the part of image is also nice solution , thank You and good luck :) This is my first time on forum and I am very happy with Your help, cheers :)
Post Reply

Return to “Ask for Help (v1)”