; ============================================================ ; DX4WIN ADIF Import Automation ; ============================================================ ; Hotkey: Ctrl+Alt+I ; ; Sequence: ; 1. DX4WIN main window (ahk_class TQSOForm) -> Alt+F -> "I" (Import/Export...) ; This opens the "Import / Export Filters" dialog (ahk_class TPickIEFilter) ; 2. That dialog's own File menu -> Alt+F -> "I" (Import) ; This opens the standard Windows file picker ; 3. Type the ADIF path, press Enter ; 4. "Options for duplicate QSOs" dialog (ahk_class TAskDupesImport) appears ; -> set dropdown to "Imported QSO is ignored" -> click OK ; ; If the "Import / Export Filters" dialog is already open when the hotkey is ; pressed, the script skips step 1 and jumps straight to opening Import from ; that dialog's File menu, instead of reactivating the main window (which ; would disrupt the already-open dialog). ; ============================================================ ADIFPath := "C:\ham program files\dx4w901\save\wsjtx_log.adi" ^!i::DoDX4WinImport() DoDX4WinImport() { global ADIFPath ; --- Detect current state --- if WinExist("ahk_class TPickIEFilter") { WinActivate("ahk_class TPickIEFilter") if !WinWaitActive("ahk_class TPickIEFilter", , 3) { MsgBox("Could not activate existing Import / Export Filters dialog.", "DX4WIN Import", "Iconx") return } } else { ; --- 1. Activate DX4WIN main window --- if !WinExist("ahk_class TQSOForm") { MsgBox("DX4WIN main window not found. Make sure DX4WIN is running.", "DX4WIN Import", "Iconx") return } WinActivate("ahk_class TQSOForm") if !WinWaitActive("ahk_class TQSOForm", , 3) { MsgBox("Could not activate DX4WIN main window.", "DX4WIN Import", "Iconx") return } Sleep(300) ; extra buffer: WinWaitActive confirms active state, but ; keyboard input routing can lag slightly behind, especially ; if another window from the same process previously had focus ; --- 2. Open File menu, then Import/Export... --- Send("!f") Sleep(300) Send("i") Sleep(300) ; --- 3. Wait for "Import / Export Filters" dialog --- if !WinWait("ahk_class TPickIEFilter", , 3) { MsgBox("Import / Export Filters dialog did not appear.", "DX4WIN Import", "Iconx") return } WinActivate("ahk_class TPickIEFilter") if !WinWaitActive("ahk_class TPickIEFilter", , 3) { MsgBox("Could not activate Import / Export Filters dialog.", "DX4WIN Import", "Iconx") return } } ; --- 4. Inside that dialog: Alt+F -> Import --- Send("!f") Sleep(300) Send("i") Sleep(500) ; --- 5. Standard Windows file picker should now be open --- if !WinWait("ahk_class #32770", , 3) { MsgBox("File selection dialog did not appear.", "DX4WIN Import", "Iconx") return } WinActivate("ahk_class #32770") Sleep(200) ; --- 6. Type the full path into the filename field and confirm --- Send("!n") ; Alt+N focuses filename field in standard Open dialogs Sleep(200) Send("^a") Send(ADIFPath) Sleep(200) Send("{Enter}") ; --- 7. "Options for duplicate QSOs" dialog --- if !WinWait("ahk_class TAskDupesImport", , 3) { MsgBox("Options for duplicate QSOs dialog did not appear.", "DX4WIN Import", "Iconx") return } WinActivate("ahk_class TAskDupesImport") if !WinWaitActive("ahk_class TAskDupesImport", , 3) { MsgBox("Could not activate Options for duplicate QSOs dialog.", "DX4WIN Import", "Iconx") return } Sleep(200) ; Try to set the dropdown directly. TWheelx1 is a custom control (not a ; standard ComboBox), so ControlSetText may or may not work depending on ; how it's implemented. We verify afterward and fall back if needed. desiredText := "Imported QSO is ignored" try ControlSetText(desiredText, "TWheelx1", "ahk_class TAskDupesImport") catch { } Sleep(200) actualText := "" try actualText := ControlGetText("TWheelx1", "ahk_class TAskDupesImport") catch { } if (actualText != desiredText) { ; Fallback: click the control to give it focus, then try typing ; the first letter to jump to the matching entry. ControlClick("TWheelx1", "ahk_class TAskDupesImport") Sleep(200) Send("i") Sleep(200) try actualText := ControlGetText("TWheelx1", "ahk_class TAskDupesImport") catch { } if (actualText != desiredText) { MsgBox("Could not confirm dropdown is set to '" . desiredText . "'.`nCurrent value: '" . actualText . "'.`nPlease set it manually, then click OK.", "DX4WIN Import", "Icon!") return } } ; --- 8. Click OK --- ControlClick("TBitBtn2", "ahk_class TAskDupesImport") ; --- 9. Done --- Sleep(500) ToolTip("ADIF import sent to DX4WIN") SetTimer(() => ToolTip(), -2000) }