buckRogers Posted July 2, 2009 Share Posted July 2, 2009 I've got some vbs code that I kick off via an AutoIt script that watches for any changes to a USB device. What I'm doing is checking for a USB printer being turned on, turned off, plugged in or unplugged. If the printer is turned on or plugged in, I have VBS code that makes sure the printer is set to default and removes any additional printer installations. Long story short... The vbs code stops the print spooler, does the admin work, restarts the print spooler and sets the default printer. When I go check the Printers and Faxes window, it looks like no changes were made except for the setting of the default printer. Additional copies of printer installation exist and sometimes the default printer show offline when it is online. If you hit F5 with the window open, everything shows as it's supposed to. There's the rub...I don't want to have to open Printers and Faxes and do a sendkey to refresh the printer listing. I would like to make this a passive as possible to the user. I've found the following code within the AutoIt Forums: CODE#include <Constants.au3> Dim Const $SHCNE_ASSOCCHANGED = 0x8000000 Dim Const $SHCNF_IDLIST = 6 Dim Const $NULL = 0 DllCall("shell32.dll", "none", "SHChangeNotify", "long", $SHCNE_ASSOCCHANGED, "int", $SHCNF_IDLIST, "ptr", 0, "ptr", 0) I found that $SHCNF_IDLIST=6 is for PRINTERW and $SHCNF_IDLIST=2 is for PRINTERA. In testing, I've gotten better results with $SHCNF_IDLIST=6 but not 100%. I get abouta 40% success rate with it and am wondering if anybody sees something wrong with the code. Longwinded? I apologize, but do appreciate any help offered. Link to comment Share on other sites More sharing options...
KaFu Posted July 2, 2009 Share Posted July 2, 2009 Maybe the function _Update_Explorer() from Valik solves your problem...#666239 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
buckRogers Posted July 6, 2009 Author Share Posted July 6, 2009 Thanks for the tip KaFu but it didn't work. Well, it works if the Printers and Faxes window is open but not when it's just the desktop. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 6, 2009 Share Posted July 6, 2009 Close the window, make changes, open window? Or don't open window at all until changes are made? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
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