script smashes system tray & taskbar

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
smhodge
Newbie
Posts: 12
Joined: Mon May 28, 2007 6:46 pm

script smashes system tray & taskbar

Post by smhodge » Mon Jun 25, 2007 4:53 am

The following script smashes & freezes my system tray and taskbar, and the only fix is to logout/login. In some cases the process msched.exe has to be manually stopped before logout is possible.

The script closes a Windows Explorer window open to the folder "C:\Program Files\ATI", in which case Windows Explorer displays just "ATI" as the window name.

Let>WF_TYPE=2
IfWindowOpen>ATI*
CloseWindow>ATI*
Wait>1
Endif

The script works ok and does close the window whether or not the wildcard (*) is used. However, if it is used, after the script terminates, the system tray and taskbar get smashed. Without the wildcard, everything is just fine after the script terminates.

Yes, I know, why put the * there in the first place? The reason is that I have given a simplified example here. I really want it to work with a long path name, only the first part of which is significant; hence it seemed like using a wildcard would simplify things. But the same thing happens with any folder. Add the asterisk and the script fails catastrophically. Why?

Steve

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 25, 2007 5:16 am

Steve,
Can't tell you what the problem might be but I can relate what just happened to my taskbar when I ran your script. I ran it in the editor, stepped through using F8. Completed successfully and I thought I'd gotten away without any consequences. However when I checked the taskbar (mine is hidden) I discovered it was redone for me and the shortcut icons including date/time and Macro Scheduler are gone.

I've not figured out what happened nor how to repair it and its been 20 minutes. If no one else posts a reasonable fix I'll look into it more in the morning. Its midnight here and I've got to be up at 6:00.

Good luck,
Dick

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 25, 2007 1:40 pm

After a little checking... specifically, a search for "ATI" using "View System Windows", I've concluded that "ATI" is too generic and is included in several system windows. For example one window I found was ToolbarWindow32 "Notification Area". That's probably what I turned off on my home computer.

A solution would be to use window handles. Try revising your script to
something like this:

Code: Select all

Let>WF_TYPE=2
IfWindowOpen>ATI*
SetFocus>ATI*
Let>WIN_USEHANDLE=1
GetActiveWindow>Win_Title,Win_X,Win_Y
CloseWindow>%Win_Title%
Let>WIN_USEHANDLE=0
Endif
Wait>1
Hope this is helpful,
Dick

P.S.
this method will still cause problems if the explorer window "ATI" is not open. It will then find the toolbar window and close it creating similar problems to what you're experiencing.

smhodge
Newbie
Posts: 12
Joined: Mon May 28, 2007 6:46 pm

Post by smhodge » Wed Jun 27, 2007 4:38 pm

Well, no, it doesn't help. You must have missed my statement in the original post that "the same thing happens with any folder". The string "ATI" was just an example. It is the presence of the wildcard (*) appended to ANY folder string that causes the problem, not what the particular folder string happens to be.

Besides that, IF there were "hidden" glitches in the use of a common command that caused catastrophic failure, wouldn't that constitute a bug in the command that needs fixing?

Steve

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jun 27, 2007 5:02 pm

This is hardly a hidden glitch. If you try to close the first window that is found containing ATI in the title then you can hardly blame Macro Scheduler if the system crashes because it tried to close the task bar notification area, for example.

Using this command it is possible to close a hidden system window. We or Macro Scheduler cannot be responsible for what happens if you do that.

If you want to close a window whose title is ATI then the safest method is:

SetFocus>ATI
Press ALT
Press F4
Release ALT

CloseWindow sends a WM_CLOSE event and can bypass the user interface. Many applications process it differently. The only way to properly simulate the process that takes place when a user closes a window is to send the keystrokes to it. CloseWindow is useful in some cases but may not always work, and in some cases can have adverse results. Focusing the explorer window and sending ALT-F4 will work as if the user hit ALT-F4 to close it. Surely therefore the safest method.

And if the window title is ATI then don't add the asterisk. If you do need to add the asterisk then at the very least ensure that SetFocus can only work against visible windows to try to avoid Macro Scheduler finding something it shouldn't be closing:

Let>WF_TYPE=2
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts