Hello,
I would like to ask for a help.
I'm a noob and came across AHK thanks to one game and one of my team mates.
He provided me with a script which worked perfectly fine until now.
The game however changed it's logic regarding a "collect button". Sometimes appears the old one (collect_button1.png), sometimes a new one(collect_button2.png).
I've tried to figure out how to add the new collect button into the below function so that in case the new button appears, the script will recognise it as well and click on it (exactly as by the old button), but unfortunately without any success.
Could someone please help me to add the new button (collect_button2.png) into the below function?
Here is the original function for the collect button (collect_button1.png - in green).
collectThrophy() {
; wait for victory or defeat flag
wait = 1
max_try = 0
while wait {
; exit loop if we made 100 tries (30s)
if max_try >= 100
return 0
; search for defeat
ImageSearch, X, Y, 0, 0, A_ScreenWidth, A_ScreenHeight, images/flag_defeat.png
wait = %ErrorLevel%
; if we are defeated, don't click on 1st trophy location
if wait = 0
{
Click X, Y
return 0
}
Sleep, 300
ImageSearch, X, Y, 0, 0, A_ScreenWidth, A_ScreenHeight, images/flag_victory.png
wait = %ErrorLevel%
max_try += 1
}
; wait for collect button
wait = 1
max_try = 0
while wait {
; exit loop if we made 20 tries (16s)
if max_try >= 20
return 0
; click on first throphy
Click 510, 465
Sleep, 500
; collect button
ImageSearch, X, Y, 0, 0, A_ScreenWidth, A_ScreenHeight, images/collect_button1.png
wait = %ErrorLevel%
Sleep, 300
max_try += 1
}
; if image was found move cursor on the button and click
MouseMove X + 20, Y + 7
Click
; search for out of slot flag
Sleep, 500
ImageSearch, X, Y, 0, 0, A_ScreenWidth, A_ScreenHeight, images/flag_not_enough_slots.png
; if out of slots flag was found exit
if ErrorLevel = 0
{
return 1
}
}
Many thanks in advance.
A.
- Home Board index AutoHotkey Ask For Help Gaming
- Search
-
- It is currently 19 Jan 2021, 07:59
- All times are UTC-05:00
Multiple image search
Ask gaming related questions
Jump to
- AutoHotkey Foundation
- About This Community
- Forum Issues
- AutoHotkey
- Ask For Help
- Gaming
- AutoHotkey v2 Help
- Scripts and Functions
- Gaming
- AutoHotkey v2 Scripts and Functions
- Tutorials
- Tips and Tricks
- Wish List
- Suggestions on documentation improvements
- Bug Reports
- AutoHotkey v2 Development
- AutoHotkey_H
- Ask For Help
- Development
- Announcements
- Editors
- AHK Studio
- Pulovers Macro Creator
- SciTE4AutoHotkey
- AutoGUI
- General Discussion
- General
- Other Utilities & Resources
- Other Programming Languages
- C/C++
- ASM
- C#
- Offtopic
- RPA
- Other languages
- Deutsch (German)
- Ich brauche Hilfe
- Spiele
- Skripte und Funktionen
- Tutorials
- Tooltime
- Allgemeines
- 中文 (Chinese)
- 请求帮助
- 脚本函数
- 教程资料
- 相关工具
- 其他
- Español (Spanish)
- Pedir Ayuda
- Automatización de Juegos
- Scripts y Funciones
- Tutoriales
- Otras Utilidades y Recursos
- General
- Русский (Russian)
- Помощь
- Скрипты для Игр
- Скрипты и библиотеки
- Статьи и руководства
- Прочие ресурсы и ПО.
- Свободное общение
- Français (French)
- J'ai besoin d'aide
- Scripts et Fonctions
- Tutoriels
- Autres Utilitaires et Ressources
- Hors Sujet
- Português (Portuguese)
- Ajuda e Suporte Geral
- Scripts e Funções
- Tutoriais
- Outras Ferramentas e Recursos
- Outros Assuntos
- 한국어 (Korean)