我正在AutoHotKey中开发一个程序,该程序自动化了将.FTM (FamiTracker)文件大规模转换为.WAV的过程。问题是,我希望它增加“Send{down}”语句+每个循环1(在文件夹中选择下一首歌曲)的值。
编辑我更新了代码。增量语句起作用,我只需要找到一种方法来使整个程序循环尽可能多次地转换文件夹中的所有文件(添加+1来发送{down}每个循环)。现在的问题是它没有循环整个程序。任何帮助都是非常感谢的!
下面是该程序在启动FamiTracker音乐应用程序后的处理方式的摘录:
Sleep, 800 ; I want the program to loop back to here when it reaches the last line
click 20,30 ; clicks "file"
Sleep, 500
Send {down 2} ; clicks "open"
send {enter}
Sleep, 1200
click 211,128 ; clicks first filename in folder
Sleep, 1200
send {enter}
Sleep, 1000
click 20,30 ; clicks "file"
send {down 6}
send {enter} ; clicks "create wav"
Sleep, 1000
click 157,57 ; increase playcount to 2
Sleep, 500
send {enter}
Sleep, 1000
send {enter}
Sleep, 2500
send {enter}
click 20,30 ; clicks "file"
Sleep, 500
Send {down 2} ; clicks "open"
send {enter}
Sleep, 1200
click 211,128 ; clicks first filename in folder
Sleep, 1000
Jmp:=1
Loop
{
Send, {Down %Jmp%}
Jmp+=1
return
}
sleep, 100
send {enter}
Sleep, 1000
click 20,30 ; clicks "file"
send {down 6}
send {enter} ; clicks "create wav"
Sleep, 1000
click 157,57 ; increase playcount to 2
Sleep, 500
send {enter}
Sleep, 1000
send {enter}
Sleep, 2500
send {enter}
Sleep, 1000 ; final line of code, want it to loop back to line 1 to repeat process till all files in folder are converted我被困了一段时间了,有什么想法吗?实际上,我希望光标在程序的每个循环之后移动到下一首歌曲上。当程序第一次运行时,它会加载song1,然后在song1完成后,它会重复这个过程,但是继续单击song2,等等。
非常感谢
发布于 2013-02-21 06:14:01
如果你想跳过一个循环中的多一个文件,你可以使用这样的东西。您应该添加一个测试,将最后一个文件名与当前文件名进行比较,以便在列表末尾退出这个循环。
Jmp:=1
Loop
{
Send, {Down %Jmp%}
Jmp+=1
}
Return我已经更新了您的代码,以展示如何使用循环。花括号定义了将在循环中执行的内容。
InputBox, Jmp , Start, Enter Start number,,,,,,,,1
Loop
{
Sleep, 800
click 20,30 ; clicks "file"
Sleep, 500
Send {down 2} ; clicks "open"
; Copy the file name somewhere here
; Send, ^c ; Copy highlighted text to ClipBoard
; ClipWait
; If (ClipBoard = PreviousName)
; {
; Break
; MsgBox, Next filenumber = %Jmp%
; }
; PreviousName = %ClipBoard%
send {enter}
Sleep, 1200
click 211,128 ; clicks first filename in folder
Sleep, 1200
send {enter}
Sleep, 1000
click 20,30 ; clicks "file"
send {down 6}
send {enter} ; clicks "create wav"
Sleep, 1000
click 157,57 ; increase playcount to 2
Sleep, 500
send {enter}
Sleep, 1000
send {enter}
Sleep, 2500
send {enter}
click 20,30 ; clicks "file"
Sleep, 500
Send {down 2} ; clicks "open"
send {enter}
Sleep, 1200
click 211,128 ; clicks first filename in folder
Sleep, 1000
Send, {Down %Jmp%}
Jmp+=1
sleep, 100
send {enter}
Sleep, 1000
click 20,30 ; clicks "file"
send {down 6}
send {enter} ; clicks "create wav"
Sleep, 1000
click 157,57 ; increase playcount to 2
Sleep, 500
send {enter}
Sleep, 1000
send {enter}
Sleep, 2500
send {enter}
Sleep, 1000
; If (Jmp > "1000")
; Break
}
Return原始代码将一直运行到文件列表的末尾,然后继续对最后一个文件一次又一次地执行相同的操作。因此,我在代码中添加了一个文件名比较。在打开文件时,文件名可能以文本形式可用,这就是您将文件复制到ClipBoard并将ClipBoard与前一个文件名进行比较的内容。通过添加一个起始号,您可以在某个文件重新启动。
我看到你的代码使用了很多鼠标。如果您只运行这一次,这是没有问题的,但是如果您想要可靠地运行它,还有其他方法。
总体检查:检查在此过程中打开的每个窗口,并验证是否打开了正确的窗口。在本例中,我检查标题为"File“的窗口是否确实已打开并处于活动状态(另一个进程或程序聊天、更新等可以接管焦点,您的脚本将在此另一个程序中执行代码.)。
SetTitleMatchMode = 2
WinWaitActive, File Open, , 5 ; Wait up to five seconds for the screen
if ErrorLevel ; Execute this when the window is not activated within 5 seconds
{
SoundBeep 1000 , 1000 ; Warn the user
Break
}如果可能的话,也尝试使用键盘快捷键,或者(更高级的)使用AutoHotKey Windows Spy并检查ClassNN:在“现在在鼠标光标下”部分,然后使用它直接激活这些按钮,而不是通过鼠标坐标。
祝好运!
发布于 2013-02-21 04:02:57
尝试使用Window Spy,以便获得某个窗口的控件的类名。如果该窗口上有进度条,则更容易侦听进程已完成的事件。
基本上,使用ControlGet命令获取转换的进度,并使用ControlSend命令在控件上发送事件(例如,ControlSend, Button1, {Click}, ahk_class AWindow)。
https://stackoverflow.com/questions/14992973
复制相似问题