timmy2 Posted November 1, 2014 Posted November 1, 2014 In short, the script below works perfectly when run in Windows 7 but the _Middle function has no effect when the script is run from the Startup menu during boot. $SCRIPT = "bginfo.exe tim's.bgi /TASKBAR /NOLICPROMPT /SILENT" Run($SCRIPT) $TITLE = "BGInfo" WinWait($TITLE,"",4) Call ("_Middle",$TITLE) ControlSend($TITLE,"","","!{F4}") ; Center Window on Screen Func _Middle($TITLE) $size = WinGetClientSize($TITLE) Local $y = (@DesktopHeight / 2) - ($size[1] / 2) Local $x = (@DesktopWidth / 2) - ($size[0] / 2) Return WinMove($TITLE,"", $x, $y) EndFunc ;==>_Middle My goal was to run SysInternals' BGInfo upon boot using the /TASKBAR command line option because it's supposed to merely load BGInfo into the Notification Area without displaying anything or modifying the Desktop like BGInfo normally does. The problem is that /TASKBAR displays the BGInfo popup window. I don't want to bother the user with the popup window; I just want BGInfo resident in the notification area. So I wrote the above ultra-simple script. It accomplishes two things in addition to running BGInfo with the needed command line options. 1. centers the BGInfo windows, because another glitch I found with BGInfo is that the popup window extends below the bottom edge of the screen. 2. closes the initial popup window (BTW, I tried WinClose and it has no effect on the BGInfo popup window, thus my use of ControlSend) When I run my script in Windows it works perfectly. But after I place a shortcut to my script in the Startup folder, when Windows 7 boots the popup window does not get centered by my _Middle function. I tried inserting Sleep commands at various points but either the ControlSend has no effect or my _Middle function has no effect. I even inserted a 15 second Sleep at the top of the script, delaying running BGInfo by that amount. The BGInfo popup window still didn't get centered. During Startup there must be some things unavailable to AutoIt's executable (or too many other things going on) that prevent my script from fully executing like normally does. Any suggestions? (thanks)
Rockerfeller Posted November 2, 2014 Posted November 2, 2014 You should start by removing the timeout from winwait function.
TheSaint Posted November 3, 2014 Posted November 3, 2014 You should really add in some checking code and have it report via a MsgBox or perhaps better still, write to a log file (or both). I'd start with code like If WinExists etc. Setup your code to test for all the required elements and report to you, etc. That is the best way to troubleshoot this. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now