Loops 自动热键循环增量

Loops 自动热键循环增量,loops,converter,autohotkey,Loops,Converter,Autohotkey,我正在用AutoHotKey开发一个程序,它可以自动将.FTM(FamiTracker)文件大规模转换为.WAV。问题是,我希望它在每个循环中增加“send{down}”语句的值+1(以选择文件夹中的下一首歌曲) 编辑我已经更新了代码。increment语句有效,我只需要找到一种方法,使整个程序循环次数与转换文件夹中所有文件所需次数相同(添加+1以发送{down}每个循环)。现在的问题是它没有循环整个程序。感谢您的帮助 以下是该计划在启动FamiTracker音乐应用程序后的表现: Slee

我正在用AutoHotKey开发一个程序,它可以自动将.FTM(FamiTracker)文件大规模转换为.WAV。问题是,我希望它在每个循环中增加“send{down}”语句的值+1(以选择文件夹中的下一首歌曲)

编辑我已经更新了代码。increment语句有效,我只需要找到一种方法,使整个程序循环次数与转换文件夹中所有文件所需次数相同(添加+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,依此类推


非常感谢

尝试使用
窗口间谍
,这样您将获得特定窗口控件的类名。如果该窗口上有进度条,则更容易侦听流程完成的事件


基本上,使用
ControlGet
命令获取转换进度,并使用
ControlSend
命令发送控件上的事件(例如
ControlSend,Button1,{Click},ahk_class AWindow
)。

如果要在循环中跳过一个以上的文件,可以使用类似的方法。 您应该添加一个测试来比较最后一个文件名和当前文件名,以便在列表末尾退出此循环

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
原始代码将一直运行到文件列表的末尾,然后继续对最后一个文件反复执行相同的操作。因此,我在代码中添加了一个文件名比较。打开文件时,您可能有文本形式的文件名,这是您复制到剪贴板上并将剪贴板与以前的文件名进行比较的内容。通过添加起始编号,您可以在某个文件上重新启动

我看到你的代码使用了很多鼠标点击。如果只运行一次,这是没有问题的,但是如果您想可靠地运行它,还有其他方法

全面检查: 检查在此过程中打开的每个窗口,并确认正确的窗口已打开。在本例中,我检查标题为“File Open”(文件打开)的窗口是否确实已打开并处于活动状态(其他进程或程序[聊天、更新等]可以接管焦点,您的脚本将在此其他程序中执行代码…)

如果可能,也可以尝试使用键盘快捷键,或者(更高级)使用
自动热键Windows Spy
并检查“鼠标光标下”部分的ClassNN:,然后使用此选项通过鼠标坐标直接激活这些按钮


祝你好运

我已经更新了上面的代码,只是想知道如何在每次向send{down}语句中添加+1的同时使程序循环(大约100个文件)。太棒了!现在可以了:)非常感谢你,伊尔布林克先生!我将检查每一行代码,试图完全理解它的功能。谢谢你的建议和帮助:)我更新了你的代码,而不是把它写在答案中。循环花括号需要在代码之外,您可能想检查是否已到达文件列表的末尾。我刚刚看到我的更新未被接受。。。。。。
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
  }