分享我的主启动脚本

许多实用脚本和封装函数, 可以让您编写脚本更加便捷高效

Moderators: tmplinshi, arcticir

oaker
Posts: 5
Joined: 01 Aug 2014, 21:02

分享我的主启动脚本

03 Aug 2014, 03:28

#前言:

在使用Windows十年中,试用过太多快速启动工具、窗口控制软件。不断探索,终而在实践中发现,Autohotkey才能以尽可能低运行成本做到随时待命、响应,根据场景需求,随时增删改进。本文将以代码加简短评注的方式,介绍本人历经N年收集、沉淀在主启动脚本(autohotkey.ini)中的代码。其中大部分简短实用,开机必备,有从中外论坛搜刮来,有自己改写。还有不少脚本需单独运行,而不宜放在autohotkey.ini中,需另行介绍。(本文不解决Autohotkey基础知识问题)

# 正文:

Code: Select all

; Win---># ; Shift--->+ ; Ctrl--->^ ; Alt--->!
; ::/d::此格式加回车执行
防遗忘的小知识点

Code: Select all

#SingleInstance force
;SendMode Input
第一行挺重要,只允许运行一个本脚本的实例

Code: Select all

#include %A_scriptDir%\myahk\app_launch.ahk
#include %A_scriptDir%\myahk\winhide.ahk
同时启动的脚本,但不会(没必要)在托盘显示。注意路经设置,便于迁移或在多系统中正常调用。

app_launch.ahk 是真正的重度使用脚本,需另开文介绍。

Code: Select all

;---- 本脚本开关、快速编辑和重启 -------------------

RCtrl & End:: 
    suspend ; AutoHotKey 挂起/激活双向开关 
    traytip,AutoHotKey,热键状态已切换
    ;msgbox,64,激活 VS 挂起,^-^ AutoHotKey 挂起/激活双向开关 ^-^,0.2 
return
!^e::
Edit   ; Edit the script by Alt+Ctrl+E.
return
!^r::
Reload  ; Reload the script by Alt+Ctrl+R.
TrayTip,AutoHotKey, 脚本已重启
return
调试时经常用到

Code: Select all

;---- 按 Win - F10,粘贴密码 -------------------

#F10::
    PSD =你的密码
    clipboard = %PSD%
return
快速输入密码,实际工作中天天用(安全性低)

Code: Select all

;---- 按下 Ctrl - Shift - C, 选中文本并Google之 -------------------

^+c::
{
Send, ^c
Sleep 50
Run, http://www.google.com/search?q=%clipboard%
Return
}
使用率低

Code: Select all

;---- 按 Win - F11 ,使当前活动窗口的标题行,在隐藏/显示状态之间切换 ----------------

#f11::
WinSet, Style, ^0xC00000, A
WinSet, Style, ^0×40000, A
return
使用率低

Code: Select all

;----- 按 Win - F9,用IrfanView截图 ------------------

;The capture=0 could be 1 (current monitor), 2 (foreground window), 3 (client area), 4 (rectangle section), or 5 (launch in capture mode).
#f9:: Run,"D:\Program Files\IrfanView\i_view32.exe" /capture=4 /convert="d:\capture\capture_$U(%d%m%Y_%H%M%S).webp"
要注意capture的参数和截图格式

Code: Select all

;-----  按 Win - B , 弹出光驱 ---------------

#b::
    Drive, Eject
    If A_TimeSinceThisHotkey < 1000
        Drive, Eject, , 1
    Return 
使用率低

Code: Select all

;---- 按 Win - S ,复制文字用记事本查看 ----------------

;#s::
Send ^c
IfWinExist ahk_class Notepad2U
{
    WinActivate
}
else
{
    Run Notepad
    WinWait ahk_class Notepad2U
    WinActivate
}
Send ^a^v   ;^a是为了替换可能在已打开的记事本中存在的文字,如果你只想跟随复制,那么去掉它即可
return
记得是从中文论坛抄来的

Code: Select all

;---- UI For Run --------------
   
RWin::
IfWinNotExist, 运行
{ 
send #r    ;SendPlay有些键不能发送,如RWin
WinWait, 运行
WinSet, Transparent,190
WinSet, Style, -0xC00000    ;WS_CAPTION, 去掉title bar
WinSet, Region,68-74 W320 H22 R11-11
return
}
else
Winkill
return
有人喜欢用 Win - R - 输入别名 - Enter 的方式运行程序,在这个过程中“运行”界面其实不是必要的。这段代码只保留显示“运行”的输入框,并调整了透明度,实现在需运行别的程序时、尽量不遮挡当前窗口内容的功能。实际上挺酷,但没咋用。对于不同的显示器,需要调整坐标。

实际上,可以控制任何窗口显示哪部分内容。

Code: Select all

;----- 置顶与否 ------------------

;^Up::WinSet,TopMost,,A ;按热键Ctrl+↑来切换激活的窗口的置顶与否的状态
return
使用率低,也因为这个快捷键易引起冲突
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: 分享我的主启动脚本

13 Aug 2014, 08:29

很赞,小口,小口,很有胃口,占楼写笔记..
我为人人,人人为己?

Return to “脚本函数”

Who is online

Users browsing this forum: No registered users and 44 guests