@mikeyww I am facing problems with your code.
https://gyazo.com/89ed0cf83e43b57189f569b2b8116643 Video on why your code is not doing the job for me at all
The clicks are not exactly on the image and are off, I dont know why it is that way. Btw I trimmed your code and in this message, I will put the code that I used. As I said in the post, the code I gave first is merely experimental, I will have a bunch of images in the list and etc.. As I also said, I want the script to run as long as I am holding g and when I stop holding it will stop. I believe your missed this part because your code doesnt allow me this. With your code, I have random stuff popping on my screen on white, its numbers, I dont want that. I also dont need error message boxes. When I used your code, it made my clicks unstable for some reason, i have no idea why that happened.
TLDR'ing my earlier message : I want two combinations with one working while i hold down the key "g" and the other working while i hold down the key "j".
the first combination will work in this way: So as can be seen in the video, all my images that im trying to find are located in a small game menu that can be opened with clicking at a game button which for this combination fyi, "add bonus." What the code will do is, when I hold g, it will send 1 click to add bonus button's coordinates which I will set myself. So its a simple click on coordinate. So then, the menu will open, and so the code might find no images from my list in the menu, which in that case will do nothing. And I mean it, strictly nothing. If it finds multiple images, it will click at one of them randomly. So now i want to say, the way the game works is as you can see in the video, when you click at lets say, "goal bonus." from the add bonus menu, what happens is that goal bonus gets added and it cant get added again, the image of it also changes to a darkish tone, and so it cant be clicked again by the script anyways. Also when you add a bonus or a clause from the menus, the menu disappears so you have to open it again. So here comes my crucial request which your script doesnt fulfill, after the script clicks on a found image, it will send click to the coordinate of the "add bonus" button which again, I will set. And remember all of this is happening as I'm holding the key g and if i stop holding it, the whole thing stops. So then, it will look for images again and this will repeat till it cant find images. In that case, as you'd imagine, the menu is left open and so he strictly doesnt take any action if it cant find anything but the click on coordinate at the start.
Now for the second combination, its literally the same. Refer to the video here:
https://gyazo.com/216f1e8458f1af8688ba7c1626e6ddda - So what i want is that this time it will work as i hold down the "j" button. This time, which you can see on the video, we will be sending the click on coordinate at the start to the "add clause" button. Now here, we will have mousehover function i believe. There are combined goals and assists, there are goals, and, there are assists. When you hover on them, as can be seen in the video, a list of numbers pop up next to them. So for the three clauses aka combined g/a, g, and, a, (im saying them in short terms) the mouse will just hover them and choose 2 clauses from the new list of numbers for each clause. If you didnt really understand me, think of it this way: so in the video, forward it a little to the point where im doing stuff with the add clause, so okay all mouse movements im doing there i want them to be automated. I hope this visually breaks it down for u because i got very long with my explanation.
Code: Select all
#Requires AutoHotkey v1.1.33.11
dir := A_Desktop "\Yeni klasör"
imageList := ["goalbonus.png", "assistbonus.png"]
$g::
CoordMode Mouse
CoordMode Pixel
tip := ""
For each, image in imageList {
; ImageSearch, FoundX, FoundY, 1114, 328, 1450, 800, % "*10 " image
ImageSearch px, py, 0, 0, A_ScreenWidth, A_ScreenHeight, % dir "\" image
ToolTip % tip .= ErrorLevel
Switch ErrorLevel {
Case 0:
MouseGetPos x, y
WinActive("A")
MouseClick,, px, py
WinActivate
MouseMove x, y
}
}
Return