Thinkai's Blog

Autohotkey|Python|php|aardio|VOIP|IT 爱好者

归属地快速离线查询SQLite_Autohotkey 7806

作者为 发表

Autohotkey


想学习autohotkey和sqlite数据库配合的使用,从ahk论坛找了相应资料,并使用QC归属地第三方2014年10月的最新归属地数据,做成了一个ahk离线查询归属地的函数。实际下载代码已经内置了Class_SQLiteDB

#NoEnv
#Include Class_SQLiteDB.ahk
;初始化连接数据库 以便反复查询
DBFileName := A_ScriptDir . "\areacode.db"
DB := new SQLiteDB
If !DB.OpenDB(DBFileName) {
   MsgBox, 16, SQLite错误, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode
   ExitApp
}

;示例
;start := A_TickCount
;MsgBox % "号码:01012345678 归属地:"get_area("01012345678") " 查询耗时:" A_TickCount - start "毫秒"
;MsgBox % get_area("95533")
;MsgBox % get_area("02340820000")
;MsgBox % c := get_area("13800138000")
InputBox, phone, 归属地查询, 请输入号码
if phone
{
   start := A_TickCount
   MsgBox % "号码:" phone " 归属地:"get_area(phone) " 查询耗时:" A_TickCount - start "毫秒"
}
ExitApp


get_area(phone){
global DB ;全局
;去国家代码
phone := RegExReplace(phone,"^\+86","")
phone := RegExReplace(phone,"^0086","")
;去长途代码
phone := RegExReplace(phone,"^0","")
;组织查询语句
SQL := "SELECT * FROM area where code='" SubStr(phone,1,7) "' or code='" SubStr(phone,1,6) "' or code='" SubStr(phone,1,5) "' or code='" SubStr(phone,1,4) "' or code='" SubStr(phone,1,3) "' or code='" SubStr(phone,1,2) "'  order by code desc LIMIT 1"
If !DB.GetTable(SQL, Result)
   MsgBox, 16, SQLite错误: 获取结果, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode
Result.Next(Row)
If (Result.HasRows) {
   Return Row[2] "-" Row[3]
}
}

归属地快速查询SQLite_Ahk.zip



来了就留个评论吧! 1个评论




友情链接:Autohotkey中文帮助Autohotkey官网Autohotkey中文网联系作者免GooglePlay APK下载

 主题设计 • skyfrit.com  Thinkai's Blog | 保留所有权利

60 queries in 4.616 seconds |