WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WinActivate Erratic Behavior

Keywords: 	  WinActivate

Question:

I'm trying to use IntControl 61 [IntControl (61, 2, 0, 0, 0)] to activate a window before sending key strokes. WinActivate is not effective and only works every second time through the script. The second parameter, 2, is the only one that works each time. However it iconizes other windows as well. Is there a way to tell IntControl 61 which window to iconize?

The apps I am having the problem with are running either as an icon or normal. When the script is ready to send a keystroke, the active window in shown with WinShow and then activated with WinActivate. The keystokes are sent correctly, every second time through the script, which is why I tried IntControl 61. IntControl 61 sends the keystrokes correctly each time. It iconizes other windows(eg a maximized window that tells the user what is happening and asks them not to touch the mouse or keyboard while the batch file is executing).

I have 10 applications that use exactly the same script. It is unusual that two of them are having these problems. I was hoping that using Control Manager would limit any variations by looking for specific input boxes, then send the keystrokes. My initial guess was that the apps were a bit screwy, but it is still not clear why every second attempt is successful or even why [IntControl 61, 2, 0, 0, 0] works each time. If only the latter didn't iconize other windows...

Answer:

  1. Maybe try...
    	WinShow(...
    	WinActivate(...
    	TimeDelay(2)
    	WinActivate(...
    

  2. Is there possibly more than one window with that name on the system?

  3. Well, this does not exactly ring a bell, but rather thunks on the side of one slightly....Sometimes when people are writing their own dialogs with the dialog editor they somehow get 2 DIALOG statements into their scripts. And then when they fill out the dialog...nothing happens. Then they do it again and walla it works. And then they notice it works every second time.

    It was because the first DIALOG statement just dropped into the second one.

  4. Something sounds strange.

    IntControl 61 came about as a result of Winbatch not working on Windows 98 Beta's.

    Basically Windows 98 broke the WinBatch family of WinActivate functions. During the beta period it was difficult to get support or workarounds to the WinActivate problems, so we came up with a few whereby we could make it *kinda* work.

    We added in IntControl 61 to be able to switch between the various workarounds.

    After Windows 98 was released, support was more forthcoming and we were able to do the WinActivate via an approved method.

    WinActivate works differently depending on whether you are running Windows 95 (where the default method is #0) or Windows 98 (default method 4 (documentation error))

    In you are not running Windows 98, try method #4 anyway.

    Also try the 99F version of WinBatch.

    One thing we keep track of is how widespread some particular problem is, and also how long that code has been unmodified.

    In this case it seems no one else is having any problems with the WinActivate functions, and the code has not changed in recent memory.

    If it was just one application, well I would assume something funny about the application. However you have two. But it is still one site.

    Is there anything in common about the two failing applications? Same vendor? Anything else in common?

    I still suspect more than one window with that title. a

    	list=WinItemize()
    	AskItemList("check This",list,@tab,@sorted,@single)
    
    should display all the known windows in a sorted list. Check your windows for duplicates - perhaps there is a hidden window with the same name gumming up the works.

    Basically we've had no other reports of any problems whatsoever with the WinActivate functions -- assuming you are running current versions of the software of course. Do note that there are problems in running WinBatch 97E and older on Windows 98, but I seem to recall that problem was already eliminated....time to reread the entire thread I guess...


Article ID:   W14147
Filename:   WinActivate Erratic Behavior.txt
File Created: 1999:06:09:14:33:58
Last Updated: 1999:06:09:14:33:58