10个小技巧,源自论坛
http://hi.baidu.com/iokey/blog/item/5bc703da959aced9b6fd4833.html
1,开机(windows运行)时间:(By Gooker)
$time = DllCall("kernel32.dll","int","GetTickCount")
MsgBox(0,0,$time[0]) ;$time[0]是window运行时间的毫秒数
2,根据文件扩展名取得相关图标(By 辣椒龙)
以txt文件为例。
1.找HKEY_CLASSES_ROOT/.txt下的默认键,值是“txtfile”。
2.找HKEY_CLASSES_ROOT/txtfile/DefaultIcon下的默认值,值是“%SystemRoot%/system32/shell32.dll,-152”。
逗号前是文件名(也可以是exe文件等),后是位置(正值为顺序号,负值为索引号)。
3,设置Combo内内容为不可更改(样式)(By chasedream)
GUICtrlCreateCombo("", 32, 45, 145, 25,$SS_BLACKFRAME)
4,判断大写键盘灯亮还是灭(By Gooker)
$result = DllCall("user32.dll","Int","GetKeyState","int",20)
If @error = 1 Then
MsgBox(0,"错误","函数调用失败") ;基本上不会的 :)
Exit
Else
If $result[0] = 1 Then
MsgBox(0,"大写键盘灯状态","亮")
Else
MsgBox(0,"大写键盘灯状态","灭")
EndIf
EndIf
5,调用迅雷下载(By thesnow)
$obj=ObjCreate("ThunderAgent.Agent")
;$obj.Addtask("下载地址", "另存文件名", "保存目录","任务注释","引用地址","开始模式", "只从原始地址下载","从原始地址下载线程数") ;添加下载任务
;说明一下,开始模式只能为1(立即)/0(手动)/-1,只从原始地址下载请设置为真或者假(True/False)(1/0)
$obj.AddTask(" http://www.autoit.net.cn/autoitv3/3.2.5.5.1.exe","X.EXE","C:/TDOWNLOAD","3.2.5.5.1","dddd",1,1,10);添加下载任务
$obj.CommitTasks(1) ;提交任务.
6,查CPU温度(WMI)(By zcbenz)
Dim $temp = ""
While 1
$objWMIService = ObjGet("winmgmts://./root/WMI")
$colItems = $objWMIService.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature")
$temp = ""
For $objItem in $colItems
$temp &= "CurrentTemperature: " & ($objItem.CurrentTemperature - 2732) / 10 & "°C" & @LF
Next
ToolTip(StringTrimRight($temp,1),100,0)
$objWMIService = 0
Sleep(5000)
WEnd
7,调用放大镜的功能(By zcbenz)
Global $SRCCOPY = 0x00CC0020
Global $leave = 0
HotKeySet("{PAUSE}","leave")
SplashTextOn ( "AU3MAG", "" , 100 , 100 , 0, 0, 1 )
$MyhWnd = WinGetHandle("AU3MAG")
While Not $leave
Sleep(25)
MAG()
WEnd
Func MAG()
$MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
If @error Then Return
$DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
If Not @error Then
$xy = MouseGetPos()
If Not @error Then
$l = $xy[0]-10
$t = $xy[1]-10
DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int",0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
EndIf
DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
EndIf
DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc
Func leave()
$leave = 1
EndFunc
7,打开我的电脑,定位到C盘(By 辣椒龙)
Run(@WindowsDir & "/explorer.exe /e, /select,C:/")
8,限制input框为数字和数量限制(By dyljf & 20ysbb)
$Input1 = GUICtrlCreateInput("", 95, 205, 129, 21,$ES_NUMBER)
GUICtrlSetLimit(-1, 9)
9,强制刷新组策略和注册表 (By redapple)
xp/2003命令
gpupdate /force
2k命令
secedit /refreshpolicy machine_policy /enforce
10,获得进程路径 (By sanhen)
Func Processpath($iPID)
Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
If $aProc[0] = 0 Then Return SetError(1, 0, '')
Local $vStruct = DllStructCreate('int[1024]')
DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
Return $aReturn[3]
EndFunc