autohotkey php,[教程][网络]AutoHotkey请求PHP返回JSON字符串

最近在做的AutoHotkey中需要访问主机数据库,所以去学习了PHP、SQL、JSON再此分享出来。

本文中所学来自万维网,首先在服务器创建PHP文件,autohotkey.php与ahk文件下方给出代码。

[video width=”1920″ height=”1080″ mp4=”http://yun.autoahk.com/autohotkey/video/coupling-interaction/php/ahk-php-sql-json.mp4″][/video]

header("Content-type:text/html;charset=utf-8");

$con = mysql_connect("localhost:3306","数据库账号","数据库密码"); //链接数据库

mysql_select_db("数据库名",$con); //需要操作的数据库名

mysql_query('SET NAMES UTF8'); //设置数据库编码

$result = mysql_query("SELECT * FROM lib ORDER BY heat DESC",$con); //执行数据库查询命令

$results = array(); //将查询结果转换为数组

while ($row = mysql_fetch_assoc($result))

$results[] = $row;

echo urldecode(json_encode($results,JSON_UNESCAPED_UNICODE)); //输出JSON字符串

mysql_close($con); //关闭数据库连接

?>

#Persistent

#SingleInstance force

#Include %A_ScriptDir%\JSON.ahk

Gui,Add,ListView,w600,脚本名|描述|标签|热度

Gui,Show

get:=JSON.load(Update())

for k,v in get

LV_Add("" , get[A_Index].name,get[A_Index].describe,get[A_Index].label,get[A_Index].heat)

LV_ModifyCol()

return

Update(){

static req := ComObjCreate("Msxml2.XMLHTTP")

req.open("GET","http://zozhu.com/autohotkey.php",false)

req.Send()

return req.responseText

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值