Hi! I need help with if function in duration Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
HazelnutMango
Posts: 8
Joined: 01 Aug 2019, 17:14

Hi! I need help with if function in duration

01 Aug 2019, 18:09

Hello! Thanks for checking this post out. I have no clue on how to do this. Anyway, here's what I want to happen:

I want to make a script that executes a command when it sees a particular color. Easy enough, I know how to do that.

What I don't know is how I could let it execute it for like, 3 times, or 4 times, (it depends).

FOR EXAMPLE - Let's say the execution is {Enter}

I want it to press enter when it sees the color but will only do this 3 times. On the 4th time it sees the color, it will do nothing but continue with the script.

I hope you understand what I'm trying to do. Hahaha!

Anyway, here's the script I made so far.

Code: Select all

global dialogbox_color := 0xF7F7F7
global dialog_x := 457
global dialog_y := 496

global times := 4

F8::
Loop
{
	Loop, %times%
	{
		DialogBox := checkDialogBox()
		if (DialogBox = 1)
		{
			Send, {Enter}
		}
	}
	send, BACK TO LOOP IN 5
	sleep, 5000
}

checkDialogBox()
{
	{
		PixelGetColor, color, %dialog_x%, %dialog_y%
		if (color = dialogbox_color)
			return 1
	}
	return 0
}
hd0202
Posts: 163
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Hi! I need help with if function in duration  Topic is solved

01 Aug 2019, 20:52

Code: Select all

F8::
Loop
{
	enter_sent = 0
	Loop
	{
		DialogBox := checkDialogBox()
		if (DialogBox = 1)
		{
			Send, {Enter}
			enter_sent++
			if (enter_sent = times)
				break
		}
	}
	send, BACK TO LOOP IN 5
	sleep, 5000
}
Hubert
HazelnutMango
Posts: 8
Joined: 01 Aug 2019, 17:14

Re: Hi! I need help with if function in duration

01 Aug 2019, 21:41

Thanks you for the quick reply @hd0202 !

I managed to fix and figure out a way to not use a counter though I really appreciate your help!

Here's what I came up with:

Code: Select all

global dialogbox_color := 0xF7F7F7
global dialog_x := 457
global dialog_y := 496

global times := 4

F8::
Loop
{
	Loop, %times%
	{
		Checkbox:
		DialogBox := checkDialogBox()
		if (DialogBox != 1)
		{
			Goto, Checkbox
		}
		else
		{
			Send, {Enter}
		}
	}
	send, BACK TO LOOP IN 5
	sleep, 5000
}

checkDialogBox()
{
	{
		PixelGetColor, color, %dialog_x%, %dialog_y%
		if (color = dialogbox_color)
			return 1
	}
	return 0
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Sneakysnail, TAC109 and 40 guests