Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

how to automatically run a script when an image loads on web



  • Please log in to reply
64 replies to this topic
smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
sir suppose i want to run successive scripts when different images loads...on the same website...did u get my question??
that...it is automatic login..then..automatic form filll..then..automatically..detail fill in etc...thnx in advance

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Simply duplicating the code should be enough. I think this will be the easiest way for you now, but you'll have to make some tests...
[color=#008000]; This script was created using Pulover's Macro Creator[/color]

#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
CoordMode, Pixel, Screen

[color=#008000]; Make a ScreenShot with the image and place it in the same directory of the script.[/color]
[color=#FF0000]ImageFile1[/color] := "ScreenShot1.png" ; Name of the image file from screenshot.
[color=#0000FF]ImageFile2[/color] := "ScreenShot2.png" ; Name of the image file from screenshot.

F2::  [color=#008000]; Toggles search timer on/off[/color]
SetTimer, SearchImage, % If (k := !k) ? 100 : "off"
TrayTip,, % If (t := !t) ? "On" : "Off"
return

SearchImage:
ImageSearch, FoundX, FoundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %[color=#FF0000]ImageFile1[/color]%
If ErrorLevel = 0 [color=#008000] ; Put your code inside the braces below.[/color]
{
	MsgBox, 49, Continue?, Image / Pixel Found at %FoundX%x%FoundY%.`nPress OK to continue.
	IfMsgBox, Cancel
	{
		SetTimer, SearchImage, off
		TrayTip,, Off
	}
}
ImageSearch, FoundX, FoundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %[color=#0000FF]ImageFile2[/color]%
If ErrorLevel = 0 [color=#008000] ; Put your code inside the braces below.[/color]
{
	MsgBox, 49, Continue?, Image / Pixel Found at %FoundX%x%FoundY%.`nPress OK to continue.
	IfMsgBox, Cancel
	{
		SetTimer, SearchImage, off
		TrayTip,, Off
	}
}
return

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
thanks for the response sir...will try and revert...soon

smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
thanks sir..it is working..the more i get help from u the more i seek...

1. can i add a timer to the script..that is the website is already loaded..but the script waits for say the time to be 1:00 pm exactly to run itself
2. is it possible that if once executed a set a keystrokes after an image is loaded...it is (i.e. the keystrokes) are not repeated ..as the images that are loaded are similar after login.
3.though the repetition of different keystrokes continues

thanks again sir

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
In that case you'll have to use different timers for each image and stop them after execution. Use Windows Task Scheduler to execute your scripts at the time you want.
[color=#008000]; This script was created using Pulover's Macro Creator[/color]

#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
CoordMode, Pixel, Screen

[color=#008000]; Make a ScreenShot with the image and place it in the same directory of the script.[/color]
[color=#FF0000]ImageFile1[/color] := "ScreenShot1.png" ; Name of the image file from screenshot.
[color=#0000FF]ImageFile2[/color] := "ScreenShot2.png" ; Name of the image file from screenshot.

F2::  [color=#008000]; Toggles search timer on/off[/color]
SetTimer, [color=#FF0000]SearchImage1[/color], % If (k := !k) ? 100 : "off"
SetTimer, [color=#0000FF]SearchImage2[/color], % If (k := !k) ? 100 : "off"
TrayTip,, % If (t := !t) ? "On" : "Off"
return

[color=#FF0000]SearchImage1:
ImageSearch, FoundX, FoundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %ImageFile1%
If ErrorLevel = 0 [color=#008000] ; Put your code inside the braces below.[/color]
{
	MsgBox, 49, Continue?, Image / Pixel Found at %FoundX%x%FoundY%.`nPress OK to continue.
	IfMsgBox, Cancel
	{
		SetTimer, [color=#4000FF]SearchImage1, off[/color]
		TrayTip,, Off
	}
}
return  [color=#8000FF]<--- DON'T FORGET TO USE RETURN BEFORE THE NEXT LABEL![/color]
[/color]
[color=#0000FF]SearchImage2:
ImageSearch, FoundX, FoundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %ImageFile2%
If ErrorLevel = 0 [color=#008000] ; Put your code inside the braces below.[/color]
{
	MsgBox, 49, Continue?, Image / Pixel Found at %FoundX%x%FoundY%.`nPress OK to continue.
	IfMsgBox, Cancel
	{
		SetTimer, [color=#4000FF]SearchImage2, off[/color]
		TrayTip,, Off
	}
}
return[/color]

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
thanks sir...after googling a bit i also reached windows task schedular...but as i have forgotten the password etc. it is of no help..yor scripts are the most self explanatory..

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

...but as i have forgotten the password etc. it is of no help...

Try to google a way to recover your password, it should be possible.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
thanks sir for your replies!!..
because of ahk and your guidance i think i shall learn a lot of other things also
i m unable to get myself registered at
<!-- m -->http://webchat.freenode.net/<!-- m -->

please help me with this also

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
I don't use irc because it's blocked at my work and I don't have time to use when I'm home. Detail the steps and the error you get and post it in the forum, someone might help you.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
sir thanks ..finally got it!!...registered with the same name....cheers!!

smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
sir ...it is working awesomely ...
one more doubt sir....(it is difficult to express my doubts clearly)

after execution of my codes exactly as i want...when i move to the third step...

that is the after first image is searched(loaded)..codes executed

than second image searched (loaded)..codes executed

now in the third step though i want different set of codes to be executed but as the second and the next consecutive images are identical the coded mentioned for the second image run again...

that is...as the image which gets loaded after the imagesearch 2 ...is exactly similar to the subsequent image..due to which a loop is automatically formed..the 2nd image loads ..codes executed..2nd image loaded again ..codes executed..so on so forth..

can u tell me a way by which ..the coded mentioned for the 2nd image run only once..that if the second image is loaded again ..i can run different set of codes!!!!!!!!

all hail pulover!!

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Man! I can't understand what you say... I think you are mistaking the word "as" for "if".
When you say "as the second and the next consecutive images are identical", don't you mean "If the second and the next consecutive images are identical"...?
Maybe you can make a scratch code to illustrate what you want, but I think you need more "If Statements" for that.

What's your native language, btw?

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
"If the second and the next consecutive images are identical"...?

yes sir

smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012
as means because

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

as means because

Not always, it could mean "like", "while", "since"... but it makes more sense now.
I don't think you can compare the images, you'll have to do the search again. Post your code so I can take a look.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!