0

I have been using wsh to run vbscripts in conjunction with iMacros at my work for going on 3 years now. I know that the iMacros browser itself has an option to run hidden but the web-based db interface I have to work with does not function in the iMacros browser. For this reason I have had to use Internet Explorer. I have no problems with the script itself or how it runs. The thing I would like to improve is how the Internet Explorer window itself is handled.

Currently, when iMacros is initiated it creates the IE window in a non-maximized state cascaded from where the previous window was created. Because of iMacros's behavior, I then resize the window using an iMacros script so that enough of the page is rendered for the script to see everything it needs.

Set iim1 = CreateObject ("imacros")
iret = iim1.iimOpen ("-ie -iePrivate", TRUE, 300)
iret = iim1.iimPlayCode("SIZE X=" & scrWidth & " Y=" & scrHeight)

This all works fine and dandy. The scripts are scheduled to run at specific times, gather information out of the db and then imports that data into Excel spreadsheets and prints them out.

What I would like to do is make the IE window hidden while these scripts run. Because I do not create the IE window first (Set objIE = CreateObject("internetexplorer.Application")) I do not have access to the IE window object. I let iMacros create the window with the -iePrivate flag so that it will not disturb my own IE window if I should be logged in and working in the db while the script executes. However, it does try to take focus and become the active application while the script executes. Which can be very annoying at time. My goal is to be able to share these scripts with my co-workers but I don't want the IE windows popping up on them while they may be working on something else.

Is there a way to get to the IE object created by iMacros so that the window can be hidden?

1 Answers1

0

This does Internet Explorer and Explorer windows (they used to be the same program).

Set objShell = CreateObject("Shell.Application")
Set AllWindows = objShell.Windows
For Each window in AllWindows
    msgbox window.locationname
Next
Serenity
  • 24
  • 2
  • I have tested this code. It can find the window that iMacros creates, however, the window still becomes visible. That may be fine in the end if it is only visible for a second or so. However, I am still unable to "hide" this window. Suggestions? – Ben Stotler Mar 20 '15 at 18:56
  • There's a command line program to hide windows on my skydrive. https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 I think the zip is called showhidewindows. – Serenity Mar 20 '15 at 19:06
  • Can this not be done through the script itself (using wsh and windows API) without needing another external program? If not, that's fine, but if there is a way to accomplish this, I would love to know or at least pointed in the right direction. – Ben Stotler Mar 20 '15 at 19:30
  • No. No runtime will allow you to mess with other program's windows. In normal programming, as opposed to scripting, there should be no need. So API calls are the only way. Scripting languages are prevented from making API calls. So the program with source code (which is also on SO at http://stackoverflow.com/questions/27248528/size-batch-windows-and-set-in-specific-location) on my skydrive is for VB6. VB.NET is installed all computers so you can make your own in notepad. – Serenity Mar 20 '15 at 20:00
  • Here's the general principals of making VB.NET window functions. For a COM class usable by VBS http://stackoverflow.com/questions/26341753/how-to-find-the-window-title-of-activeforeground-window-using-window-script-ho/26349431#26349431 and to make a command line program http://social.msdn.microsoft.com/Forums/en-US/adcae113-4758-481a-a367-60d5d14d97d6/this-is-how-to-turn-vbs-and-js-files-into-exe-files-from-the-command-line-without-third-party-tools?forum=scripting – Serenity Mar 20 '15 at 20:04