原始文件可以是两个TXT文档,一个是身份证 ID.TXT,一个是姓名 Name.TXT;也可以是一个Excel的两列数据;
主要需求是利用原始文件的数据,在网页http://jndj.osta.org.cn/;按照对应的姓名,身份证号码,进行查询,哪位大神帮忙看看。
感觉应该不难,但是网上实在是找不到对应的样本,谢谢
按行读取名字,身份证号码,在网页粘贴查询 Topic is solved
Moderators: tmplinshi, arcticir
Re: 按行读取名字,身份证号码,在网页粘贴查询 Topic is solved
Code: Select all
#Requires AutoHotkey v2.0
F4:: ; 指定热键为F4
{
explorerSel := explorerGetSel(hwnd:="",true) ; 获得选中的项目
if(explorerSel != "ERROR" && explorerSel) { ; 如果在资源管理窗口并且有选中的项目
file1 := strSplit(explorerSel, "`n")[1] ; 获取第一行
if (fileExist(file1) != "D") { ; 如果不是文件夹则读取文件内容
content := fileRead(file1, "UTF-8")
msgbox content
}
}
}
explorerGetSel(hwnd := '', selection := True)
{
hwWindow := ''
ret := ""
Switch window := explorerGetWindow(hwnd)
{
Case '':
Return 'ERROR'
Case 'desktop':
Try hwWindow := ControlGetHwnd('SysListView321', 'ahk_class Progman')
hwWindow := hwWindow || ControlGetHwnd('SysListView321', 'A')
Loop Parse ListViewGetContent((selection ? 'Selected' : '') ' Col1', hwWindow), '`n', '`r'
{
SplitPath A_LoopField, , , &ext ; 获得拓展名
if(!ext && !DirExist(A_Desktop '\' A_LoopField)) ; 如果没拓展名并且不是文件夹,则获得快捷方式的目标,并叠加到变量ret
{
shortcut := A_Desktop '\' A_LoopField ".lnk"
if !fileExist(shortcut)
shortcut := A_DesktopCommon '\' A_LoopField ".lnk"
try FileGetShortcut shortcut, &OutTarget
catch {
msgbox("桌面项目需在资源管理器勾选此项:查看-显示-文件拓展名")
return
}
ret .= OutTarget '`n'
} else { ; 如果是文件或者是文件夹则直接叠加
ret .= A_Desktop '\' A_LoopField '`n'
}
}
Default: ; 如果不是在桌面则直接叠加
For item in selection ? window.document.SelectedItems : window.document.Folder.Items
ret .= item.path '`n'
}
Return Trim(ret, '`n')
}
; 如果是桌面则返回“desktop”
explorerGetWindow(hwnd := '')
{
class := WinGetClass(hwnd := hwnd || WinExist('A'))
Switch
{
Case WinGetProcessName(hwnd) != 'explorer.exe': Return
Case class ~= 'Progman|WorkerW': Return 'desktop'
Case class ~= '(Cabinet|Explore)WClass':
For window in ComObject('Shell.Application').Windows
Try If window.hwnd = hwnd
Return window
}
}
Re: 按行读取名字,身份证号码,在网页粘贴查询
感谢不吝赐教,不过实在没有读懂,这些代码和ID.TXT ,Name.TXT 以及那个网站有关系吗?附件是ID和名字,大神可以试试测试一下。
运行的时候提示如下,也没有明白是什么意思。
运行的时候提示如下,也没有明白是什么意思。
- Attachments
-
- Study.zip
- (109.23 KiB) Downloaded 233 times
Re: 按行读取名字,身份证号码,在网页粘贴查询
@WKen,谢谢指导,但是没有明白这段代码具体所指。 运行显示错误提示如下 。
我附件是对应的ID,名字,测试一下,是否可以用,谢谢
我附件是对应的ID,名字,测试一下,是否可以用,谢谢
- Attachments
-
- run error.png (23.9 KiB) Viewed 1164 times
Re: 按行读取名字,身份证号码,在网页粘贴查询
代码为v2版本,选中两个文件按F4,在网页点击第一个输入框后按F6
你发布了重复的帖子,另一个可以删除了,如果存档包含真实的个人信息请删除
你发布了重复的帖子,另一个可以删除了,如果存档包含真实的个人信息请删除
Code: Select all
#Requires AutoHotkey v2.0
F4:: ; 指定热键为F4
{
explorerSel := explorerGetSel(hwnd:="",true) ; 获得选中的项目
ids := "", names := ""
if(explorerSel != "ERROR" && explorerSel) { ; 如果在资源管理窗口并且有选中的项目
files := strSplit(explorerSel, "`n")
for file in files
{
if (!dirExist(file)) { ; 如果不是文件夹则读取文件内容
content := trim(fileRead(file), "`n")
contentArray := strSplit(content, "`n", "`r")
if IsNumber(contentArray[1]) ; 如果是数字则设置为ids,否则设置为names
ids := contentArray
else if content
names := contentArray
}
}
if ids && names
soundPlay "C:\Windows\Media\Windows Navigation Start.wav" ; 声音反馈
}
global ids, names, index := ""
}
F6::
{
global
if !ids || !names
return
length := ids.length
if (!index || index = length)
index := 1
else
index++
setKeyDelay 50
sendText trim(ids[index])
send "{tab}"
sendText trim(names[index])
if index = length
return TrayTip("已完成列表!")
}
explorerGetSel(hwnd := '', selection := True)
{
hwWindow := ''
ret := ""
Switch window := explorerGetWindow(hwnd)
{
Case '':
Return 'ERROR'
Case 'desktop':
Try hwWindow := ControlGetHwnd('SysListView321', 'ahk_class Progman')
hwWindow := hwWindow || ControlGetHwnd('SysListView321', 'A')
Loop Parse ListViewGetContent((selection ? 'Selected' : '') ' Col1', hwWindow), '`n', '`r'
{
SplitPath A_LoopField, , , &ext ; 获得拓展名
if(!ext && !DirExist(A_Desktop '\' A_LoopField)) ; 如果没拓展名并且不是文件夹,则获得快捷方式的目标,并叠加到变量ret
{
shortcut := A_Desktop '\' A_LoopField ".lnk"
if !fileExist(shortcut)
shortcut := A_DesktopCommon '\' A_LoopField ".lnk"
try FileGetShortcut shortcut, &OutTarget
catch {
msgbox("桌面项目需在资源管理器勾选此项:查看-显示-文件拓展名")
return
}
ret .= OutTarget '`n'
} else { ; 如果是文件或者是文件夹则直接叠加
ret .= A_Desktop '\' A_LoopField '`n'
}
}
Default: ; 如果不是在桌面则直接叠加
For item in selection ? window.document.SelectedItems : window.document.Folder.Items
ret .= item.path '`n'
}
Return Trim(ret, '`n')
}
; 如果是桌面则返回“desktop”
explorerGetWindow(hwnd := '')
{
class := WinGetClass(hwnd := hwnd || WinExist('A'))
Switch
{
Case WinGetProcessName(hwnd) != 'explorer.exe': Return
Case class ~= 'Progman|WorkerW': Return 'desktop'
Case class ~= '(Cabinet|Explore)WClass':
For window in ComObject('Shell.Application').Windows
Try If window.hwnd = hwnd
Return window
}
}
Who is online
Users browsing this forum: No registered users and 6 guests