Jump to content

Open Winow in Background

Recommended Posts

Hi All,

I've been using AutoIT the past few weeks to automate some web based stuff for work and its worked great. Now I'm trying to automate some stuff for a program called FirstClass if anyone is familiar with it. We use it as a content management system for websites.

I've been able to automate a few things so far but it all requires me to send key strokes and mouse movements which means I can't really use my computer while it's running.

I just read up on ControlSend and similar functions and I can get those to send keystrokes to the first class client in the background which is good. The issue is that a lot of the stuff I want to automate in FirstClass opens new windows (Permissions dialog box, properties dialog, etc.) Is there a way I can have these windows open in the background so they don't interrupt what I am currently working on?

I love that I can automate IE and Excel stuff to run in the background and am trying to do the same here.



Link to post
Share on other sites

Maybe this?

_WinAPI_ShowWindow(_WinAPI_FindWindow($sClassName, $sWindowName), @SW_HIDE)

I'll look into this. I haven't really looked at the WinAPI at all. I know there's a WinSetState that you can use to hide, maximize and other stuff to windows but I think that (and what you are suggesting since it seems similar) requires the window to already be open.

Once the window is open and becomes active it doesn't need to stay open for very long (probably not more than 10 seconds or so) the issue is that by becoming the active window it would interrupt whatever I was doing. So if it opened while I was in the middle of typing I could end up typing over data in the window that opens. Ideally there would be a way to set new windows to open without becoming active. I might have to spend some time looking at the WinAPI.

Edit: In a related note (and I may find something in the WinAPI) is there a way to wait for a window to fully load sort of like the IELoadWait() function?

I have a window that I open currently and I have to add a sleep delay in because if I send the keystrokes immediately the window isn't fully loaded and it ends up messing everything up. The sleeps also might need to change depending on computer speed.

Just found WinWait might have to try that.

Edited by DennisFV
Link to post
Share on other sites

I have a solution

1) run the program hidden.

2) switch the parent to the desktop window so when you shownoactivate it is behind all other windows.

3) shownoactivate

4) switch the parent back to the original parent.

#Include <WinAPI.au3>
Run ("notepad.exe", "", @SW_HIDE)
$handle=WinGetHandle("Untitled - Notepad")
$origParent = DllCall("user32.dll", "int", "SetParent", "hwnd", $handle, "hwnd",  WinGetHandle("Program Manager"))
_WinAPI_ShowWindow($handle, @SW_SHOWNOACTIVATE)
$origParent2 = DllCall("user32.dll", "int", "SetParent", "hwnd", $handle, "hwnd",  $origParent[0])
Link to post
Share on other sites

#Include <WinAPI.au3>
#Include <Constants.au3>

$hForm = GUICreate('MyGUI', 800, 600)

Until GUIGetMsg() = -3

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...