Loading... * 是这俩按钮: ![](https://image.cnotcat.cn/blogimg%2F20230526094620.png) * 如果没有TW_BottomShortCutQuery.ini和TW_TopShortCutQuery.ini这两个配置文件,手动加一下 > TW_BottomShortCutQuery.ini ```ini [登录技师已检查] PHOTOMAKERID=super [COMMON] CONDITION=Default [Default] NDAY=3 DEVICETYPEID=7 DEVICEID=771 ``` > TW_TopShortCutQuery.ini ```ini [待检查] NDAY=2 ;PHOTOMAKERID = is null PHOTOMAKER=超级用户 [COMMON] CONDITION =Default [FYL] STUDYSTATUS=0 , 10 , 20 [Default] NDAY=3 DEVICETYPEID=7 DEVICEID=771 STUDYSTATUS=0 , 10 , 20 ``` * 然后新增一个DevicePrepare.ini配置文件,记录是否绑定过设备 > DevicePrepare.ini ```ini [Default] Prepare=0 ``` * 这个是双击检查记录后 调用的脚本 > TW_ArtificerWorkStation.vbs ```vb Call Main Sub Main() checkSerialNum = Data.GetNamedValue("检查流水号") Data.SetNamedValue CStr("ShowStudyInfo"),0 writepath=".\Config\TW_BottomShortCutQuery.ini" writepath1=".\Config\DevicePrepare.ini" writepath2=".\Config\TW_TopShortCutQuery.ini" writesectionName="Default" writekeyName1="DEVICEID" writekeyName2="DEVICETYPEID" writekeyName3="Prepare" newvalue="1" ' Call WriteIni (writepath1,writesectionName,writekeyName3,newvalue) cc = ReadIni(writepath1, writesectionName, writekeyName3) if cc =0 then '------------------------查询设备信息 - Start-----------------------------' strSql = "select de.devicetypeid,de.devicetypename,d.deviceid,d.devicename from studyinfo s left join devicetable d on d.deviceid=s.deviceid left join devicetypeinfo de on de.devicetypeid=s.devicetypeid where s.checkserialnum='" & checkSerialNum & "'" Set rs = DBConnection.Execute(strSql) If not rs.eof Then devicetypeid = rs("devicetypeid") devicetypename = rs("devicetypename") deviceid = rs("deviceid") devicename = rs("devicename") end if '------------------------查询设备信息 - End-----------------------------' msgtxt1 = "为准确的让技师工作站与检查设备绑定,需要您确认以下信息:" + vbcrlf msgtxt2 =msgtxt1 + "即将绑定的设备信息为:" + vbcrlf msgtxt3 = msgtxt2 + vbcrlf msgtxt4 =msgtxt3 + "设备类型:"&devicetypename&"" + vbcrlf msgtxt5 =msgtxt4 + "设备名称:"&devicename&"" + vbcrlf msgtxt6 = msgtxt5 + vbcrlf msgtxt7 = msgtxt6 + "以上信息无误请点击 是 ,如信息不符请选择分诊到所在设备的检查" select case MsgBox (msgtxt7,vbYesNo,"诊室初始化设置提醒") case vbYes Call WriteIni (writepath1,writesectionName,writekeyName3,newvalue) Call WriteIni (writepath,writesectionName,writekeyName1,deviceid) Call WriteIni (writepath,writesectionName,writekeyName2,devicetypeid) Call WriteIni (writepath2,writesectionName,writekeyName1,deviceid) Call WriteIni (writepath2,writesectionName,writekeyName2,devicetypeid) MsgBox "绑定成功" case vbNo MsgBox "取消绑定" end Select end if end sub Sub WriteIni( myFilePath, mySection, myKey, myValue ) '写ini ' This subroutine writes a value to an INI file ' ' Arguments: ' myFilePath [string] the (path and) file name of the INI file ' mySection [string] the section in the INI file to be searched ' myKey [string] the key whose value is to be written ' myValue [string] the value to be written (myKey will be ' deleted if myValue is <DELETE_THIS_VALUE>) ' ' Returns: ' N/A ' ' CAVEAT: WriteIni function needs ReadIni function to run ' ' Written by Keith Lacelle ' Modified by Denis St-Pierre, Johan Pol and Rob van der Woude Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Dim blnInSection, blnKeyExists, blnSectionExists, blnWritten Dim intEqualPos Dim objFSO, objNewIni, objOrgIni, wshShell Dim strFilePath, strFolderPath, strKey, strLeftString Dim strLine, strSection, strTempDir, strTempFile, strValue strFilePath = Trim( myFilePath ) strSection = Trim( mySection ) strKey = Trim( myKey ) strValue = Trim( myValue ) Set objFSO = CreateObject( "Scripting.FileSystemObject" ) Set wshShell = CreateObject( "WScript.Shell" ) strTempDir = wshShell.ExpandEnvironmentStrings( "%TEMP%" ) strTempFile = objFSO.BuildPath( strTempDir, objFSO.GetTempName ) Set objOrgIni = objFSO.OpenTextFile( strFilePath, ForReading, True ) Set objNewIni = objFSO.CreateTextFile( strTempFile, False, False ) blnInSection = False blnSectionExists = False ' Check if the specified key already exists blnKeyExists = ( ReadIni( strFilePath, strSection, strKey ) <> "" ) blnWritten = False ' Check if path to INI file exists, quit if not strFolderPath = Mid( strFilePath, 1, InStrRev( strFilePath, "\" ) ) If Not objFSO.FolderExists ( strFolderPath ) Then WScript.Echo "Error: WriteIni failed, folder path (" _ & strFolderPath & ") to ini file " _ & strFilePath & " not found!" Set objOrgIni = Nothing Set objNewIni = Nothing Set objFSO = Nothing WScript.Quit 1 End If While objOrgIni.AtEndOfStream = False strLine = Trim( objOrgIni.ReadLine ) If blnWritten = False Then If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then blnSectionExists = True blnInSection = True ElseIf InStr( strLine, "[" ) = 1 Then blnInSection = False End If End If If blnInSection Then If blnKeyExists Then intEqualPos = InStr( 1, strLine, "=", vbTextCompare ) If intEqualPos > 0 Then strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) If LCase( strLeftString ) = LCase( strKey ) Then ' Only write the key if the value isn't empty ' Modification by Johan Pol If strValue <> "<DELETE_THIS_VALUE>" Then objNewIni.WriteLine strKey & "=" & strValue End If blnWritten = True blnInSection = False End If End If If Not blnWritten Then objNewIni.WriteLine strLine End If Else objNewIni.WriteLine strLine ' Only write the key if the value isn't empty ' Modification by Johan Pol If strValue <> "<DELETE_THIS_VALUE>" Then objNewIni.WriteLine strKey & "=" & strValue End If blnWritten = True blnInSection = False End If Else objNewIni.WriteLine strLine End If Wend If blnSectionExists = False Then ' section doesn't exist objNewIni.WriteLine objNewIni.WriteLine "[" & strSection & "]" ' Only write the key if the value isn't empty ' Modification by Johan Pol If strValue <> "<DELETE_THIS_VALUE>" Then objNewIni.WriteLine strKey & "=" & strValue End If End If objOrgIni.Close objNewIni.Close ' Delete old INI file objFSO.DeleteFile strFilePath, True ' Rename new INI file objFSO.MoveFile strTempFile, strFilePath Set objOrgIni = Nothing Set objNewIni = Nothing Set objFSO = Nothing Set wshShell = Nothing End Sub Function ReadIni( myFilePath, mySection, myKey ) ' 读ini ' This function returns a value read from an INI file ' ' Arguments: ' myFilePath [string] the (path and) file name of the INI file ' mySection [string] the section in the INI file to be searched ' myKey [string] the key whose value is to be returned ' ' Returns: ' the [string] value for the specified key in the specified section ' ' CAVEAT: Will return a space if key exists but value is blank ' ' Written by Keith Lacelle ' Modified by Denis St-Pierre and Rob van der Woude Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Dim intEqualPos Dim objFSO, objIniFile Dim strFilePath, strKey, strLeftString, strLine, strSection Set objFSO = CreateObject( "Scripting.FileSystemObject" ) ReadIni = "" strFilePath = Trim( myFilePath ) strSection = Trim( mySection ) strKey = Trim( myKey ) If objFSO.FileExists( strFilePath ) Then Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False ) Do While objIniFile.AtEndOfStream = False strLine = Trim( objIniFile.ReadLine ) ' Check if section is found in the current line If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then strLine = Trim( objIniFile.ReadLine ) ' Parse lines until the next section is reached Do While Left( strLine, 1 ) <> "[" ' Find position of equal sign in the line intEqualPos = InStr( 1, strLine, "=", 1 ) If intEqualPos > 0 Then strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) ' Check if item is found in the current line If LCase( strLeftString ) = LCase( strKey ) Then ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) ) ' In case the item exists but value is blank If ReadIni = "" Then ReadIni = " " End If ' Abort loop when item is found Exit Do End If End If ' Abort if the end of the INI file is reached If objIniFile.AtEndOfStream Then Exit Do ' Continue with next line strLine = Trim( objIniFile.ReadLine ) Loop Exit Do End If Loop objIniFile.Close Else WScript.Echo strFilePath & " doesn't exists. Exiting..." Wscript.Quit 1 End If End Function ``` * 双击检查记录后 : ![](https://image.cnotcat.cn/20240422101605.png) 最后修改:2024 年 04 月 22 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏