Thinkai's Blog

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

正在浏览分类 Autohotkey

总共找到 128 篇

#NoTrayIcon ;不显示图标
IfNotExist, 内外网双用路由.cmd ;检测文件是否存在
	{
	SplashTextOn, 200, 40, 提示, 获取网络信息中! ;悬浮窗口
	RunWait, %ComSpec% /c ipconfig /all >%A_Temp%\ip.tmp, , Hide ;获取ipconfig
	file = %A_Temp%\ip.tmp ;定义路径
	index = 8 ;定义FileReadLine起始行
	id = 0
	ip := Object() ;初始化数组
	gateway := Object()
	name := Object()
	Loop
	{
	index += 1
	FileReadLine, line, %file%, %index% ;循环读取每一行到line变量
	if errorlevel
		Break
	if line <>   ;不为空
		{
		line = `n%line%`n  ;加上首位界限
		head := RegExMatch(line, "\n[^\s].*\s.*:\n") ;正则表达式检测适配器标题
		if head = 1 ;如果是
			{
			id += 1 ;网卡id+1
			name[id] := RegExReplace(line, "\n([^\s].*):\n", "$1") ;正则替换获取适配器名称并添加到数组
			}
		Else
			{
			testip := RegExMatch(line, "\n.*(IPv4 地址|IP Address).*:\s\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.*\n") ;匹配有地址的ip
			testip2 := RegExMatch(line, "\n.*(IPv4 地址|IP Address).*:.*\n") ;匹配无地址的ip 地址为空的情况下
			testip3 = %testip%%testip2% ;连接两个变量
			if testip3 = 11
				ip[id] := RegExReplace(line, "\n.*(IPv4 地址|IP Address).*:\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*\n", "$2") ;获取ip并添加到数组
			if testip3 = 01
				ip[id] =
			testgw := RegExMatch(line, "\n.*(默认网关|Default Gateway).*:\s\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.*\n")
			testgw2 := RegExMatch(line, "\n.*(默认网关|Default Gateway).*:.*\n")
			testgw3 = %testgw%%testgw2%
			if testgw3 = 11
				gateway[id] := RegExReplace(line, "\n.*(默认网关|Default Gateway).*:\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*\n", "$2")
			if testip3 = 01
				gateway[id] =
			}
		}
	}
	SplashTextOff ;关闭悬浮窗口
	;创建界面
	gui, add, text, x0 y0 w720 h20, 请选择对应的网络适配器并分别设为内网、外网
	gui, add, text, x0 y20 w60 h20, 内网:
	gui, add, text, x60 y20 w300 h20 vnei,
	gui, add, text, x360 y20 w60 h20, 外网:
	gui, add, text, x420 y20 w300 h20 vwai,
	gui, add, button, x0 y40 w360 h20 gsetnei, 设为内网
	gui, add, button, x360 y40 w360 h20 gsetwai, 设为外网
	gui, add, ListView, x0 y60 w720 h100 vlist, ID|网卡名称|IP地址|默认网关
	gui, add, text, x0 y160 w720 h20, 静态路由设置(可复制到CMD直接执行或另存为.bat批处理 当然,下次打开程序会自动执行下面的路由的)
	gui, add, edit, x0 y180 w720 h50 vroute, route delete 0.0.0.0
	gui, add, button, x0 y230 w240 h20 gsubmit, 提交
	gui, add, button, x240 y230 w240 h20 gsexec, 提交并立即执行
	gui, add, button, x480 y230 w240 h20 ghelp, 帮助
	gui, show, , 内外网双用初始化设置 Powered by Thinkai
	;添加网卡信息到列表
	loop
	{
	if A_Index > %id% ;到头退出
		break
	n := name[A_Index] ;赋值临时名称
	i := ip[A_Index] ;赋值临时ip
	g := gateway[A_Index] ;赋值临时网关
	if i <>
		LV_Add("", A_Index, n, i, g) ;添加ip不为空的网卡信息 ""为图标
	}
	LV_ModifyCol() ;自动调整列宽
	}
Else
	{
	MsgBox, 4100, 询问, 请问是否继续设定好的信息执行内外网双用?, 5 ;5秒超时
	IfMsgBox, Yes ;选是
		goto, exec ;跳到exec标签
	IfMsgBox, Timeout ;超时
		goto, exec
	IfMsgBox, no ;选否
		{
		FileDelete, 内外网双用路由.cmd ;删除
		Reload ;重载
		}
	}
Return

setnei: ;设置内网
;获取选中行信息
FocusedRowNumber := LV_GetNext(0, "F")
if not FocusedRowNumber ;没有焦点
	{
	MsgBox, 4144, 提示, 您未选中任何网卡!
	Return
	}
LV_GetText(idx, FocusedRowNumber, 1) ;获取id
namen := name[idx] ;由id从数组读取值并赋值
ipn := ip[idx]
gwn := gateway[idx]
StringSplit, var, ipn, . ;用“.”分割ip
if gwn =
	{
	prompt = 该适配器没有默认网关,请手动输入!例如%var1%.%var2%.%var3%.1 ;变量化提示
	goto, setgwn
	}
if gwn = %gww%
	{
	prompt =  你的内外网为同一个网络适配器,请手动输入内网的网关!`n例如%var1%.%var2%.%var3%.1
	goto, setgwn
	}
GuiControl, , nei, %namen%
GuiControlGet, route ;获取路由编辑控件信息
StringSplit, nn, ipn, .
ipnn = %nn1%.0.0.0 ;内网路由
GuiControl, , route, %route%`nroute add %ipnn% mask 255.0.0.0 %gwn% ;追加路由到窗口
Return

setgwn:
InputBox, gwn, 设置内网网关, %prompt%, , 600, 200
testgwn := RegExMatch(gwn, "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") ;检查ip格式
if testgwn = 0
	{
	prompt = 该适配器没有默认网关,请手动输入!例如%var1%.%var2%.%var3%.1
	MsgBox, 64, 提示, 网关格式错误!
	goto, setgwn
	}
if gwn = %gww%
	{
	prompt =  你的内外网为同一个网络适配器,请手动输入内网的网关!`n例如%var1%.%var2%.%var3%.1
	MsgBox, 64, 提示, 网关与外网网关相同,请重新填写!
	goto, setgwn
	}
GuiControl, , nei, %namen%
GuiControlGet, route
StringSplit, nn, ipn, .
ipnn = %nn1%.0.0.0
GuiControl, , route,  %route%`nroute add %ipnn% mask 255.0.0.0 %gwn%
Return

setwai:
FocusedRowNumber := LV_GetNext(0, "F")
if not FocusedRowNumber
	{
	MsgBox, 4144, 提示, 您未选中任何网卡!
	Return
	}
LV_GetText(idx, FocusedRowNumber, 1)
namew := name[idx]
ipw := ip[idx]
gww := gateway[idx]
StringSplit, var, ipw, .
if gww =
	{
	prompt = 该适配器没有默认网关,请手动输入!例如%var1%.%var2%.%var3%.1
	goto, setgww
	}
if gww = %gwn%
	{
	prompt =  你的内外网为同一个网络适配器,请手动输入外网的网关!`n例如%var1%.%var2%.%var3%.1
	goto, setgww
	}
GuiControl, , wai, %namew%
GuiControlGet, route
GuiControl, , route, %route%`nroute add 0.0.0.0 mask 0.0.0.0 %gww%
Return

setgww:
InputBox, gww, 设置外网网关, %prompt%, , 600, 200
testgww := RegExMatch(gww, "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")
if testgww = 0
	{
	prompt = 该适配器没有默认网关,请手动输入!例如%var1%.%var2%.%var3%.1
	MsgBox, 64, 提示, 网关格式错误!
	goto, setgwn
	}
if gwn = %gww%
	{
	prompt =  你的内外网为同一个网络适配器,请手动输入外网的网关!`n例如%var1%.%var2%.%var3%.1
	MsgBox, 64, 提示, 网关与内网网关相同,请重新填写!
	goto, setgww
	}
GuiControl, , wai, %namew%
GuiControlGet, route
GuiControl, , route, %route%`nroute add 0.0.0.0 mask 0.0.0.0 %gww%
Return


GuiClose:
ExitApp

exec:
RunWait, 内外网双用路由.cmd, ,Hide
ExitApp

submit:
GuiControlGet, route
if gww =
	{
	MsgBox, 64, 提示, 没有设置外网信息!
	Return
	}
if gwn =
	{
	MsgBox, 64, 提示, 没有设置内网信息!
	Return
	}
FileDelete, 内外网双用路由.cmd
FileAppend, %route%, 内外网双用路由.cmd
MsgBox, 64, 提示, 已经保存并生成“内外网双用路由.cmd”
if exec = 1
	RunWait, 内外网双用路由.cmd, ,Hide
exec = 0
Return

sexec:
exec = 1
goto, exec
Return

help:
MsgBox, 64, 帮助, 程序会帮你生成内外网双用的批处理,并在下次打开软件的时候提示你是否按设置好的信息执行。`n网关就相当于出口,内网和外网的出口是不一样的,有宽带连接的需要设置宽带连接的网关为外网网关。`n你也可以添加自定义路由在路由设置里面。
Return

内外网双用路由.zip


定时同步增量备份文件夹 Autohotkey 8576

作者为 发表

Autohotkey

;定时备份
old_hour = %A_Hour%
;源路径
source = D:\1
;目标路径
dest = E:\1
Loop
{
new_hour = %A_Hour% ;定义新旧小时
if new_hour <> %old_hour% ;如果不等
	{
	RunWait,%ComSpec% /c dir `"%source%`" /A-D /b /s >files.tmp,,Hide ;CMD dir命令获取文件列表
	RunWait,%ComSpec% /c dir `"%source%`" /AD /b /s >folders.tmp,,Hide ;CMD dir命令获取文件夹列表
	Loop ;创建不存在的文件夹
	{
	FileReadLine,tmpfolder,folders.tmp,%A_Index%
	If ErrorLevel
		Break
	if tmpfolder <>
		{
		StringReplace,tmpdestfolder,tmpfolder,%source%,%dest% ;替换路径
		FileCreateDir,%tmpdestfolder% ;创建文件夹
		}
	}
	Loop ;复制不存在的或更新的文件
	{
	FileReadLine,tmpfile,files.tmp,%A_Index%
	If ErrorLevel
		Break
	if tmpfile <>
		{
		StringReplace,tmpdestfile,tmpfile,%source%,%dest% ;替换路径
		IfNotExist,%tmpdestfile% ;不存在
			FileCopy,%tmpfile%,%tmpdestfile%,1
		Else
			{
			FileGetTime,sourcetime,%tmpfile% ;获取源文件修改时间
			FileGetTime,desttime,%tmpdestfile% ;获取目标文件修改时间
			if sourcetime > %desttime% ;如果源文件更新
				FileCopy,%tmpfile%,%tmpdestfile%,1
			}
		}
	}
	}
Sleep,60000 ;等待1分钟
}


号码前面批量加零 Autohotkey 5736

作者为 发表

Autohotkey

Gui, add, edit, x0 y0 w200 h600 vcontent,
gui, add, button, x0 y600 w200 h20 ggo, 号码前面加零
gui, show, , 加零
Return

go:
GuiControlGet, content
content = `n%content%
StringReplace, content, content, `n, `n0, All
StringReplace, content, content, `n, ,
StringTrimRight, content, content, 1
GuiControl, , content, %content%
Return


GuiClose:
ExitApp


加载未知ini文件到ahk Autohotkey 8890

作者为 发表

Autohotkey

FileSelectFile, file, , , 请选择ini文件, ini配置文件(*.ini) ;选择文件
if file=
	{
	MsgBox, 0, 错误, 您为选择任何文件
	Reload
	}
sections =
FileRead, filecontent, %file% ;加载文件到变量
StringSplit, line, filecontent, `n, , ;用函数分割变量为数组
Loop ;循环
{
if A_Index > %line0%
	Break
content = % line%A_Index% ;赋值当前行
StringReplace, content, content, `r, , All ;替换特殊字符
FSection := RegExMatch(content, "\[.*\]") ;正则表达式匹配section
if FSection = 1 ;如果找到
	{
	TSection := RegExReplace(content, "\[(.*)\]", "$1") ;正则替换并赋值临时section $为向后引用
	sections = %sections%%TSection%| ;用|串接所有section 方便使用列出
	%TSection%keys =
	}
Else
	{
	FKey := RegExMatch(content, ".*=.*") ;正则表达式匹配key
	if FKey = 1
		{
		TKey := RegExReplace(content, "(.*)=.*", "$1") ;正则替换并赋值临时key
		StringReplace, TKey, TKey, ., _, All
		TKey2=%Tkey%|
		%TSection%keys = % %TSection%keys TKey2 ;;用|串接当前section下所有key 方便使用列出
		TValue := RegExReplace(content, ".*=(.*)", "$1") ;正则替换并赋值临时value
		%TSection%_%TKey%=%TValue%
		}
	}
}
ListVars ;调试情况 列出所有变量
Pause


调试网页源码URLDownloadToFile AutoHotKey 8581

作者为 发表

Autohotkey

因不满浏览器调试php代码的速度,特写了一个简单的AHK调试html源码的小工具,建议下载时间不得超过1分钟。

gui, add, edit, x0 y0 w400 h20 vaddress,
gui, add, button, x400 y0 w60 h20 vbm gbm, GB2312
gui, add, button, x460 y0 w40 h20 gok Default, 加载
gui, add, edit, x0 y20 w500 h200 vshow,
gui, show, , URLDownload To File
bm = GB2312
Return


bm:
if bm = GB2312
	{
	bm = UTF-8
	GuiControl, , bm, %bm%
	goto, ok
	}
Else
	{
	bm = GB2312
	GuiControl, , bm, %bm%
	goto, ok
	}


ok:
GuiControlGet, address
if bm = GB2312
	FileEncoding,
if bm = UTF-8
	FileEncoding, UTF-8
URLDownloadToFile, %address%, %A_Temp%\tp.tmp
FileRead, a, %A_Temp%\tp.tmp
;StringReplace, a, a, `n, \n`n, All
GuiControl, , show, %a%`n______________%A_Now%_____________
Return

GuiClose:
ExitApp


CoordMode, Mouse, Screen ;强制相对全屏

$LButton:: ;加$表示不执行自身 加~表示不阻碍原功能
MouseGetPos, x, y ;保存当前坐标
Sleep, 200 ;单击检测延时
GetKeyState, state, lbutton, P ;检测右键是否释放
if state = U
	{
	IfWinActive, ahk_class Chrome_WidgetWin_100 ;匹配窗口ahk_class
		Send, ^{lbutton}
	Else
		MouseClick, left, %x%, %y%
	}
Else
	{
	MouseClick, left, %x%, %y%, , , D ;拖拽
	KeyWait, lbutton ;等待左键释放
	MouseClick, left, 0, 0, , , U, R ;抬起左键
	}

Return


按键映射【按住】Autohotkey 10735

作者为 发表

Autohotkey

f::
Send, {LButton Down}
Loop
{
GetKeyState, state, f, P
;循环获取f键的按下状态,如果抬起,释放左键 中断循环
if state = U
    {
    Send, {LButton Up}
    Break
    }
}
Return

f键按下,不发送f,按住鼠标左键知道松开f。

QQ影音视频批量获取剧情缩略图 Autohotkey 11522

作者为 发表

Autohotkey

QQ影音5.x新版代码: 

;ControlSend, ahk_parent, !s, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
;ExitApp
#Persistent
#SingleInstance
SetTitleMatchMode, 2
;配置信息
;播放器路径
IfExist, D:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
    QQplayer_path = D:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
IfExist, c:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
    QQplayer_path = c:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
IfExist, D:\Program Files\Tencent\QQPlayer\qqplayer.exe
    QQplayer_path = D:\Program Files\Tencent\QQPlayer\qqplayer.exe
IfExist, c:\Program Files\Tencent\QQPlayer\qqplayer.exe
    QQplayer_path = D:\Program Files\Tencent\QQPlayer\qqplayer.exe
if QQplayer_path =
    {
    FileSelectFile, QQplayer_path, , qqplayer.exe, 请指定QQ影音主程序所在, QQPlyer.exe(*.exe)
    }
;QQ影音5.x更新,连拍张数再播放器设置里面,图片保存在个人图片文件夹下QQplayerPic文件夹内
filter = .rm,.rmvb,.mp4,.wmv,.avi,.mkv,.flv,.f4v,.ts,.3gp,.dat,.vob,.wm,.asf,.rp,.m1v,.m2p,.m2t,.m2ts,.m2v,.mp2v,.mpeg,.tp,.m4v,.m2b,.m4p,.mpeg4,.mov

FileSelectFolder, folder, , 2, 请选择一个批量剧情连拍的视频文件夹路径
if folder <>
    {
    Loop, %folder%\*.*, 0, 0
    {
		if A_LoopFileName Contains %filter%
        {
			run, `"%QQplayer_path%`" `"%A_LoopFileFullPath%`"
			WinWait, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
			WinGetTitle, oldtitle, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
			ToolTip, Found
			Loop, 10
			{
				sleep, 100
				WinGetTitle, Tt, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
				if Tt <> %oldtitle%
					Break
			}
			Sleep, 1000
			ToolTip, Ready
			ControlSend, ahk_parent, {Space}, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
			ToolTip, Pause
			Sleep, 1000
			;ControlSend, ahk_parent, !s, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
			ControlSend, ahk_parent, {Alt Down}s{Alt Up}, ahk_class TXGuiFoundation ahk_exe QQPlayer.exe
			ToolTip, MuiltiShot
			Sleep, 30000 ;等待30秒
			Pause
        }
    }
    MsgBox, 64, 提示, 剧情连拍批处理完毕!
    }
Return

 QQ影音老版本代码:

#Persistent
#SingleInstance
SetTitleMatchMode, 2
;配置信息
;播放器路径
IfExist, D:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
	QQplayer_path = D:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
IfExist, c:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
	QQplayer_path = c:\Program Files (x86)\Tencent\QQPlayer\qqplayer.exe
IfExist, D:\Program Files\Tencent\QQPlayer\qqplayer.exe
	QQplayer_path = D:\Program Files\Tencent\QQPlayer\qqplayer.exe
IfExist, c:\Program Files\Tencent\QQPlayer\qqplayer.exe
	QQplayer_path = D:\Program Files\Tencent\QQPlayer\qqplayer.exe
if QQplayer_path =
	{
	FileSelectFile, QQplayer_path, , qqplayer.exe, 请指定QQ影音主程序所在, QQPlyer.exe(*.exe)
	}
;保存路径
FileSelectFolder, SavePath, , 1, 选择截图保存的目录
;保存文件尾巴
InputBox, Filetail, 保存文件尾巴,请输入,留空不添加。
;筛选格式
filter = .rm,.rmvb,.mp4,.wmv,.avi,.mkv,.flv,.f4v,.ts,.3gp,.dat,.vob,.wm,.asf,.rp,.m1v,.m2p,.m2t,.m2ts,.m2v,.mp2v,.mpeg,.tp,.m4v,.m2b,.m4p,.mpeg4,.mov
;几格X
InputBox, a, 输入,横向几个预览
InputBox, b, 输入,纵向几个预览
oldtitle =
IfNotExist, %SavePath%
FileCreateDir, %SavePath%
;初始化完毕
FileSelectFolder, folder, , 2, 请选择一个批量剧情连拍的视频文件夹路径
if folder <>
	{
	run, %ComSpec% /c dir `"%folder%`" /A-D /b >`"%A_ScriptDir%\list.txt`", Hide
	Process, WaitClose, cmd.exe
	Loop
	{
	FileReadLine, line, %A_ScriptDir%\list.txt, %A_Index%
	if errorlevel
		Break
	if line Contains %filter%
		{
		run, `"%QQplayer_path%`" `"%folder%\%line%`"
		WinWait, QQ影音
		WinActivate, ahk_class QQPlayer Window
		WinGetActiveTitle, oldtitle
		Loop
		{
		sleep, 100
		WinGetActiveTitle, Tt
		if Tt <> %oldtitle%
			Break
		}
		Loop
		{
		WinActivate, ahk_class QQPlayer Window
		WinActivate, QQ影音
		WinGetActiveTitle, Title
		Send, !s
		WinWait, 另存为, , 1
		If errorlevel <> 1
			Break
		}
		WinActivate, #32770
		StringReplace, Title, Title, [高清加速开启],
		StringReplace, Title, Title, %A_Space%- QQ影音
		ControlSetText, Edit1, %SavePath%, 另存为
		ControlSend, Button2, {lbutton}, 另存为
		send, {enter}
		ControlSetText, Edit1, %title%_%Filetail%, 另存为
		ControlSetText, Edit2, %a%, 另存为
		ControlSetText, Edit3, %b%, 另存为
		WinActivate, #32770
		Clipboard =
		ControlSend, Button2, {lbutton}, 另存为
		send, {enter}
		IfWinExist, 确认另存为
			{
			WinActivate, 确认另存为
			send, y
			}
		ClipWait, , 1
		}
	}
	MsgBox, 36, 提示, 剧情连拍批处理完毕,是否打图片保存开文件夹?
	IfMsgBox, Yes
	run, %SavePath%
	}
Return


简单的批量键鼠操作下载图片脚本 Autohotkey 4807

作者为 发表

Autohotkey

z::
ex = 0
Loop
{
if ex = 1
	Break
MouseGetPos, x, y
do:
MouseClick, Right, %x%, %y%,
sleep, 250
Send, s
WinWaitActive, ahk_class #32770, , 1
if Errorlevel
	goto, do
Send, %A_Now%
Send, {Enter}
sleep, 100
Send, {Left}
}
Return

x::
ex = 1
Return

z开始 x中断

批量结束包含关键词程序名的进程 Autohotkey 4738

作者为 发表

Autohotkey

RunWait, %ComSpec% /c tasklist >a.txt, , Hide
InputBox, key, 程序名关键词批量结束, 请输入程序名关键词!,
StringLen, len, key
if len < 2
	{
	MsgBox, 16, 警告, 关键词小于两位,可能会导致系统崩溃,请重试!
	Reload
	}
Loop
{
FileReadLine, line, a.txt, %A_Index%
if errorlevel
	Break
IfInString, line, .exe
	{
	StringSplit, var, line, .,
	IfInString, var1, %key%
		{
		runwait, %ComSpec% /c taskkill /f /IM %var1%.exe, , Hide
		}
	}
}



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

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

50 queries in 1.344 seconds |