SDR Oxide - Browan : Direct Frequency Input + Small window

Posted by @XYZ •
#1 @XYZ
SDR Oxide - Browan : Direct Frequency Input + Small window via AutoHotkey AutoHotkey v1.1 https://www.autohotkey.com/ ** The coordinates in the code will vary depending on the display settings of your SDROxide, so please adjust them accordingly. A history of up to the last five frequencies is saved, and you can jump to any of them instantly by clicking the corresponding button. Frequency input is buffered until confirmed by pressing the Enter key. It will be displayed once entry is complete. When SDROxide is active, you can toggle the small window between hidden and visible modes by pressing "Shift + Ctrl + H". - Install AutoHotkey v1.1 on your PC. - Create a file containing the code below, name it (e.g., "SDROxideHotKey.ahk"), and place it in the same folder as `sdroxide.exe`. **Ensure the file extension is ".ahk".** - Double-click the .ahk file to launch it. (Creating a shortcut on your desktop may be convenient.) - If SDROxide fails to start, close the .ahk script, launch `sdroxide.exe` manually, and then restart the .ahk script once you have confirmed that SDROxide is running. (This is necessary for the script to retrieve coordinate data.) - Beforehand, remove any numeric keys currently assigned as shortcut keys within the SDROxide application itself. I currently use this myself, but as it is for research purposes, I do not provide support. #NoEnv #SingleInstance Force SetWorkingDir %A_ScriptDir% ; ----- SDROxide Boot and Stand-by ----- IfWinNotExist, ahk_exe sdroxide.exe { IfWinNotExist, SDROxide { Run, %A_ScriptDir%\sdroxide.exe WinWait, ahk_exe sdroxide.exe,, 10 WinWaitActive, ahk_exe sdroxide.exe,, 10 Sleep, 500 } } global freqBuffer := "" global isTuningEnabled := true global isGuiVisible := true global inputMode := "kHz" global historyList := [] ; ========================================================= ; SDROxide WINDOW (X, Y) ; ========================================================= WinGetPos, winX, winY, winW, winH, ahk_exe sdroxide.exe if (winX = "") { winX := 100 winY := 100 } ; ### Small window (X, Y) ### guiX := winX + 1160 guiY := winY + 735 ; ========================================================= ; AHK GUI (Enlarged text size / Stylish panel) ; ========================================================= Gui, +AlwaysOnTop +ToolWindow +E0x08000000 +HwndGuiHwnd -Caption +Border Gui, Color, 1A1D24, 252932 ; Dark navy gray ; ----- Header and UTC Clock ----- Gui, Font, s9 c7A889B Bold, Segoe UI Gui, Add, Text, x10 y8 w110 h18, SDROxide Ctrl Gui, Font, s10 c00E5FF Bold, Consolas Gui, Add, Text, x160 y7 w110 h18 Right vUtcClockText, 00:00:00 UTC ; Line Gui, Add, Progress, x8 y28 w264 h1 Background3A4250, 0 ; ----- Main control ----- Gui, Font, s9 c00FFA3 Bold, Segoe UI Gui, Add, Button, x10 y34 w82 h28 vBtnToggle gToggleTuningStatus, Direct: ON Gui, Font, s9 cE1E6EB Bold, Segoe UI Gui, Add, Button, x98 y34 w82 h28 vBtnMode gToggleInputMode, Mode: kHz Gui, Font, s9 cFF5555 Bold, Segoe UI Gui, Add, Button, x186 y34 w84 h28 gQuitApp, Exit (Shift+Q) ; ----- History ----- Gui, Font, s8 c6C7A89 Bold, Segoe UI Gui, Add, Text, x10 y67 w260 h15 Center, --- FREQ HISTORY --- ; ----- History Button ----- Gui, Font, s9 cFFC107 Bold, Consolas Gui, Add, Button, x10 y84 w82 h24 vHist1 gTuneFromHistory hidden, - Gui, Add, Button, x98 y84 w82 h24 vHist2 gTuneFromHistory hidden, - Gui, Add, Button, x186 y84 w84 h24 vHist3 gTuneFromHistory hidden, - Gui, Add, Button, x54 y112 w82 h24 vHist4 gTuneFromHistory hidden, - Gui, Add, Button, x144 y112 w84 h24 vHist5 gTuneFromHistory hidden, - ; ----- Footer Navigation ----- Gui, Font, s8 c5A6578 Normal, Segoe UI Gui, Add, Text, x10 y140 w260 h15 Center, Hide/Show: Ctrl+Shift+H ; UTC Clock Timer SetTimer, UpdateUtcClock, 1000 GoSub, UpdateUtcClock ; GUI (width 280 x height 160) Gui, Show, x%guiX% y%guiY% w280 h160 NoActivate, SDROxide Control ; ========================================================= ; Shortcut Key Input Control ; ========================================================= #IfWinActive ahk_exe sdroxide.exe +q:: GoSub, QuitApp ScrollLock:: GoSub, ToggleTuningStatus ^+h:: GoSub, ToggleGuiVisibility ~.:: AddDigit(".") NumpadDot:: AddDigit(".") #If ; ========================================================= ; SDROxide Direct numeric input hook on-screen ; ========================================================= #If WinActive("ahk_exe sdroxide.exe") && isTuningEnabled && IsMainUIActive() ~0:: AddDigit("0") ~1:: AddDigit("1") ~2:: AddDigit("2") ~3:: AddDigit("3") ~4:: AddDigit("4") ~5:: AddDigit("5") ~6:: AddDigit("6") ~7:: AddDigit("7") ~8:: AddDigit("8") ~9:: AddDigit("9") Numpad0:: AddDigit("0") Numpad1:: AddDigit("1") Numpad2:: AddDigit("2") Numpad3:: AddDigit("3") Numpad4:: AddDigit("4") Numpad5:: AddDigit("5") Numpad6:: AddDigit("6") Numpad7:: AddDigit("7") Numpad8:: AddDigit("8") Numpad9:: AddDigit("9") AddDigit(digit) { global freqBuffer, inputMode freqBuffer .= digit ToolTip, Tuning: %freqBuffer% %inputMode% } Backspace:: if (StrLen(freqBuffer) > 0) { StringTrimRight, freqBuffer, freqBuffer, 1 if (freqBuffer = "") ToolTip else ToolTip, Tuning: %freqBuffer% %inputMode% } return Escape:: freqBuffer := "" ToolTip return Enter:: NumpadEnter:: ApplyFrequency(freqBuffer) return #If ; ========================================================= ; Subroutine and Function Processing ; ========================================================= UpdateUtcClock: utcTime := A_NowUTC FormatTime, utcStr, %utcTime%, HH:mm:ss GuiControl,, UtcClockText, %utcStr% UTC return ToggleInputMode: if (inputMode = "kHz") { inputMode := "MHz" GuiControl,, BtnMode, Mode: MHz ToolTip, Mode Changed: MHz } else { inputMode := "kHz" GuiControl,, BtnMode, Mode: kHz ToolTip, Mode Changed: kHz } SetTimer, RemoveToolTip, -1500 return ToggleGuiVisibility: isGuiVisible := !isGuiVisible if (isGuiVisible) { Gui, Show, NoActivate ToolTip, Panel: Shown } else { Gui, Hide ToolTip, Panel: Hidden } SetTimer, RemoveToolTip, -1500 return ApplyFrequency(inputVal) { global freqBuffer, inputMode if (inputVal = "" || inputVal = ".") return targetMHz := "" displayStr := "" if (inputMode = "kHz") { targetkHz := inputVal + 0 if (targetkHz <= 0) { freqBuffer := "" ToolTip return } mhzVal := targetkHz / 1000.0 targetMHz := Format("{:.6f}", mhzVal) targetMHz := RTrim(RTrim(targetMHz, "0"), ".") displayStr := targetkHz . " kHz" } else { targetMHz := inputVal displayStr := targetMHz . " MHz" } Click, 200, 100, 2 Sleep, 200 Send, ^a Sleep, 50 Send, {BS} Sleep, 50 Send, %targetMHz% Sleep, 100 Send, {Enter} AddHistory(displayStr, targetMHz) freqBuffer := "" ToolTip, Tuned: %displayStr% SetTimer, RemoveToolTip, -2000 } TuneFromHistory: GuiControlGet, clickedBtnText,, %A_GuiControl% if (clickedBtnText = "" || clickedBtnText = "-") return btnIndex := SubStr(A_GuiControl, 5) + 0 targetMHz := historyList[btnIndex].mhz displayStr := historyList[btnIndex].disp Click, 200, 100, 2 Sleep, 200 Send, ^a Sleep, 50 Send, {BS} Sleep, 50 Send, %targetMHz% Sleep, 100 Send, {Enter} ToolTip, Tuned (Hist): %displayStr% SetTimer, RemoveToolTip, -2000 return AddHistory(disp, mhz) { global historyList if (historyList.Length() > 0 && historyList[1].disp = disp) return historyList.InsertAt(1, {disp: disp, mhz: mhz}) if (historyList.Length() > 5) historyList.Pop() Loop, 5 { if (A_Index <= historyList.Length()) { txt := historyList[A_Index].disp GuiControl,, Hist%A_Index%, %txt% GuiControl, Show, Hist%A_Index% } } } ToggleTuningStatus: isTuningEnabled := !isTuningEnabled if (isTuningEnabled) { GuiControl,, BtnToggle, Direct: ON ToolTip, Direct Tuning: ON } else { GuiControl,, BtnToggle, Direct: OFF ToolTip, Direct Tuning: OFF } WinActivate, ahk_exe sdroxide.exe SetTimer, RemoveToolTip, -1500 return QuitApp: WinClose, ahk_exe sdroxide.exe ExitApp return GuiClose: GoSub, QuitApp return RemoveToolTip: ToolTip return IsMainUIActive() { WinGetTitle, activeTitle, A if InStr(activeTitle, "Settings") || InStr(activeTitle, "Setup") || InStr(activeTitle, "Config") return false return true }
001.png

You must be logged in to reply to this radio discussion.