html tool

显示标签为“ahk”的博文。显示所有博文
显示标签为“ahk”的博文。显示所有博文

2019年9月3日星期二

ahk 读取传入参数


参考:http://ahkcn.sourceforge.net/docs/Scripts.htm#cmd

如果传递给脚本的参数数目不确定 (可能由于用户拖放一组文件到脚本上), 可以使用下面的示例逐个提取这些参数:
Loop, %0%  ; 对每个参数进行循环:
{
    param := %A_Index%  ; 取得名称为 A_Index 的值的变量中的内容.
    MsgBox, 4,, Parameter number %A_Index% is %param%.  Continue?
    IfMsgBox, No
        break
}

ahk2exe编译32/64位exe 方式


参考:https://www.autohotkey.com/v2/
download:
Compiling scripts requires Ahk2Exe.exe, which can be copied from an AutoHotkey v1 installation or AutoHotkey.zip(https://autohotkey.com/download/ahk.zip).

解压后:
cd Compiler/
Ahk2Exe.exe /in ${inputfile} /out ${outfile} /bin Unicode 32-bit.bin   #编辑为32位exe
Ahk2Exe.exe /in ${inputfile} /out ${outfile} /bin Unicode 64-bit.bin   #编辑为64位exe

2018年12月17日星期一

AHK读取文件内容去掉换行符



FileRead,num,setnum.txt

StringSplit,Count,num, "a" ;这里使用a分割,原文要求最后加a
MsgBox,%Count1%
Loop % Count1 - 1
{
    RunWaitCmd(dir)
}

AHK loop



https://ahkcn.github.io/docs/commands/Loop.htm

重复执行一系列命令:可以指定表示重复次数的数字或直到遇到 break
Loop [, Count]

参数

Count
执行循环体 (重复) 的次数. 如果省略, Loop 会无期限继续, 直到遇到 break 或 return.
如果 Count 是一个变量引用例如 %ItemCount%, 每当此变量为空或包含小于 1 的数字时, 循环会被完全跳过.
由于必须支持 文件模式循环Count 不可以为表达式. 不过, 和所有的非表达式参数一样, 通过在表达式之前加上 % 和空格可以强制使用它. 例如:Loop % Count + 1。此时, 表达式仅在循环开始之前被求值一次. [popexizhi: 这里的 % 和 空格非常重要,否则无法使用!!!]

备注

AHK cmd run


https://wapiknow.baidu.com/question/547051459.html?entrytime=1545104073339

SetTitleMatchMode 2
dir=c:\WINDOWS
run,cmd
WinWait, ahk_class ConsoleWindowClass,
IfWinNotActive, ahk_class ConsoleWindowClass, , WinActivate, ahk_class ConsoleWindowClass,
WinWaitActive, ahk_class ConsoleWindowClass,
ControlSend, , cd /d %dir% {Enter}, cmd.exe ; 直接发送到命令提示符窗口.要配合SetTitleMatchMode RegEx或SetTitleMatchMode 2

2018年12月10日星期一

AHK write file


https://www.jianshu.com/p/eb0a6fc8d0c7
FileAppend [, Text, Filename, Encoding]

AHK run python


https://superuser.com/questions/336004/how-to-run-python-script-in-ahk


Run python e:/copytimeinbuffer.py

2015年5月6日星期三

selenium swf 处理 上传文件

问题:
上传文件使用的是flash按钮


参考:http://osdir.com/ml/selenium-users/2012-12/msg00657.html
You'd have to go with external tool like AutoIt or Sikuli.
[popexizhi]
看来selenium没有提供好的flash处理接口,上面提到的AutoIt我go了一下
参考:http://blog.csdn.net/kittyboy0001/article/details/25557147
是个“用来在Windows GUI(用户界面)中进行自动操作”,
ok,只能用这样的工具处理,我写了AHK的脚本,脚本如下:

#IfWinActive,打开 ;ahk_class #32770 ;切换到弹出的选择文件窗口
    WinActivate,打开 ;将窗口前置
    Send,c:\logo1.jpg ;输入文件地址
    Send,!+o ;打开文件操作
#IfWinActive

编译为exe进程在其他脚本中直接用了。

AHK相关资料:
http://blog.csdn.net/foxbryant/article/details/7605714
http://blog.csdn.net/foxbryant/article/details/7628392
要处理窗口的spy信息
>>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
打开
ahk_class #32770

>>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<<
On Screen: 804, 643  (less often used)
In Active Window: 804, 599

>>>>>>>>>( Now Under Mouse Cursor )<<<<<<<<

Color: 0x000000  (Blue=00 Green=00 Red=00)

>>>>>>>>>>( Active Window Position )<<<<<<<<<<
left: 0     top: 44     width: 640     height: 512

>>>>>>>>>>>( Status Bar Text )<<<<<<<<<<

>>>>>>>>>>>( Visible Window Text )<<<<<<<<<<<
命名空间树控件
树视图
ShellView
文件名(&N):
文件类型(&T):
打开(&O)
取消
地址: 库\图片

>>>>>>>>>>>( Hidden Window Text )<<<<<<<<<<<
命名空间树控件
Shell Preview Extension Host
帮助(&H)

>>>>( TitleMatchMode=slow Visible Text )<<<<
*.jpg;*.jpeg;*.bmp;*.png;*.gif (*.jpg;*.jpeg;*.bmp;*.png;*.gif)

>>>>( TitleMatchMode=slow Hidden Text )<<<<



2014年8月8日星期五

SampleRobot的守卫进程实现--AHK版


为gTalk的SampleRobot写的守卫进程,用AHK写的,测试时突然想到,这样就真能用在windiws了,还是在改一改python版为liunx下也可以用吧,整个工程已经提交到google code(https://code.google.com/p/xizhi/)中了。下文是源码
-----------------------------------------------------AHK script-----------------------
run,python sampleRobot.py, , ,NewPID
;run的第二个参数为python sampleRobot.py 为以python运行这个脚本;但如果为python,sampleRobot.py,这个文件则是The working directory for the launched item了
;run的last参数是OutputVarPID这样可以很好的监控进程运行环境了

while True
{
 process,Exist,%NewPID%
 ;MsgBox The PID is,%NewPID%
 ;MsgBox %ErrorLevel%
 if ErrorLevel>0
  robot_num=1
 else
  run,python sampleRobot.py, , ,NewPID 
}
;:) ok了,是while的多语句要使用{},好吧自己的尝试问题:)

2012年6月18日星期一

ahk 的组合键问题


[?]
当前版本使用“Ctrl + Alt + Shift + Win + Q”(这个快捷键真牛×。- -b)来启动 QQ 的话,可以这样写:^!+#q::run D:\qq\qq.exe


这个组合键不起作用,why?

[ok]
调整顺序就ok了,vim中不知why吧放在首位的^当作注释来处理了

顺便了解了一下:
AHK中
使用 #CommentFlag 可以把默认的注释符 (分号) 改为其他字符或字符串
eg:

#CommentFlag //  ; 改为 C++ 注释风格.

  

[?]
vim中不知why吧放在首位的^当作注释来处理了 ,是做注释处理了吗?看到的颜色是绿色,应该也不是注释啊?其他的非#放到第一 都是绿色的,这个是什么原因呢?