Imacros Browser Not responding with VBScript

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information:CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Imacros Browser Not responding with VBScript

Post by Aditya93 » Sun Jun 23, 2019 3:00 am

Hi,

When I run 1 vbscript at a time, it runs smoothly without any issues, but if i run 2 or more at the same time, one or more of the imacros browser goes not responding. Not sure why that happens

Test Script

Code: Select all

set iim1= CreateObject ("imacros")
iret = iim1.iimOpen ("")
'iret = iim1.iimSet("-tray", "")
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Extra\URL.iim")


'Login ID - Saint - 2[change 2 places]
myLoopVariable = 2
iret = iim1.iimSet("loopNumber", Cstr(myLoopVariable))

iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Login\Login.iim")
do while (iret < 0)
myLoopVariable = 2

iret = iim1.iimSet("loopNumber", Cstr(myLoopVariable))
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Login\Login.iim")
loop

'Pop Up Close - 5 Times
i = 0
do while (i<5)
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Extra\Offer Close.iim")
i = i + 1
loop


'Going to Map
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Castle\Going to Map.iim")
do while (iret < 0)
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Castle\Going to Map.iim")
loop

'Going to Sand
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Castle\Going to Fire.iim")
do while (iret < 0)
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Castle\Going to Fire.iim")
loop

iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Extra\Delete Dragon File.iim")

'Dragon HUnting
myLoopVariable = 1

do while (myLoopVariable < 100)
iret = iim1.iimSet("loopNumber", Cstr(myLoopVariable))

iret3 = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Tower Selection\Dragon List.iim")
if (iret3 < 0) then
	iim1.iimClose(30)
	WScript.Quit(iret)
end if

iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Attack Formation\Formations\Dragon Detection.iim")

'Pop Up Close - 1 Times
i = 0
do while (i<1)
iret = iim1.iimPlay("C:\Users\Aditya\Documents\iMacros\Macros\Script\Extra\Offer Close.iim")
i = i + 1
loop

myLoopVariable = myLoopVariable + 1
loop

iim1.iimClose(30)
WScript.Quit(iret)
URL.iim

Code: Select all

SIZE X=845 Y=868
URL GOTO=https://empire.goodgamestudios.com/flash/
Login.iim

Code: Select all

SIZE X=845 Y=868
SET !TIMEOUT_STEP 2
SET !DATASOURCE user_name.csv
SET !DATASOURCE_COLUMNS 2

WAIT SECONDS=1

SET !DATASOURCE_LINE {{loopNumber}}
IMAGECLICK POS=1 IMAGE=login.png CONFIDENCE=95
WAIT SECONDS=2
DS CMD=CLICK X=724 Y=31 CONTENT={{!COL1}}
DS CMD=CLICK X=736 Y=53 CONTENT={{!COL2}}
DS CMD=CLICK X=678 Y=81 CONTENT=
DS CMD=CLICK X=722 Y=123 CONTENT=

WAIT SECONDS=1

WAIT SECONDS=20
Offer close.iim

Code: Select all

SIZE X=845 Y=868
SET !TIMEOUT_STEP 2
SET !DATASOURCE user_name.csv
SET !DATASOURCE_COLUMNS 2

WAIT SECONDS=1

SET !DATASOURCE_LINE {{loopNumber}}
IMAGECLICK POS=1 IMAGE=login.png CONFIDENCE=95
WAIT SECONDS=2
DS CMD=CLICK X=724 Y=31 CONTENT={{!COL1}}
DS CMD=CLICK X=736 Y=53 CONTENT={{!COL2}}
DS CMD=CLICK X=678 Y=81 CONTENT=
DS CMD=CLICK X=722 Y=123 CONTENT=

WAIT SECONDS=1

WAIT SECONDS=20
Going to Map.iim

Code: Select all

SIZE X=845 Y=868
SET !TIMEOUT_STEP 2

IMAGECLICK POS=1 IMAGE=globe.png CONFIDENCE=95
DS CMD=CLICK X=-1 Y=-1 CONTENT=

Going to Fire

Code: Select all

SIZE X=845 Y=868
SET !TIMEOUT_STEP 2
WAIT SECONDS=2

DS CMD=CLICK X=750 Y=802 CONTENT=
WAIT SECONDS=1

IMAGECLICK POS=1 IMAGE=Ghost_Wrath.png CONFIDENCE=95
WAIT SECONDS=2
Deleting Dragon File.iim

Code: Select all

SIZE X=845 Y=868
SET !TIMEOUT_STEP 2
FILEDELETE NAME=Dragon_Hit.csv
Dragon List.iim

Code: Select all

SIZE X=845 Y=868
SET !TIMEOUT_STEP 2

SET !DATASOURCE Dragon_List.csv
SET !DATASOURCE_COLUMNS 2

WAIT SECONDS=1

SET !DATASOURCE_LINE {{loopNumber}}
DS CMD=CLICK X=319 Y=19 CONTENT={TAB} 
DS CMD=CLICK X=319 Y=19 CONTENT={{!COL1}}
DS CMD=CLICK X=364 Y=9 CONTENT={TAB} 
DS CMD=CLICK X=364 Y=9 CONTENT={{!COL2}}
DS CMD=CLICK X=364 Y=9 CONTENT={ENTER}

WAIT SECONDS=1.5

DS CMD=CLICK X=421 Y=428 CONTENT=
Dragon Detection

Code: Select all

SIZE X=845 Y=868

SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES

WAIT SECONDS=0.3
ADD !EXTRACT {{!COL1}}
ADD !EXTRACT {{!COL2}}

WAIT SECONDS=0.3
SAVEAS TYPE=EXTRACT FOLDER=* FILE={{Coord_X_1}}
That is all :lol:

Any suggestion or help would be great :D

Code: Select all

VERSION BUILD=11.5.498.2403
Windows 7 x64 (English)
Imacros Browser V11.5.498.2403
Last edited by Aditya93 on Tue Jun 25, 2019 3:49 pm, edited 1 time in total.
Tom, Tech Support
Posts: 3490
Joined: Mon May 31, 2010 4:59 pm

Re: Imacros Browser Not responding with VBScript

Post by Tom, Tech Support » Mon Jun 24, 2019 10:58 am

Hi Aditya93,

Does this game run normally if you have it open in multiple instances of IE at the same time?

Keep in mind that session state (browser cache) is shared among multiple instances of the iMacros browser, so this could potentially cause problems.

One thing you can try is creating multiple Windows user accounts on your machine, and then run the script once in each user account. This ensures that the sessions are separate and would not interfere with each other.
Regards,

Tom, iMacros Support
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Tue Jun 25, 2019 5:45 am

Hi Tom
Does this game run normally if you have it open in multiple instances of IE at the same time?
Yes, it works properly, even in imacros browser, if it is not initiated by vbscript.
Even 5-7 instances run fine together and can also add 1 which is initiated by vbscript.

But most of the time as soon as i add one more vbscript initiated imacros browser, the first one goes in Not Responding.[which was started by vbscript]

For trying to find where the issue was, I tried few things.
1) started one with vbscript, added another after 1 min, most of the time the first one goes in Not responding.
2) started two at the same time with vbscript, mostly they run fine without going in Not Responding, but sometimes one of them still do.
3) started two, then added 1 more after few mins, the first 2 goes in Not Responding.
All of the above have been initiated by vbscript

I checked the systems Ram and CPU usage, they still have not been fully used, still it goes in Not Responding and only the specific imacros browser goes in Not Responding.
other then that the whole system works smoothly
One thing you can try is creating multiple Windows user accounts on your machine, and then run the script once in each user account. This ensures that the sessions are separate and would not interfere with each other.
I am a bit new to scripting, so i don't have the idea how would I initiate the vbscript from the different user accounts as i can login only one of them at at time.
I think its something related to iimRunner, which i didn't get how to use

one more thing i would like to know, wscript.exe keeps on adding up and r not terminated.
Any way to to terminate them all at once or after the script ends
Tom, Tech Support
Posts: 3490
Joined: Mon May 31, 2010 4:59 pm

Re: Imacros Browser Not responding with VBScript

Post by Tom, Tech Support » Tue Jun 25, 2019 10:55 am

What happens if you try the following:
  1. Start more than one iMacros browser instance manually.
  2. Change your VBScript such that it will attempt to attach to an existing instance of the browser rather than launch a new one, by passing False as the second parameter to iimOpen:

    Code: Select all

    iret = iim1.iimOpen ("", False)
  3. Now run the script multiple times (once for each open browser instance)
Regards,

Tom, iMacros Support
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Tue Jun 25, 2019 11:30 am

Now run the script multiple times (once for each open browser instance)
for example say 3 imacros browsers are open
now i start 3 scripts, so how will it know which needs to run in which of the browser
Tom, Tech Support
Posts: 3490
Joined: Mon May 31, 2010 4:59 pm

Re: Imacros Browser Not responding with VBScript

Post by Tom, Tech Support » Tue Jun 25, 2019 3:36 pm

Aditya93 wrote:
Tue Jun 25, 2019 11:30 am
for example say 3 imacros browsers are open
now i start 3 scripts, so how will it know which needs to run in which of the browser
The iMacros scripting interface will connect to the first browser instance it finds that is not already under the control of the scripting interface.
Regards,

Tom, iMacros Support
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Tue Jun 25, 2019 4:06 pm

It seems to be working without going in Not Responding[went ones in 5-6 trials], but what could be the reason for that?
Tom, Tech Support
Posts: 3490
Joined: Mon May 31, 2010 4:59 pm

Re: Imacros Browser Not responding with VBScript

Post by Tom, Tech Support » Tue Jun 25, 2019 4:34 pm

That is good to hear, and proves what I was suspecting.

The iMacros sidebar is handled differently when launching the iMacros browser manually vs. via script. When launched manually, the sidebar is 'pinnable':

Pinnable Sidebar.png
Pinnable Sidebar.png (24.08 KiB) Viewed 406 times

But not so when it is launched with the scripting interface:

Static Sidebar.png
Static Sidebar.png (19.53 KiB) Viewed 406 times

Normally this is not a problem, but for this specific site / application it is causing the issue (for technical reasons that I do not know).

If you do not want to have to launch the browser instances manually, you can still program the script to do this but via the WshShell.Run command rather than with the iMacros scripting interface. For example:

Code: Select all

Const NUM_INSTANCES = 5

set iim1= CreateObject ("imacros")

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

Dim i
For i = 1 To NUM_INSTANCES
    ' Launch the browser
    WshShell.Run("""C:\Program Files (x86)\Ipswitch\iMacros\iMacros.exe""")
    
    ' Wait a bit before attempting to connect via iMacros SI
    WScript.Sleep(2000)
    iret = iim1.iimOpen ("", False)
    
    ' Wait a bit more before launching the next instance
    If i < NUM_INSTANCES Then
        WScript.Sleep(2000)
    End If
Next
The delays may or may not be necessary, you'll have to test and adjust to see what works best.

For more info on how to use WshShell.Run, see this reference.
Last edited by Tom, Tech Support on Wed Jun 26, 2019 9:47 am, edited 1 time in total.
Reason: Fixed WshShell.Run statement (needed to surround path with double-quotes since it contains spaces)
Regards,

Tom, iMacros Support
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Wed Jun 26, 2019 1:19 am

WshShell.Run("C:\Program Files (x86)\iOpus\iMacros\iMacros.exe")
gives error

Image
http://prntscr.com/o6palb
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Wed Jun 26, 2019 1:43 am

got it to work, needed two extra """ on the end:P
Tom, Tech Support
Posts: 3490
Joined: Mon May 31, 2010 4:59 pm

Re: Imacros Browser Not responding with VBScript

Post by Tom, Tech Support » Wed Jun 26, 2019 9:45 am

Ah yes, sorry about that. I wrote that code on-the-fly without testing it.
Regards,

Tom, iMacros Support
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Thu Jun 27, 2019 9:36 am

Hi

Still the issue of Not Responding is persisting.
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Sun Jun 30, 2019 12:59 am

Any way I could kill the Not Responding tasks with the task scheduler?

tried this in .bat
taskkill /f /im wScript.exe

it works

but when i try
taskkill /f /im imacros.exe

it doesnt work, not sure why
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Sun Jun 30, 2019 2:46 am

not sure wht the issue was, it seems to be working now
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Imacros Browser Not responding with VBScript

Post by Aditya93 » Sat Jul 06, 2019 3:38 pm

any way to use .bat to open the files in the browser that is already opened a specific one among them
Post Reply