본문 바로가기
IT관련/OJ시리즈

OJP :: OJ Printer 2 소스 코드 (Autoit Script) 프린터 자동설치

by RichNam 2022. 1. 5.
반응형

 

 

 

아래는 OJP2 의 소스입니다.

 

각 제조사별 프린터 드라이버를 만들어 두고

기종별 선택하여 간편설치를 이용하여 드라이버를 바로 설치하고자 만든 프로그램이며.

제가 임대업에 종사할 당시 업체 나가면 항상 애용했던 그 프로그램입니다.

 

개발이 끝나고 소스관리를 하지 않은터에 이게 최신인지 모르겠네요.

 

나중에  C# 으로 수정한게 더 최신이지만

그건 모 업체 프로그램과 연관된 소스코드가 좀 섞여 있어서

공개하기는 좀 어려워 오토잇 버전을 공개합니다.

 

 

실제 하는 일에 대한 설명은 아래 글을 참고하십시요.

 

 

https://richnam.com/696

 

OJP 프린터의 간편설치 유틸리티를 이용한 엡손프린터 드라이버 설치

무척 오랫만에 프로그램 하나를 손 봤습니다. 과거 임대시 나름 편하게 사용했던 프로그램인데요. OJP 라고... 아실 분은 아시겠지만, 몇번 카페에도 소개해 드렸었지요. ^^; 이 프로그램은 프린터

richnam.com

 

 

 

 

 

 

아래 소스 참고하시어 필요하신 분은 수정하여 사용하세요.

 

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ServiceControl.au3>

#include <iNet.au3>
#include <ClipBoard.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>

#include <IE.au3>
#Include "printers.au3"
#include <GuiComboBox.au3>
#include <InetConstants.au3>

$OJP = GUICreate("OJ프린터", 404, 534, 308, 160)
GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)
$cmbPrnMaker = GUICtrlCreateCombo("제조사를 선택하세요", 127, 102, 245, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$cmbPrnModel = GUICtrlCreateCombo("기종을 선택하세요", 127, 132, 245, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$cTCPIP = _GUICtrlIpAddress_Create($OJP, 127, 162, 133, 21)
_GUICtrlIpAddress_Set($cTCPIP, "0.0.0.0")
$cPrnName = GUICtrlCreateInput("OJP", 127, 192, 133, 21)
$chkDefaultPrn = GUICtrlCreateCheckbox("기본 프린터로 설정하기", 127, 214, 189, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
$chkPrnOpen = GUICtrlCreateCheckbox("양방향 해제하기", 127, 238, 197, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
$btnGO = GUICtrlCreateButton("간편 설치", 29, 270, 169, 41)

;~ $btnPrnFolderOpen = GUICtrlCreateButton("프린터 폴더 열기", 31, 361, 169, 25)
;~ $btnRegWrite = GUICtrlCreateButton("관리용 REG등록", 31, 392, 104, 25)
;~ $btnRegRemove = GUICtrlCreateButton("삭제", 135, 392, 65, 25)
;~ $btnRemote = GUICtrlCreateButton("OJ 리모트 설치", 31, 424, 169, 25)
;~ $AddPrt = GUICtrlCreateButton(".", 31, 455, 169, 25)

;~ $btnPrnBackup = GUICtrlCreateButton("프린터 백업", 206, 360, 104, 25)
;~ $btnPrnRestore = GUICtrlCreateButton("복구", 310, 360, 65, 25)

;~ $btnDelSpool = GUICtrlCreateButton("인쇄 대기열 문서 삭제", 206, 392, 169, 25)
;~ $btnCounter = GUICtrlCreateButton("OJ 카운터 설치", 206, 424, 169, 25)
;~ $IPScanGO = GUICtrlCreateButton("IP 스캔", 206, 455, 167, 24)

$btnPrnFolderOpen = GUICtrlCreateButton("프린터 폴더 열기", 31, 361, 169, 25)
$AddPrt = GUICtrlCreateButton("프린터추가마법사 실행", 31, 392, 169, 25)

$btnRegWrite = GUICtrlCreateButton("관리용 REG등록", 31, 424, 104, 25)
$btnRegRemove = GUICtrlCreateButton("삭제", 135, 424, 65, 25)

$btnRemote = GUICtrlCreateButton("원격지원 설치", 31, 455, 169, 25)

$btnDelSpool = GUICtrlCreateButton("인쇄중인 문서 삭제", 206, 360, 169, 25)

$btnPrnBackup = GUICtrlCreateButton("프린터 백업", 206, 392, 104, 25)
$btnPrnRestore = GUICtrlCreateButton("복구", 310, 392, 65, 25)

$btnCounter = GUICtrlCreateButton("프린터 카운터 설치", 206, 424, 169, 25)
$IPScanGO = GUICtrlCreateButton("IP 스캔", 206, 455, 167, 24)


$ButtonPortMake = GUICtrlCreateButton("TCP/IP 포트생성", 267, 160, 105, 25)
$Label1 = GUICtrlCreateLabel("TCP/IP 주소", 29, 162, 87, 17)
$Label2 = GUICtrlCreateLabel("프린터 이름", 29, 192, 67, 17)
$Label3 = GUICtrlCreateLabel("제조사", 29, 102, 40, 17)
$Group1 = GUICtrlCreateGroup("새 프린터 설치", 13, 70, 377, 257)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$oStatusBar = _GUICtrlStatusBar_Create($OJP)
_GUICtrlStatusBar_SetMinHeight($oStatusBar, 25)
$Group2 = GUICtrlCreateGroup("", 13, 342, 377, 153)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label4 = GUICtrlCreateLabel("기종 선택", 29, 132, 55, 17)
$btnGO2 = GUICtrlCreateButton("정식 설치", 205, 270, 169, 41)
GUISetState(@SW_SHOW)


_GUICtrlIpAddress_Set($cTCPIP, @IPAddress1)
_GUICtrlIpAddress_Get($cTCPIP)


; IP Scan 에서 사용
Global $HostName, $WhichList, $List, $Used, $StartTime, $Finished, $CurrentIP, $CurrentIndex, $FreeCount, $Progress, $CurrentlyScanning, $FinishMessage, $fDblClkMessage
Global $ChosenIP, $IPinBrowser, $CopyToClip, $Rescan, $Unused, $TimeoutDefault, $Gateway, $StatusBar
Global Const $MAX_PROCESS = 30 ; maximum processes at once
Global $fDblClk = False, $aLV_Click_Info


; 시트롤 컨트롤 다운로드 변수
$Surl = "http://www.seetrol.co.kr/download/client.exe"


#NoTrayIcon
;Opt("TrayMenuMode", 3)
;$mAbout_Item = TrayCreateItem("OJ Printer ?")
;TraySetState()
;TraySetToolTip("OJ Printer :: 프린터 설치")


; 프로그램 상단의 배너 뛰우는 부분
$url = "http://bibs.iptime.org:88/link/index.htm"
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 0, 0, 404, 54)
ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2")
_IENavigate($oIE, $url)


;버전 관리용
_GUICtrlStatusBar_SetText($oStatusBar, "ver 2.7.0 - " & @OSVersion	& " " & @OSArch )


; =====================================================================
; INI 초기 설정 값을 서버에서 다운받는 방식으로 수정함 2016.3.22


    Local $oGUI = GUICreate('OJ 다운로더', 370, 90, -1, -1, -1, $WS_EX_TOPMOST)
    Local $iLabel = GUICtrlCreateLabel('OJ 다운로더', 5, 5, 270, 40)
    Local $iProgressBar = GUICtrlCreateProgress(5, 60, 360, 20)
	GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)
	GUISetState(@SW_SHOW, $oGUI)

    DirCreate("C:\OJP2\")
    _InetGetGUI('http://bibs.iptime.org:88/OJP2.txt', $iLabel, $iProgressBar, @ScriptDir & "\")
    Sleep(1000)
    GUIDelete($oGUI)


; =====================================================================


; 콤보박스 값 초기화
Local $aArray = IniReadSection(@ScriptDir & "\OJP2.txt", "Model")
; Local $aArrayINF = IniReadSection(@ScriptDir & "\OJP2.ini", "INF")
Local $cValue

; Check if an error occurred.
If Not @error Then
	; Enumerate through the array displaying the keys and their respective values.
	For $i = 1 To $aArray[0][0]
;~ 		MsgBox($MB_SYSTEMMODAL, "", "Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1])
		$cValue = $cValue & $aArray[$i][0] & "|"
	Next
EndIf
GUICtrlSetData($cmbPrnMaker , "HP")
GUICtrlSetData($cmbPrnModel , $cValue)


Global $cDownFileName
Global $cPrinterName
Global $cInfPrinterName
Global $cPrinterPortName

Global $cDownFileName
Global $cPrinterName
Global $cInfPrinterName
Global $cPrinterPortName
Local $aTemp


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $btnGO

			If _GUICtrlComboBox_GetCurSel ( $cmbPrnModel ) = 0 Then ContinueLoop

			; 파일 다운로드
			GUISetState(@SW_DISABLE, $OJP)
			$cDriverFileName = $aArray[_GUICtrlComboBox_GetCurSel ( $cmbPrnModel )][1]
			$cPrinterModel = $aArray[_GUICtrlComboBox_GetCurSel ( $cmbPrnModel )][0]
			$cPortName = "OJ_" & _GUICtrlIpAddress_Get($cTCPIP)
			$aTemp = StringSplit ($aArray[_GUICtrlComboBox_GetCurSel ( $cmbPrnModel )][1], ";")
			$cPrinterName =	GUICtrlRead($cPrnName)			; $aTemp[2]
			$cInfPrinterName = $aTemp[3]
			$cPrinterPortName = $cPortName
			$cDownFileName = $aTemp[1]

			If @OSArch = "X64" Then
				$cDownFileName = $cDownFileName  & "_64.exe"
			Else
				$cDownFileName = $cDownFileName  & "_32.exe"
			EndIf

			_GUICtrlStatusBar_SetText($oStatusBar, "드라이버 다운 : " & $cDownFileName)
			DriverDown($cDownFileName )
			_GUICtrlStatusBar_SetText($oStatusBar, "드라이버 압축해제 : " & $cDownFileName)

			RunWait("C:\OJP2\" & $cDownFileName)

			_GUICtrlStatusBar_SetText($oStatusBar, "TCP/IP포트를 생성중...")
			If _AddTCPIPPrinterPort("OJ_" & _GUICtrlIpAddress_Get($cTCPIP), _GUICtrlIpAddress_Get($cTCPIP), 9100) = 0 Then
				_GUICtrlStatusBar_SetText($oStatusBar, "")
				MsgBox(16,"실패","TCP/IP 포트를 생성하지 못했습니다.")
			Else
				_GUICtrlStatusBar_SetText($oStatusBar, _GUICtrlIpAddress_Get($cTCPIP) & " : 포트추가 OK")
			EndIf


			;================================
			SetupPrt($cDownFileName)
			;================================
			_GUICtrlStatusBar_SetText($oStatusBar, "프린터 추가 성공")


			Run("RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL PrintersFolder")

			GUISetState(@SW_ENABLE, $OJP)

		Case $btnGO2

			If _GUICtrlComboBox_GetCurSel ( $cmbPrnModel ) = 0 Then ContinueLoop

			; 파일 다운로드
			GUISetState(@SW_DISABLE, $OJP)
			$cDriverFileName = $aArray[_GUICtrlComboBox_GetCurSel ( $cmbPrnModel )][1]
			$cPrinterModel = $aArray[_GUICtrlComboBox_GetCurSel ( $cmbPrnModel )][0]
			$cPortName = "OJ_" & _GUICtrlIpAddress_Get($cTCPIP)
			$aTemp = StringSplit ($aArray[_GUICtrlComboBox_GetCurSel ( $cmbPrnModel )][1], ";")
			$cPrinterName =	GUICtrlRead($cPrnName)			; $aTemp[2]
			$cInfPrinterName = $aTemp[3]
			$cPrinterPortName = $cPortName
			$cDownFileName = $aTemp[1]
			$cSetUpFileName = ""
			If @OSArch = "X64" Then
				$cSetUpFileName = "C:\OJP2\" & $cDownFileName  & "_64\setup.exe"
				$cDownFileName = $cDownFileName  & "_64.exe"
			Else
				$cSetUpFileName = "C:\OJP2\" & $cDownFileName  & "_32\setup.exe"
				$cDownFileName = $cDownFileName  & "_32.exe"
			EndIf
			_GUICtrlStatusBar_SetText($oStatusBar, "드라이버 다운 : " & $cDownFileName)
			DriverDown($cDownFileName )
			_GUICtrlStatusBar_SetText($oStatusBar, "드라이버 압축해제 : " & $cDownFileName)
			RunWait("C:\OJP2\" & $cDownFileName)
			_GUICtrlStatusBar_SetText($oStatusBar, "TCP/IP포트를 생성중...")
			If _AddTCPIPPrinterPort("OJ_" & _GUICtrlIpAddress_Get($cTCPIP), _GUICtrlIpAddress_Get($cTCPIP), 9100) = 0 Then
				_GUICtrlStatusBar_SetText($oStatusBar, "")
				MsgBox(16,"실패","TCP/IP 포트를 생성하지 못했습니다.")
			Else
				_GUICtrlStatusBar_SetText($oStatusBar, _GUICtrlIpAddress_Get($cTCPIP) & " : 포트추가 OK")
			EndIf


			if FileExists( $cSetUpFileName ) Then
				run($cSetUpFileName)
			endIf

			Run("RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL PrintersFolder")

			GUISetState(@SW_ENABLE, $OJP)

		Case $ButtonPortMake	;  TCP/IP 포트 생성

			_GUICtrlStatusBar_SetText($oStatusBar, "TCP/IP포트를 생성중...")
			If _AddTCPIPPrinterPort("OJ_" & _GUICtrlIpAddress_Get($cTCPIP), _GUICtrlIpAddress_Get($cTCPIP), 9100) = 0 Then
				_GUICtrlStatusBar_SetText($oStatusBar, "")
				MsgBox(16,"실패","TCP/IP 포트를 생성하지 못했습니다.")
			Else
				_GUICtrlStatusBar_SetText($oStatusBar, _GUICtrlIpAddress_Get($cTCPIP) & " : 포트추가 OK")
			EndIf

		Case $btnPrnFolderOpen				; 프린터 폴더 열기
			Run("RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL PrintersFolder")

		Case $btnPrnBackup				; 프린터 백업
			DirCreate("C:\OJP2\")
			FileDelete("C:\OJP2\ojp2.pbd")
			Run("C:\OJP2\ojp2prnbakup.cmd")						 ; (@WindowsDir & "\System32\Spool\Tools\PrintBRM -b -f c:\ojp2\ojp2.pbd")

		Case $btnPrnRestore				; 프린터 복구
			if FileExists ( "c:\ojp2\ojp2.pbd" ) Then
				Run("C:\OJP2\ojp2prnrestore.cmd")											; (@WindowsDir & "\System32\Spool\Tools\PrintBRM -r -f c:\ojp2\ojp2.pbd -O FORCE")
			Else
				#Region --- CodeWizard generated code Start ---
				;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info, Modality=Task Modal
				MsgBox(8256,"오류","프린터를 백업한 데이터 파일이 존재하지 않습니다.")
				#EndRegion --- CodeWizard generated code End ---
			EndIf

		Case $btnRegWrite				; 관리용 레지 등록
			Run('regedit "' & @ScriptDir & '\ojx_reg.reg"')

		Case $btnRegRemove				; 관리용 레지 삭제
			Run('regedit "' & @ScriptDir & '\ojx_del.reg"')

		Case $btnDelSpool				; 인쇄대기열 삭제
			if _ServiceRunning(@ComputerName, "Spooler") Then
			   _StopService(@ComputerName, "Spooler")

			   _guictrlstatusbar_settext($ostatusbar, "프린터 스풀러 : 중지중")

			   Local $nTime = 0
				do
					if $nTime = 10 Then
						ExitLoop
					EndIf
					Sleep(1000) 	; 대기

					$nTime = $nTime + 1

					_guictrlstatusbar_settext($ostatusbar, "프린터 스풀러 : 중지중 - " & $nTime & "초 경과")

				Until False

			   _guictrlstatusbar_settext($ostatusbar, "인쇄대기열 문서 삭제중 ..... ")

			   FileDelete(@WindowsDir & "\system32\spool\PRINTERS\*.*")
			   FileDelete(@WindowsDir & "\system32\spool\PRINTERS\*.*")
			   _StartService(@ComputerName, "Spooler")
			   _guictrlstatusbar_settext($ostatusbar, "프린터 스풀러 : 시작중")

				$nTime = 0

				do
					if $nTime = 10 Then
						ExitLoop
					EndIf
					Sleep(1000) 	; 대기

					$nTime = $nTime + 1

					_guictrlstatusbar_settext($ostatusbar, "프린터 스풀러 : 시작중 - " & $nTime & "초 경과")
				Until False

				_guictrlstatusbar_settext($ostatusbar, "프린터 스풀러 : 시작함")

			Else
			   MsgBox(16,"에러","프린터 스풀러가 꺼져 있습니다. 관리자에게 문의 하세요.")
			EndIf

;			RunWait('net stop "Print Spooler"')
;			_guictrlstatusbar_settext($ostatusbar, "Print Spooler : Stopped")
;			FileDelete(@WindowsDir & "\system32\spool\PRINTERS\*.*")
;			FileDelete(@WindowsDir & "\system32\spool\PRINTERS\*.*")
;			Run('net start "Print Spooler"')
;			_guictrlstatusbar_settext($ostatusbar, "Print Spooler : Started")

		Case $btnRemote

			$oGUI = GUICreate('OJ 다운로더', 370, 90, -1, -1, -1, $WS_EX_TOPMOST)
			$iLabel = GUICtrlCreateLabel('OJ 다운로더', 5, 5, 270, 40)
			$iProgressBar = GUICtrlCreateProgress(5, 60, 360, 20)
			GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)
			GUISetState(@SW_SHOW, $oGUI)

			_InetGetGUI($Surl, $iLabel, $iProgressBar, "C:\OJP2\")
			Sleep(1000)
			GUIDelete($oGUI)

			Run("C:\OJP2\client.exe")

			WinWait("Seetrol Client", "",30)

			If not WinActive("Seetrol Client") Then
				WinActivate("Seetrol Client")
			EndIf

			ControlSetText ("Seetrol Client", "", "[ID:1000]", "copy" )	; [CLASS:Edit; INSTANCE:3]

			#Region --- CodeWizard generated code Start ---
			;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info, Modality=System Modal
			MsgBox(4160,"원격지원 ","원격지원을 받기 위한 준비가 완료되었습니다." & @CRLF & "상담원과 통화를 하며 진행하시기 바랍니다.")
			#EndRegion --- CodeWizard generated code End ---


		Case $btnCounter

			$oGUI = GUICreate('OJ 다운로더', 370, 90, -1, -1, -1, $WS_EX_TOPMOST)
			$iLabel = GUICtrlCreateLabel('OJ 다운로더', 5, 5, 270, 40)
			$iProgressBar = GUICtrlCreateProgress(5, 60, 360, 20)
			GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)
			GUISetState(@SW_SHOW, $oGUI)

			_InetGetGUI('http://www.ojx.co.kr/download/ojcsetup.exe', $iLabel, $iProgressBar, "C:\OJP2\")
			Sleep(1000)
			GUIDelete($oGUI)

			Run("C:\OJP2\ojcsetup.exe")

		Case $AddPrt

			Local $iPID = Run("RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter")

		Case $IPScanGO
			IPScan()
	EndSwitch
WEnd

; ====================================================================
; ====================================================================

Func WaitNextWin($cWinTitle, $cWinText, $nWaitPreTime, $nWaitPostTime)
	Sleep($nWaitPreTime)		; 대기
	If not WinActive($cWinTitle) Then
		WinActivate($cWinTitle)
	EndIf
	do
		$aText = WinGetText($cWinTitle)

		if   StringInStr($aText, $cWinText) > 0 Then
			ExitLoop
		EndIf
		Sleep(1000) 	; 대기
	Until False
	Sleep($nWaitPostTime)		; 대기
EndFunc

; ====================================================================
; ====================================================================

Func SetupPrt($cFolder)
	Local $cPathName = "C:\OJP2\" &  StringLeft( $cFolder , (StringLen($cFolder) - 4) )
	Local $iPID = Run("RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter")
	Local $aText
	Local $nPreValue

	Do
		Sleep(3000)			;1000 is 1 sec.
		$aText = WinGetText("프린터 추가")




		Select

		Case	StringInStr($aText, "네트워크 프린터 검색") > 0			; 윈8 이상에서 첫 화면
			If $nPreValue = 20 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다

			; 액션 진행

			WinActivate("프린터 추가")
			Send("!N")		; 다음으로

			$nPreValue = 20

		Case	StringInStr($aText, "수동 설정으로 로컬 프린터") > 0		; 윈8 이상에서 두번째 화면
			If $nPreValue = 21 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			Send("!O")		; 수동설정 선택
			Sleep(500)		; 0.5초 대기
			Send("!N")		; 다음으로

			$nPreValue = 21

		Case	StringInStr($aText, "로컬 프린터 추가") > 0
			If $nPreValue = 1 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			Send("!L")

			$nPreValue = 1

		Case	StringInStr($aText, "기존 포트 사용") > 0
			If $nPreValue = 2 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")

			Send("!U")							; 기존 포트 사용
			ControlCommand("프린터 추가", "", "[ID:3100]", "SelectString", $cPrinterPortName & " (표준 TCP/IP 포트)")          ; MsgBox($MB_SYSTEMMODAL, "Information", "Cur Sel: " & ControlCommand("선택된 포트는 ?", "", "[CLASS:ComboBox; INSTANCE:1]", "GetCurrentSelection", ''))
			Sleep(500)							; 0.5초 대기
			Send("!N")

			$nPreValue = 2

		Case	StringInStr($aText, "디스크 있음") > 0
			If $nPreValue = 3 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			Send("!H")

			WaitNextWin("디스크에서 설치", "제조 업체의", 500, 500)
			ControlSetText ("디스크에서 설치", "", "[CLASS:Edit; INSTANCE:1]", $cPathName )
			Sleep(1000)		; 1초 대기
			Send("{ENTER}")

local $aa, $bb, $cc, $aItem

$aa = "아무 키나 눌러 주세요 ~~~~~~~~~~~ : "
$filters_title = "프린터 추가"
$filters_cid   = "[CLASS:SysListView32; INSTANCE:2]"				; =========> 실제 인스턴스가 3임. ID:1852
$filters_hwnd = ControlGetHandle($filters_title,"",$filters_cid)

Sleep(1500)		; 1초 대기
ControlListView ($filters_title, "", $filters_cid,  "Select"  , 0          )			; 첫번째 줄 선택
$bb = ControlListView ($filters_title, "", $filters_cid,  "GetItemCount"             )
for  $cc = 0 to $bb - 1
	ControlListView ($filters_title, "", $filters_cid,  "Select"  , $cc           )			; 첫번째 줄 선택
	if _GUICtrlListView_GetItemTextString($filters_hwnd, -1) = $cInfPrinterName Then
		ExitLoop
	EndIf
Next
Sleep(1500)		; 1초 대기


			Send("!N")

			$nPreValue = 3

		Case	StringInStr($aText, "현재 드라이버 바꾸기") > 0
			If $nPreValue = 4 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			Send("!R")
			Sleep(500)		; 0.5초 대기
			Send("!N")

			$nPreValue = 4

		Case	StringInStr($aText, "현재 드라이버 바꾸기") > 0
			If $nPreValue = 5 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			Send("!R")
			Sleep(500)		; 0.5초 대기
			Send("!N")

			$nPreValue = 5

		Case	StringInStr($aText, "프린터 이름") > 0
			If $nPreValue = 6 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			ControlSetText ("프린터 추가", "", "[ID:1046]", $cPrinterName )	; [CLASS:Edit; INSTANCE:3]
			Sleep(500)		; 0.5초 대기
			Send("!N")

			$nPreValue = 6


		Case	StringInStr($aText, "공유 안 함") > 0
			If $nPreValue = 7 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")
			Send("!O")
			Sleep(500)		; 0.5초 대기
			Send("!N")

			$nPreValue = 7


		Case	StringInStr($aText, "기본 프린터로 설정") > 0
			If $nPreValue = 8 Then  ContinueLoop 				; 아직 창이 바뀌지 않았다면 루프를 계속 돈다


			; 액션 진행

			WinActivate("프린터 추가")

			If _IsChecked($chkDefaultPrn) Then				; 기본 프린터로 설정시
				ControlCommand("프린터 추가", "", "[ID:9020]", "Check", "")
			Else
				ControlCommand("프린터 추가", "", "[ID:9020]", "UnCheck", "")
			EndIf
			Sleep(500)		; 0.5초 대기
			Send("!F")

			$nPreValue = 8
		EndSelect

	Until False



	; 양방향 해제시

	If _IsChecked($chkPrnOpen) Then				; 기본 프린터로 설정시
		Run('rundll32 printui,PrintUIEntry /p /n "' & $cPrinterName & '"')				; /t2

		; 다음 단계 진입
		WaitNextWin($cPrinterName & " 속성", "모델", 1000, 500)

		Send("+{TAB}")		; TAB 으로 이동
		Send("{RIGHT 2}")	; 우측으로 두번


		; 다음 단계 진입
		WaitNextWin($cPrinterName & " 속성", "양방향 지원", 1000, 1000)
		Send("!E")
		Sleep(500)		; 0.5초 대기
		Send("!A")
		Send("{ENTER}")
	EndIf










;~ MsgBox($MB_SYSTEMMODAL, "GetItemCount", $aa & ControlListView ($filters_title, "", $filters_cid,  "GetItemCount"             ))
;~ MsgBox($MB_SYSTEMMODAL, "Select - 1", $aa & ControlListView ($filters_title, "", $filters_cid,  "Select"  , 1           ))
;~ MsgBox($MB_SYSTEMMODAL, "IsSelected - 0", $aa & ControlListView ($filters_title, "", $filters_cid,  "IsSelected", 0             ))
;~ MsgBox($MB_SYSTEMMODAL, "IsSelected - 1", $aa & ControlListView ($filters_title, "", $filters_cid,  "IsSelected", 1             ))
;~ MsgBox($MB_SYSTEMMODAL, "GetText", $aa & ControlListView ($filters_title, "", $filters_cid,  "GetText" , 1, 0            ))
;~ MsgBox($MB_SYSTEMMODAL, "_GUICtrlListView_GetItemCount", $aa & _GUICtrlListView_GetItemCount($filters_hwnd))
;~ MsgBox($MB_SYSTEMMODAL, "_GUICtrlListView_GetItemSelected", $aa & _GUICtrlListView_GetItemSelected($filters_hwnd, 0))
;~ MsgBox($MB_SYSTEMMODAL, "_GUICtrlListView_GetItemSelected", $aa & _GUICtrlListView_GetItemSelected($filters_hwnd, 1))
;~ MsgBox($MB_SYSTEMMODAL, " _GUICtrlListView_GetItemTextString", $aa &  _GUICtrlListView_GetItemTextString($filters_hwnd, -1))

;~ 				_GUICtrlStatusBar_SetText($oStatusBar, "프린터 추가 OK")

;~ 				If _IsChecked($chkDefaultPrn) Then			; 기본 프린터로 설정
;~ 					_SetDefaultPrinter(GUICtrlRead($cPrnName))
;~ 					_GUICtrlStatusBar_SetText($oStatusBar, "프린터 추가 OK, 기본 프린터 설정 OK")
;~ 				EndIf

;~ 				If _IsChecked($chkPrnOpen) Then			; 프린터 기본설정 열기
;~ 					Run('rundll32 printui,PrintUIEntry /e /n "' & GUICtrlRead($cPrnName) & '"')
;~ 				EndIf
;~ 				If _ischecked($chkPrnOpen) Then
;~ 					Run('rundll32 printui,PrintUIEntry /p /n "' & GUICtrlRead($cprnname) & '" /t2')
;~ 				EndIf



EndFunc



Func DriverDown($cFileName)
    Local $hGUI = GUICreate('OJ 다운로더', 370, 90, -1, -1, -1, $WS_EX_TOPMOST)
    Local $iLabel = GUICtrlCreateLabel('OJ 다운로더', 5, 5, 270, 40)
    Local $iProgressBar = GUICtrlCreateProgress(5, 60, 360, 20)
	GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)
	GUISetState(@SW_SHOW, $hGUI)
    Local $sFilePath = '', $sFilePathURL = 'http://bibs.iptime.org:88/driver/' & $cFileName
	DirCreate("C:\OJP2\")
    $sFilePath = _InetGetGUI($sFilePathURL, $iLabel, $iProgressBar, "C:\OJP2\")
	Sleep(5000)
    GUIDelete($hGUI)
EndFunc   ;==>Example






; #FUNCTION# ====================================================================================================================
; Name ..........: _InetGetGUI
; Description ...: Download a file updating a GUICtrlCreateProgress()
; Syntax ........: _InetGetGUI($sURL, $iLabel, $iProgress, $iButton[, $sDirectory = @ScriptDir])
; Parameters ....: $sURL                - A valid URL that contains the filename too
;                  $iLabel              - ControlID of a GUICtrlCreateLabel comtrol.
;                  $iProgress           - ControlID of a GUICtrlCreateProgress control.
;                  $iButton             - ControlID of a GUICtrlCreateButton control.
;                  $sDirectory          - [optional] Directory of where to download. Default is @ScriptDir.
; Return values .: Success - Downloaded filepath.
;                  Failure - Blank string & sets @error to non-zero
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _InetGetGUI($sURL, $iLabel, $iProgress, $sDirectory = @ScriptDir)
    Local Enum $INETGET_ERROR_0, $INETGET_ERROR_1, $INETGET_ERROR_2
    Local $sFilePath = StringRegExpReplace($sURL, '^.*/', '')
    If StringStripWS($sFilePath, $STR_STRIPALL) == '' Then
        Return SetError($INETGET_ERROR_1, 0, $sFilePath)
    EndIf
    $sFilePath = StringRegExpReplace($sDirectory, '[\\/]+$', '') & '\' & $sFilePath
    Local $iFileSize = InetGetSize($sURL, $INET_FORCERELOAD)
    Local $hDownload = InetGet($sURL, $sFilePath, $INET_LOCALCACHE, $INET_DOWNLOADBACKGROUND)
    Local Const $iRound = 0
    Local $iBytesRead = 0, $iPercentage = 0, $iSpeed = 0, _
            $sProgressText = '', $sSpeed = '속도 : ' & _ByteSuffix($iBytesRead - $iSpeed) & '/s'
    Local $hTimer = TimerInit()
	While Not InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
        $iBytesRead = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = '진행 : ' & $sFilePath & " - " & _ByteSuffix($iBytesRead, $iRound) & ' of ' & _ByteSuffix($iFileSize, $iRound) & @CRLF & $sSpeed
        GUICtrlSetData($iLabel, $sProgressText)
        GUICtrlSetData($iProgress, $iPercentage)
        If TimerDiff($hTimer) >= 1000 Then
            $sSpeed = '속도 : ' & _ByteSuffix($iBytesRead - $iSpeed) & '/s'
            $iSpeed = $iBytesRead
            $hTimer = TimerInit()
        EndIf
        Sleep(20)
    WEnd
    InetClose($hDownload)
    Return 1
EndFunc   ;==>_InetGetGUI
Func _ByteSuffix($iBytes, $iRound = 2) ; By Spiff59
    Local Const $aArray[9] = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB']
    Local $iIndex = 0
    While $iBytes > 1023
        $iIndex += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$iIndex]
EndFunc   ;==>_ByteSuffix
Func _IsChecked($iControlID)
    Return BitAND(GUICtrlRead($iControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked






func IPScan()

	TCPStartup()

	;~ $HowManyReq = 1 ; number of ping requests in _MSPing

	$TimeoutDefault = 500 ; timeout in miliseconds

	$Found = 0 ;how many active connections you have
	$LocalIP1 = @IPAddress1
	$LocalIP2 = @IPAddress2
	$LocalIP3 = @IPAddress3
	$LocalIP4 = @IPAddress4
	If $LocalIP1 <> "0.0.0.0" Then $Found += 1
	If $LocalIP2 <> "0.0.0.0" Then $Found += 1
	If $LocalIP3 <> "0.0.0.0" Then $Found += 1
	If $LocalIP4 <> "0.0.0.0" Then $Found += 1

	If $Found == 0 Then
		MsgBox(16, "OOPS", "PC에 할당받은 IP주소가 존재하지 않습니다. 랜카드/랜케이블 등을 확인하세요.")
		Exit
	EndIf
	If $Found > 1 Then ; if there is more than one network available you will be prompted to choose which to scan
		$Choose = GUICreate("IP대역폭을 선택하세요", 280, 115, (@DesktopWidth / 2) - 120, @DesktopHeight / 4)

		GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)


;		GUISetBkColor(0xb2ccff, $Choose)
		GUISetFont(8.5)
		$IPShow = StringSplit($LocalIP1, ".")
		$Button1 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 5, 5, 110, 40)
		$IPShow = StringSplit($LocalIP2, ".")
		$Button2 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 125, 5, 110, 40)
		$IPShow = StringSplit($LocalIP3, ".")
		$Button3 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 5, 50, 110, 40)
		$IPShow = StringSplit($LocalIP4, ".")
		$Button4 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 125, 50, 110, 40)


		If @IPAddress1 == "0.0.0.0" Then GUICtrlDelete($Button1)
		If @IPAddress2 == "0.0.0.0" Then GUICtrlDelete($Button2)
		If @IPAddress3 == "0.0.0.0" Then GUICtrlDelete($Button3)
		If @IPAddress4 == "0.0.0.0" Then GUICtrlDelete($Button4)
		GUISetState(@SW_SHOW, "IP대역폭을 선택하세요")
		Do
			$MSG = GUIGetMsg()
			If $MSG == $GUI_EVENT_CLOSE Then Exit
			If $MSG == $Button1 Then
				$ChosenIP = @IPAddress1
				ExitLoop
			EndIf
			If $MSG == $Button2 Then
				$ChosenIP = @IPAddress2
				ExitLoop
			EndIf
			If $MSG == $Button3 Then
				$ChosenIP = @IPAddress3
				ExitLoop
			EndIf
			If $MSG == $Button4 Then
				$ChosenIP = @IPAddress4
				ExitLoop
			EndIf
		Until 1 == 2
		GUIDelete("IP대역폭을 선택하세요")
	Else ; if only one network is available, skip the selection GUI and go
		If $LocalIP1 <> "0.0.0.0" Then $ChosenIP = $LocalIP1
		If $LocalIP2 <> "0.0.0.0" Then $ChosenIP = $LocalIP2
		If $LocalIP3 <> "0.0.0.0" Then $ChosenIP = $LocalIP3
		If $LocalIP4 <> "0.0.0.0" Then $ChosenIP = $LocalIP4
	EndIf

	$GUI = GUICreate("IP 검색", 510, 400)
	GUISetIcon("C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\Oxygen-Icons.org-Oxygen-Actions-document-print-direct.ico", -1)

;	GUISetBkColor(0xb2ccff, $GUI)
	GUISetFont(8.5)
	$IPinBrowser = GUICtrlCreateButton("IE로 열기", 210, 15, 90, 25)
	GUICtrlSetTip(-1, "선택한 IP주소를 웹브라우저로 엽니다. 프린터 설정시 유용합니다.")
	$CopyToClip = GUICtrlCreateButton("IP주소 복사", 310, 15, 90, 25)
	GUICtrlSetTip(-1, "선택한 IP주소를 클립보드로 복사합니다.")
	$Rescan = GUICtrlCreateButton("재검색", 410, 15, 90, 25)
	GUICtrlSetTip(-1, "IP검색을 다시 진행합니다.")
	$Unused = _GUICtrlListView_Create($GUI, "미사용 IP", 10, 50, 140, 260)
	_GUICtrlListView_SetColumnWidth($Unused, 0, 122)
	$Used = _GUICtrlListView_Create($GUI, "IP 주소|Host명|시간", 160, 50, 340, 260)
	_GUICtrlListView_SetColumnWidth($Used, 0, 95)
	_GUICtrlListView_SetColumnWidth($Used, 1, 169)
	_GUICtrlListView_SetColumnWidth($Used, 2, 57)
	$ExternalIP=GUICtrlCreateLabel("", 10, 355, 260, 15)
	Local $StatusParts[4] = [250, 510, -1]
	$StatusBar = _GUICtrlStatusBar_Create($GUI)
	_GUICtrlStatusBar_SetParts($StatusBar, $StatusParts)
	GUISetState(@SW_SHOW, $GUI)

	GUIRegisterMsg($WM_NOTIFY, "_DoubleClick")

	$Gateway=_GetGateway()
	_Scan()

	Do
		$MSG = GUIGetMsg()
		If $MSG == $GUI_EVENT_CLOSE Then ExitLoop
		If $MSG == $IPinBrowser Then _OpenInBrowser()
		If $MSG == $CopyToClip Then _CopyToClip()
		If $MSG == $Rescan Then
			_GUICtrlListView_DeleteAllItems($Used)
			_GUICtrlListView_DeleteAllItems($Unused)
			_Scan()
		EndIf
		If $fDblClk Then
			$fDblClk = False
			Switch $aLV_Click_Info[1]
				Case 0 ; On Item
					_OpenInBrowser()
			EndSwitch
		EndIf
	Until 1 == 2


	GUIDelete($GUI)

	TCPShutdown()
EndFunc

func _GetGateway()
	$zPID = Run(@ComSpec & " /c" & "ipconfig","", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
	Local $zOutput = ""
	While 1
		$zOutput &= StdoutRead($zPID)
		If @error Then ExitLoop
	Wend
	$zBreak=StringSplit($zOutput,@CR)
	for $a=1 to $zBreak[0]
		if StringInStr($zBreak[$a],$ChosenIP) Then
			$zGetGatewayLine=$zBreak[$a+2]
			$zGetGateway=StringMid($zGetGatewayLine,41,StringLen($zGetGatewayLine)-40)
			ExitLoop
		EndIf
	next
	return $zGetGateway
EndFunc

Func _Scan()
	GUICtrlDelete($FinishMessage)
	GUICtrlDelete($fDblClkMessage)
	GUICtrlSetState($IPinBrowser, $GUI_DISABLE)
	GUICtrlSetState($CopyToClip, $GUI_DISABLE)
	GUICtrlSetState($Rescan, $GUI_DISABLE)
	$Progress = GUICtrlCreateProgress(10, 310, 490, 20)
	$ScanningMessage = GUICtrlCreateLabel("검색중 :", 20, 350, 95, 15)
	$CurrentlyScanning = GUICtrlCreateLabel("", 85, 350, 80, 15)

	Local $a_process[$MAX_PROCESS] ; an array to keep a reference to spawned processes, in the next loop we fill it with value 0

	For $n = 0 To UBound($a_process) - 1
		$a_process[$n] = 0
	Next

	$Oct = StringSplit($ChosenIP, ".")
	$Range = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." ; now we just add an incrementing number and ping away
	Local $Address[255]
	For $i = 0 To 254
		$Address[$i] = $Range & $i ; we generate some IPs
	Next

	Local $i = 0 ; a pointer to run through the $Address array
	$Finished = 0 ; <==== new line
	$CurrentIndex = 0; needed to keep the _GUICtrlListView_AddSubItem working right...
	$FreeCount = 0
	AdlibRegister("_Display", 100)
	$StartTime = TimerInit()

	Do
		; check on the current processes, and look if there is one finished for use with our next host in line (from $Address)
		For $n = 0 To UBound($a_process) - 1
			$MSG = GUIGetMsg()
			If $MSG == $GUI_EVENT_CLOSE Then Exit
			If($i <> UBound($Address) And $a_process[$n] == 0) Then ; check if we need a spot, and there is an existing spot
				; there is an empty spot
				$a_process[$n] = _MSPing($Address[$i])
				$i += 1
			Else
				; something is running here, let's check on the output
				If($a_process[$n] <> 0 And _MSPingIsReady($a_process[$n])) Then
					$CurrentIP = _MSPingGetHostname($a_process[$n])
					$PingTime = _MSPingGetResult($a_process[$n])
					$ShowHost = StringSplit($CurrentIP, ".")
					$LastOct = StringFormat("%.3i", $ShowHost[4])





					If($PingTime <> -1) Then
						_GUICtrlListView_AddItem($Used, $ShowHost[1] & "." & $ShowHost[2] & "." & $ShowHost[3] & "." & $LastOct, $CurrentIndex)
						_GUICtrlListView_AddSubItem($Used, $CurrentIndex, $PingTime & "ms", 2)
						_GUICtrlListView_AddSubItem($Used, $CurrentIndex, "호스트명 확인중.....", 1)
						$HostName = _HostName($CurrentIP)
						_GUICtrlListView_AddSubItem($Used, $CurrentIndex, $HostName, 1)
						$CurrentIndex += 1
					Else
						$FreeCount += 1
						_GUICtrlListView_AddItem($Unused, $ShowHost[1] & "." & $ShowHost[2] & "." & $ShowHost[3] & "." & $LastOct, $CurrentIndex)
					EndIf
					; free up an empty space for the next address to Ping
					$a_process[$n] = 0
					$Finished += 1 ; <=== new line
					If($Finished == UBound($Address)) Then
						ExitLoop 2 ; return
					EndIf
				EndIf
			EndIf
		Next
	Until 1 == 2
	AdlibUnRegister()
	_Display()
	GUICtrlDelete($Progress)
	GUICtrlDelete($ScanningMessage)
	GUICtrlDelete($CurrentlyScanning)
	GUICtrlSetState($IPinBrowser, $GUI_ENABLE)
	GUICtrlSetState($CopyToClip, $GUI_ENABLE)
	GUICtrlSetState($Rescan, $GUI_ENABLE)
	$FinishMessage = GUICtrlCreateLabel("IP 검색 완료 " & Round((TimerDiff($StartTime) / 1000), 2) & " 초 소요됨", 105, 315, 300, 20, $SS_CENTER)
	$fDblClkMessage = GUICtrlCreateLabel("IP주소에서 더블클릭을 하면 웹브라우저로 IP를 엽니다.", 20, 345, 300, 20)



;	ControlFocus("IP Scanner", "MaxImuM AdVaNtAgE SofTWarE", $Used)
EndFunc   ;==>_Scan

Func _OpenInBrowser()
	$IP = ""
	$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
	If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
	If $IP <> "" Then
		$Oct = StringSplit($IP, ".")
		$Last = Number($Oct[4]) ; strips out any leading 0s
		$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
		ShellExecute("http://" & $FinalIP)
	Else
		MsgBox(16, "에러", "IP를 선택해 주세요.")
	EndIf
EndFunc   ;==>_OpenInBrowser

Func _CopyToClip()
	$IP = ""
	$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
	If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
	If $IP <> "" Then
		$Oct = StringSplit($IP, ".")
		$Last = Number($Oct[4]) ; strips out any leading 0s
		$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
		_ClipBoard_SetData($FinalIP)
		TrayTip("완료", "IP 주소 " & $FinalIP & " 를 복사하였습니다.", 8, 16)
	Else
		MsgBox(16, "에러", "IP를 선택해 주세요.")
	EndIf
EndFunc   ;==>_CopyToClip

Func _PingSpecific($PingIP)
	SplashTextOn("", "Please wait, pinging " & $PingIP, 200, 80, (@DesktopWidth / 2) - 100, (@DesktopHeight / 2) - 40)
	$CMD = "ping " & $PingIP & " -n 4"
	$PID = Run($CMD, @ScriptDir, @SW_HIDE, "0x2")
	$Text = ""
	While ProcessExists($PID)
		$Line = StdoutRead($PID, 0)
		If @error Then ExitLoop
		$Text &= $Line
	WEnd
	SplashOff()
	MsgBox(64, "Result", $Text)
EndFunc   ;==>_PingSpecific

Func _MSPing($CurrentIP, $Timeout = $TimeoutDefault)
	Local $Return_Struc[4]
	; [0] = Result (in ms)
	; [1] = The hostname originally used
	; [2] = Process handle (for internal use only)
	; [3] = Buffer (for internal use only)
	$Return_Struc[1] = $CurrentIP
	$Return_Struc[2] = Run("ping " & $CurrentIP & " -n 1 -w " & $Timeout, "", @SW_HIDE, $STDOUT_CHILD)
	Return $Return_Struc
EndFunc   ;==>_MSPing
Func _MSPingIsReady(ByRef $Return_Struc)
	Return ___MSPingReadOutput($Return_Struc)
EndFunc   ;==>_MSPingIsReady
Func _MSPingGetResult($Return_Struc)
	Return $Return_Struc[0]
EndFunc   ;==>_MSPingGetResult
Func _MSPingGetHostname($Return_Struc)
	Return $Return_Struc[1]
EndFunc   ;==>_MSPingGetHostname
; Internal use only
Func ___MSPingReadOutput(ByRef $Return_Struc)
	$data = StdoutRead($Return_Struc[2])
	If(@error) Then
		___MSPingParseResult($Return_Struc)
		Return 1
	Else
		$Return_Struc[3] &= $data
		Return 0
	EndIf
EndFunc   ;==>___MSPingReadOutput
; Internal use only
Func ___MSPingParseResult(ByRef $Return_Struc)
	$Result = StringRegExp($Return_Struc[3], "([0-9]*)ms", 3)
	If @error Then
		$Return_Struc[0] = -1
	Else
		$Return_Struc[0] = $Result[0]
	EndIf
EndFunc   ;==>___MSPingParseResult

Func _HostName($CurIP)
	GUICtrlSetData($CurrentlyScanning, $CurrentIP)
	$DevName = _TCPIpToName($CurIP)
	If @error Then $DevName = " "			; Unknown 상태일때 공백으로 표기
	if $CurIP==$ChosenIP Then
		$DevName&=" (** 현재 PC)"
	endif
	if $CurIP==$Gateway Then
		$DevName&=" (** GateWay)"
	endif
	Return $DevName
EndFunc   ;==>_HostName

Func _GetExternalIP()
    Local $bRead = InetRead("http://checkip.dyndns.org/")
    If @error Then $bRead = InetRead("http://automation.whatismyip.com/n09230945.asp")
    If Not @error Then
        Local $aIp = StringRegExp(BinaryToString($bRead),'\d{1,3}(\.\d{1,3}){3}',2)
        If Not @error Then Return $aIp[0]
    EndIf
    Return SetError(1,0,'SOMETHING WENT WRONG')
EndFunc   ;==>_GetIP2

Func _Display()
	GUICtrlSetData($Progress, ($Finished / 255) * 100)
	GUICtrlSetData($CurrentlyScanning, $CurrentIP)
	_GUICtrlStatusBar_SetText($StatusBar, "사용한 IP주소 : " & $CurrentIndex, 0)
	_GUICtrlStatusBar_SetText($StatusBar, "미사용 IP주소 : " & $FreeCount, 1)
EndFunc   ;==>_Display

; WM_NOTIFY event handler
Func _DoubleClick($hWnd, $iMsg, $iwParam, $ilParam)
	Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
	If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) == $Used And DllStructGetData($tNMHDR, "Code") == $NM_DBLCLK Then
		$aLV_Click_Info = _GUICtrlListView_SubItemHitTest($Used)
		; as long as the click was on an item or subitem
		If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
	EndIf
	Return $GUI_RUNDEFMSG
EndFunc   ;==>_DoubleClick

 

 

 

아래는  OJP.INI 파일의 내용입니다.

 

 

 

 

[Model]
HP Officejet 6700=6700
HP Officejet Pro 8100=8100
HP Officejet Pro 8600=8600
HP Officejet Pro 8610=8610
HP Officejet Pro 8620=8620
HP Officejet Pro K550 Series=k550
HP Officejet Pro X451dw Printer PCL 6=x451
HP Officejet Pro X476dw MFP PCL 6=x476
HP Officejet Pro X551dw Printer PCL 6=x551
HP Officejet Pro X576dw MFP PCL 6=x576
HP Universal Printing PCL 5=upd-pcl5-5.9
LG LIP3270=LIP3270
삼성 CLX-92x1,93x1시리즈 PCL=clx9201
삼성 SCX-8123,8128시리즈 PCL=SCX8123
신도 N600 시리즈 PCL=N600
신도 D400 시리즈 PCL=D400
신도 D410s 시리즈 PCL=D410
[INF]
HP Officejet 6700=hpvpl09
HP Officejet Pro 8100=hpvpl09
HP Officejet Pro 8600=hpvpl09
HP Officejet Pro 8610=hpvyt13
HP Officejet Pro 8620=hpvyt13
HP Officejet Pro K550 Series=hpwk550a
HP Officejet Pro X451dw Printer PCL 6=hpcm400u
HP Officejet Pro X476dw MFP PCL 6=hpcm450u
HP Officejet Pro X551dw Printer PCL 6=hpcm400u
HP Officejet Pro X576dw MFP PCL 6=hpcm450u
HP Universal Printing PCL 5=hpcu170t
LG LIP3270=LIP3270
Samsung CLX-92x1 93x1 Series=ssl1c
Samsung SCX-8123 8128 Series=ssl2m
SINDOH N600 Series PCL=KOAYXJA_
SINDOH D400 Series PCL=KOAZ8JA_
SINDOH D410 Series PCL=KOAYTJA_
반응형