image search hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
exbuzz
Posts: 5
Joined: 14 May 2018, 06:22

image search hotkey

14 May 2018, 06:48

I have made a bot that buys me something on the supreme website when it drops clothes. I have had great success with it and have set it up so when I get onto the page on which the clothe item I want is on, I press '=' and it carries out the rest. with the use of image search and {tab} it has finally been able to press 'add to cart' then navigate to 'checkout now' as my address is already saved, it then navigates to relevant card information and presses process payment. however I would like it to, instead of being triggered by the '=' sign, to be triggered when it recognises the add to cart item on the page. This would mean all I would have to do is click the item I want. I have had no luck with this alteration. I will copy it below and would be really grateful if someone could send it back to me so it detects the addtocart.png and this triggers the rest of the program. Thanks!

Code: Select all

=::
SetWorkingDir %A_ScriptDir%
SetWorkingDir, ‪C:\Users\bdanz\Documents\AHK
coordmode, mouse, screen
coordmode, pixel, screen
  ImageSearch, FoundX, FoundY, 0,380, 1905, 920, ‪C:\Users\bdanz\Documents\AHK\addtobasket.png
  ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\addtobasket.png
mousemove, %FoundX%, %FoundY%
click (by itself)
sleep, 150
  ImageSearch, FoundX, FoundY, 473, 463, 620, 493, ‪C:\Users\bdanz\Documents\AHK\checkoutnow.png
  ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\checkoutnow.png
mousemove, %FoundX%, %FoundY%
click (by itself)
sleep, 1100
ImageSearch, FoundX, FoundY, 473, 463, 620, 493, ‪C:\Users\bdanz\Documents\AHK\cardnumber.png
  ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\cardnumber.png
mousemove, %FoundX%, %FoundY%
click (by itself)	
send, 1234 5678 9012 3456
sleep, 5
  send {tab}
  send {enter}
  send {down 5}
  send {enter}
sleep, 5
  send {tab}
  send {enter}
  send {down 1}
  send {enter}
sleep, 10
  send {tab}
send, 123
ImageSearch, FoundX, FoundY, 0, 678, 1918, 1045, C:\Users\bdanz\Documents\AHK\terms.png
  ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\terms.png
mousemove, %FoundX%, %FoundY%
Click (by itself)
sleep, 10
ImageSearch, FoundX, FoundY, 950, 775, 1918, 1045, ‪C:\Users\bdanz\Documents\AHK\processpayment.png
  ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\processpayment.png
mousemove, %FoundX%, %FoundY%
Click (by itself)
return
^p::pause
Mod edit: Added code tags.
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: image search hotkey

14 May 2018, 08:57

Give it a try :)

Code: Select all

=::
credit_card := "1234 5678 9012 3456"
credit_card_pin := "1234"
SetWorkingDir %A_ScriptDir%
SetWorkingDir, ?C:\Users\bdanz\Documents\AHK
coordmode, mouse, screen
coordmode, pixel, screen
while(FoundX_1 == null)
{
  ImageSearch, FoundX_1, FoundY, 0,380, 1905, 920, ?C:\Users\bdanz\Documents\AHK\addtobasket.png
  ImageSearch, FoundX_1, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\addtobasket.png
}
mousemove, %FoundX_1%, %FoundY%
click 
sleep, 150
while(FoundX_2 == null)
{
  ImageSearch, FoundX_2, FoundY, 473, 463, 620, 493, ?C:\Users\bdanz\Documents\AHK\checkoutnow.png
  ImageSearch, FoundX_2, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\checkoutnow.png
}
mousemove, %FoundX_2%, %FoundY%
click 
sleep, 1100
while(FoundX_3 == null)
{
ImageSearch, FoundX_3, FoundY, 473, 463, 620, 493, ?C:\Users\bdanz\Documents\AHK\cardnumber.png
  ImageSearch, FoundX_3, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\cardnumber.png
}
mousemove, %FoundX_3%, %FoundY%
click 
send, %credit_card%
sleep, 5
  send {tab}
  send {enter}
  send {down 5}
  send {enter}
sleep, 5
  send {tab}
  send {enter}
  send {down 1}
  send {enter}
sleep, 10
  send {tab}
send, %credit_card_pin%
while(FoundX_4 == null)
{
ImageSearch, FoundX_4, FoundY, 0, 678, 1918, 1045, C:\Users\bdanz\Documents\AHK\terms.png
  ImageSearch, FoundX_4, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\terms.png
}
mousemove, %FoundX_4%, %FoundY%
Click 
sleep, 10
while(FoundX_5 == null)
{
ImageSearch, FoundX_5, FoundY, 950, 775, 1918, 1045, ?C:\Users\bdanz\Documents\AHK\processpayment.png
  ImageSearch, FoundX_5, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\processpayment.png
}
mousemove, %FoundX_5%, %FoundY%
Click 
return
^p::pause
exbuzz
Posts: 5
Joined: 14 May 2018, 06:22

Re: image search hotkey

14 May 2018, 11:19

bro, you are an absolute hero, works great,
the only issue is that when it completes the checkout and the script finishes, with ahk still open, it cannot repeat itself, as in, if I go onto the site again it wont detect add to basket. Also, if i press equals again, after the script has finished its first use, it has random mouse movements and types the card number and pin randomly. Thank you for your help so far, you have been amazing!
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: image search hotkey

14 May 2018, 14:55

Try it again i added a reload at the end ;)

Code: Select all

=::
credit_card := "1234 5678 9012 3456"
credit_card_pin := "1234"
SetWorkingDir %A_ScriptDir%
SetWorkingDir, ?C:\Users\bdanz\Documents\AHK
coordmode, mouse, screen
coordmode, pixel, screen
while(FoundX_1 == null)
{
  ImageSearch, FoundX_1, FoundY, 0,380, 1905, 920, ?C:\Users\bdanz\Documents\AHK\addtobasket.png
  ImageSearch, FoundX_1, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\addtobasket.png
}
mousemove, %FoundX_1%, %FoundY%
click 
sleep, 150
while(FoundX_2 == null)
{
  ImageSearch, FoundX_2, FoundY, 473, 463, 620, 493, ?C:\Users\bdanz\Documents\AHK\checkoutnow.png
  ImageSearch, FoundX_2, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\checkoutnow.png
}
mousemove, %FoundX_2%, %FoundY%
click 
sleep, 1100
while(FoundX_3 == null)
{
ImageSearch, FoundX_3, FoundY, 473, 463, 620, 493, ?C:\Users\bdanz\Documents\AHK\cardnumber.png
  ImageSearch, FoundX_3, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\cardnumber.png
}
mousemove, %FoundX_3%, %FoundY%
click 
send, %credit_card%
sleep, 5
  send {tab}
  send {enter}
  send {down 5}
  send {enter}
sleep, 5
  send {tab}
  send {enter}
  send {down 1}
  send {enter}
sleep, 10
  send {tab}
send, %credit_card_pin%
while(FoundX_4 == null)
{
ImageSearch, FoundX_4, FoundY, 0, 678, 1918, 1045, C:\Users\bdanz\Documents\AHK\terms.png
  ImageSearch, FoundX_4, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\terms.png
}
mousemove, %FoundX_4%, %FoundY%
Click 
sleep, 10
while(FoundX_5 == null)
{
ImageSearch, FoundX_5, FoundY, 950, 775, 1918, 1045, ?C:\Users\bdanz\Documents\AHK\processpayment.png
  ImageSearch, FoundX_5, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_MyDocuments%\AHK\processpayment.png
}
mousemove, %FoundX_5%, %FoundY%
Click 
Reload
return
^p::pause
exbuzz
Posts: 5
Joined: 14 May 2018, 06:22

Re: image search hotkey

17 May 2018, 10:00

Hi Qysh,
Sorry for late reply, just wanted to thank you. You have been an absolute lifesaver.
All the best,
ben

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 137 guests