You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何自动用剪贴板内容替换IDM「下载文件信息」弹窗指定位置文本?

Automating IDM Download Dialog Text Replacement

Absolutely, you can automate this tedious repetitive task with AutoHotkey (AHK)—it’s tailor-made for GUI automation scenarios like interacting with IDM’s download dialogs. Let’s walk through exactly how to set this up:

Step 1: Install AutoHotkey

First, grab the latest version of AutoHotkey from its official website (it’s free) and install it on your system. Once installed, you’ll have access to the scripting tools needed to automate the IDM dialog.

Step 2: Create the Automation Script

Open Notepad (or any text editor) and paste the following script. I’ve added comments to explain what each part does:

#Persistent
SetTitleMatchMode, 2  ; Allow partial matching of window titles to catch IDM's dialog
SetControlDelay, 10   ; Small delay to ensure controls respond properly

; Continuously monitor for the IDM "Download File Info" dialog
Loop {
    WinWait, 下载文件信息
    WinWaitActive, 下载文件信息
    
    ; Get the current text from the filename input box (Edit1 is IDM's default filename field)
    ControlGetText, currentFilename, Edit1, 下载文件信息
    
    ; Only process if the filename contains .mp3
    if InStr(currentFilename, ".mp3") {
        ; Find the position of the rightmost backslash
        lastSlashPos := InStr(currentFilename, "\", false, 0)
        ; Find the start of the .mp3 extension
        mp3ExtPos := InStr(currentFilename, ".mp3")
        
        ; Make sure the positions are valid (slash comes before .mp3)
        if (lastSlashPos > 0 && mp3ExtPos > lastSlashPos) {
            ; Sanitize clipboard content to avoid invalid filename characters
            safeClipboard := Clipboard
            ; Replace illegal filename characters with underscores
            safeClipboard := StrReplace(safeClipboard, "\", "_")
            safeClipboard := StrReplace(safeClipboard, "/", "_")
            safeClipboard := StrReplace(safeClipboard, ":", "_")
            safeClipboard := StrReplace(safeClipboard, "*", "_")
            safeClipboard := StrReplace(safeClipboard, "?", "_")
            safeClipboard := StrReplace(safeClipboard, """", "_")
            safeClipboard := StrReplace(safeClipboard, "<", "_")
            safeClipboard := StrReplace(safeClipboard, ">", "_")
            safeClipboard := StrReplace(safeClipboard, "|", "_")
            
            ; Build the new filename: [path before last slash] + [sanitized clipboard] + [.mp3 and beyond]
            newFilename := SubStr(currentFilename, 1, lastSlashPos) . safeClipboard . SubStr(currentFilename, mp3ExtPos)
            
            ; Update the input box with the new filename
            ControlSetText, Edit1, %newFilename%, 下载文件信息
        }
    }
    
    ; Wait for the dialog to close before monitoring for the next one
    WinWaitClose, 下载文件信息
}

Step 3: Test and Run the Script

  1. Save the file with a .ahk extension (e.g., IDM_Filename_AutoReplace.ahk).
  2. Double-click the file to run it—you’ll see a green H icon in your system tray indicating the script is active.
  3. Copy the content you want to use into your clipboard, then trigger an IDM download to bring up the "下载文件信息" dialog. The script will automatically replace the target text segment with your clipboard content.

Key Notes & Troubleshooting

  • Verify the Input Box Control: If the script doesn’t work, use AutoHotkey’s built-in Window Spy (right-click the system tray H icon > Window Spy) to check the exact control name of IDM’s filename input box. If it’s not Edit1, replace Edit1 in the script with the correct control name.
  • Clipboard Sanitization: The script includes code to replace illegal filename characters with underscores—this prevents errors from invalid characters in your clipboard content.
  • Stopping the Script: Right-click the green H icon in the system tray and select "Exit" to stop the automation.

内容的提问来源于stack exchange,提问作者EasternRiver

火山引擎 最新活动