後来用这个方法解决Global $defPrtNm
;;; Get default Printer;
Func _GetDefaultPrinter() ; CyberSlug - 18 Nov 2004 (别人心血我不删掉)
Local $key, $default
$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers"
$default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
$defPrtNm = StringLeft($default, StringInStr($default, ",") - 1)
Return $defPrtNm
EndFunc ;==>_GetDefaultPrinter
$prt = _GetDefaultPrinter()
Run("RUNDLL32 PRINTUI.DLL,PrintUIEntry /p /n ""\" & @IPAddress1 & "" & $prt)
sleep(500)
Send("^+{TAB 2}")
Sleep(500)
Send("{down 11}")
Sleep(500)
ControlCommand("HP LaserJet", "", "ComboBox1", "SelectString", "已安裝")
Sleep(500)
Send("{up 7}")
Sleep(500)
ControlCommand("HP LaserJet", "", "ComboBox1", "SelectString", "A4")
Sleep(500)
Send("{ENTER}")
|