2

.FTM(FamiTracker)ファイルを.WAVに一括変換するプロセスを自動化するAutoHotKeyのプログラムに取り組んでいます。問題は、「send {down}」ステートメントの値をループごとに+1(フォルダー内の次の曲を選択するため)にインクリメントしたいということです。

編集コードを更新しました。インクリメントステートメントは機能します。フォルダ内のすべてのファイルを変換するために必要な回数だけプログラム全体をループさせる方法を見つける必要があります(各ループを{down}送信するために+1を追加します)。現在の問題は、プログラム全体がループしていないことです。 どんな助けでも大歓迎です!

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をクリックします。

どうもありがとう

4

2 に答える 2

1

Window Spy特定のウィンドウのコントロールのクラス名を取得できるように、を使用してみてください。そのウィンドウにプログレスバーがある場合でも、プロセスが終了したイベントを聞くのは簡単です。

基本的に、ControlGetコマンドを使用して変換の進行状況を取得し、コマンドを使用ControlSendしてコントロールでイベントを送信します(例ControlSend, Button1, {Click}, ahk_class AWindow)。

于 2013-02-21T04:02:57.133 に答える
1

ループ内でもう1つのファイルをスキップする場合は、次のようなものを使用できます。リストの最後でこのループを終了するには、最後のファイル名を現在のファイル名と比較するテストを追加する必要があります。

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

元のコードはファイルリストの最後まで実行され、最後のファイルに対して同じアクションを繰り返し実行します。したがって、コード内にファイル名の比較を追加しました。ファイルを開くと、おそらくテキスト形式でファイル名を使用できます。これをクリップボードにコピーして、クリップボードを前のファイル名と比較します。開始番号を追加することにより、特定のファイルから再開できます。

あなたのコードは多くのマウスクリックを使用しているようです。これを1回だけ実行する場合は問題ありませんが、これを確実に実行する場合は、他の方法があります。

全体的なチェック:このプロセス中に開かれるすべてのウィンドウをチェックし、右側のウィンドウが開いていることを確認します。この例では、「ファイルを開く」というタイトルのウィンドウが実際に開いてアクティブになっているかどうかを確認します(他のプロセスまたはプログラム[チャット、更新など]がフォーカスを引き継ぐことができ、スクリプトがこのコードを実行します他のプログラム...)。

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-21T06:14:01.543 に答える