Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Wait for web or for any page loaded with image search.


  • Please log in to reply
5 replies to this topic
LazyLarry
  • Guests
  • Last active:
  • Joined: --
I work with mutiple applicaiotns, pages, e.g. Oraclie, Fox DB, Delphi, alll networked along with Word, Excel, and looks like more of this than less.

Some have the same title, but different pages, WinGetTitle, WinText, WinWait, StatusBarText and the like do not always work, and a lot of AHK trial and error, frequent Sleeps etc get the job done.

AHK has so many features, that it is difficult to understand them all, any one could be a script destroyer, and for a poor scripter as myself, there is not enough time to work and play at htis enjoyable activity.

Then i started experimenting with ImageSearch and by comparison it is rock solid.

The core is the same as "Richard's" script and all these I would guess work the same way.

This script as is, would not work, one would need corresponding Imagings to search, but one can see how adapatable it would be to any beginner faced with similiar problems.

;===== start of image search script ===
InputBox, password, Enter Password, (your input will be hidden), hide 
SetKeyDelay, 20
StartSequence=https://www1.royalbank.com/cgi-bin/rbaccess/rbunxcgi?F6=1&F7=IB&F21=IB&F22=IB&REQUEST=ClientSignin&LANGUAGE=ENGLISH
WinTitle = RBC Financial Group - Online Banking

Msg1=1/3 Requested Sign in Page - Waiting for 4519
Msg2=2/3 Sent Password -  Waiting for "View" Button
Msg3=3/3 "View" button arrived - Wait for page to settle down before click
Msg4=This concludes the Royal Bank Script

Img1= SignIn4519 ; RoyalBankViewSecondPage, don't put the .bmp extension here, it is added later see line32
Img2= RoyalBankViewSecondPage ; 
Img3= RoyalBankViewSecondPage ; yes it is the same, this page seems to jump upon arrival(or firefox is repositioning it)
Img4 = rbViewAccount

GoSub STANDARD ; more variables but more consistent with other applicatons

;========== PAGE 1 WORK
GoSub SUB ; follow is any bank / client number but noyt real on
send, 2222222222
Send {tab}
sleep, 60
send, %password%{enter}

;=========== PAGE 2 WORK
GoSub SUB

;=========== PAGE 3 WORK
sleep 2500 ; wait for page to settle down
GoSub SUB
click %x% %y%
soundplay, %dir%YourBankAccountisReadyforViewing.wav, 1 ; ViewYourAccount.wav, 1 ; a nce british sounding voice here,
EXITAPP

;############ SUB #########
SUB:
Msg:=Msg%Page%
Img:=Img%Page%
SplashImage, ,x300 y650 W385 H30 B1, %Msg%
Loop
  {
    ImageSearch,x, y, %X1%, %Y1%, %X2%, %Y2%,%dir%%Img%.bmp
   LoopCount -= 1
   ToolTip, LoopCount Countdown %loopcount%
   If Errorlevel = 0 ; image found
      break
   If (LoopCount <1)
   		{
   		MsgBox,,,%DIR%%IMG%%PAGE%.BMP Not Found lOOPC %lOOPcOUNT%,200
   		exitapp
 		}
	Sleep %LoopSleepInterval%
 	} 
Page += 1 ; determines the next imagines and messages to be used
RETURN
;#########################

;###### THESE STANDARD VARIABLES / PROCESS WOULD BE CONSISTENT FOR MANY USES.
STANDARD:
dir=c:\4\
X1= 100 ; so as not to pick up the image in splashimage but in window Password is near top
Y1 = 100
X2 = 700 ; Click 501 265
Y2 = 600 ; Click 589 298
LoopCount=70
LoopSleepInterval=100
Page = 1
IfWinNotExist, %WinTitle% ; in case a failed previous launch left the page existing
	{
	RunWait, %StartSequence%
	}
WinActivate, %WinActivate%
RETURN
;######################################################


ghee22
  • Members
  • 36 posts
  • Last active: Nov 12 2009 04:44 PM
  • Joined: 04 Jul 2009

This script as is, would not work, one would need corresponding Imagings to search, but one can see how adapatable it would be to any beginner faced with similiar problems.


Found this script in the script listings wiki. Has anyone confirmed this code does work or have an improvement?

MacroMan!
  • Members
  • 604 posts
  • Last active: Mar 20 2012 11:40 AM
  • Joined: 28 Aug 2009
I personally just use something like this:

Loop
{
PixelGetColor, Loaded, 1079, 124
if Loaded = 0x30D824
break
}

It can produce some messy code if overused, but for the odd page load here and there, it works fairly reliably.

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Related: WaitPixelColor() (supports timeout)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


MacroMan!
  • Members
  • 604 posts
  • Last active: Mar 20 2012 11:40 AM
  • Joined: 28 Aug 2009

Related: WaitPixelColor() (supports timeout)


That's a much neater solution, thank you. :)

  • Guests
  • Last active:
  • Joined: --
A related post here Detect when a page is loaded (reliable, cross-browser) But, maybe imagesearch (this thread) better is some instances. It never hurts to multiple choices.