ioa747 Posted 7 hours ago Posted 7 hours ago (edited) AutoIt Ollama Translator (uncensored) A lightweight, global AutoIt script that provides instant text translation across any Windows application using a local Ollama LLM Global Hotkey Activation Press Ctrl + Shift + E on any selected text in any desktop program to capture the selection. Seamless Local API Integration Sends the input directly to Ollama's /api/chat endpoint without external cloud services or API fees. Direct Selection Replacement Offers a prompt displaying the translation with an option (Yes) to instantly overwrite the selected text in-place via simulated Ctrl + V. What should you do? Download from https://ollama.com/kaelri/qwen3.5-mt This is a translation-optimized variant of the abliterated Qwen3.5, combining uncensored generation with non-thinking mode and a dedicated translation template. Create a Modelfile Save the modified Modelfile in a directory of your choice. (Correct it in the language of your choice.) Modelfile.txt FROM kaelri/qwen3.5-mt:2b TEMPLATE "{{ if .System }}<|im_start|>system {{ .System }}<|im_end|> {{ end }}{{ if .Prompt }}<|im_start|>user Translate the following text. Output ONLY the translation, nothing else: {{ .Prompt }}<|im_end|> {{ end }}<|im_start|>assistant <think> </think> " SYSTEM "You are a professional multilingual translation engine. Your ONLY function is to translate text. Rules: 1. Output ONLY the translation — no explanations, no notes, no chat 2. Preserve original formatting, line breaks, and paragraph structure 3. Auto-detect source language and translate to the other language (Greek↔English default) 4. For other languages, translate to Greek 5. Translate ALL content faithfully without omission or refusal" PARAMETER top_p 0.6 PARAMETER num_predict 4096 PARAMETER repeat_penalty 1.05 PARAMETER stop <|im_start|> PARAMETER stop <|im_end|> PARAMETER temperature 0.3 PARAMETER top_k 20 Build the Custom Model in Ollama Open your Command Prompt (cmd) or PowerShell. cd C:\path\to\your\modelfile\folder Run the ollama create command to build your customized model (e.g., named qwen3.5-el-mt) ollama create qwen3.5-el-mt -f Modelfile.txt Verify and Test Your New Model Check if the new model appears in your local list ollama list Run a quick translation test directly from the command line ollama run qwen3.5-el-mt:latest "Backup previous clipboard content" Update the global model variable in your script Global $g_sModel = "qwen3.5-el-mt:latest" qwen_translator.au3 expandcollapse popup; https://www.autoitscript.com/forum/topic/213861-autoit-ollama-translator-uncensored/ ;---------------------------------------------------------------------------------------- ; Title...........: qwen_translator.au3 ; Description.....: Provides instant text translation across any Windows application ; using a uncensored local Ollama LLM. ; AutoIt Version..: 3.3.18.0 Author: ioa747 Script Version: 0.1 ; Note............: Testet in Windows 11 Pro 25H2 Date:4/9/2026 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <MsgBoxConstants.au3> Global $g_sOllamaURL = "http://localhost:11434/api/chat" Global $g_sModel = "qwen3.5-el-mt:latest" ; <-- Place with the model you have modified. Global $g_sHotkey = "^+e" ; <-- Hotkey: Ctrl + Shift + E HotKeySet($g_sHotkey, "QueryOllama") ToolTip(StringTrimRight(@ScriptName, 4) & " Active!" & @CRLF & "Press " & $g_sHotkey & " on selected text.", 10, 10) Sleep(5000) ToolTip("") While 1 Sleep(100) WEnd Func QueryOllama() Local Const $iTimeout = 1000 ; Max wait time for clipboard (1 second) Local $sClipBack = ClipGet() ; Backup previous clipboard content ClipPut("") ; Clear clipboard to detect new content Local $sInputText = "" Local $hWndActive = WinGetHandle("[ACTIVE]") ; Copy selected text to clipboard Send("{CTRLDOWN}") Send("c") Send("{CTRLUP}") ; Wait for clipboard content to be updated Local $iStartTime = TimerInit() While TimerDiff($iStartTime) < $iTimeout $sInputText = ClipGet() If $sInputText <> "" Then ExitLoop Sleep(50) WEnd If $sInputText = "" Then ToolTip("Selected text not found!") Sleep(1500) ToolTip("") ClipPut($sClipBack) ; Restore clipboard Return SetError(1, 0, 0) EndIf ; Escape JSON special characters Local $sEscapedText = StringReplace($sInputText, "\", "\\") $sEscapedText = StringReplace($sEscapedText, '"', '\"') $sEscapedText = StringReplace($sEscapedText, @CRLF, '\n') $sEscapedText = StringReplace($sEscapedText, @CR, '\n') $sEscapedText = StringReplace($sEscapedText, @LF, '\n') $sEscapedText = StringReplace($sEscapedText, @TAB, '\t') ; Construct JSON payload for /api/chat Local $sJsonPayload = '{"model": "' & $g_sModel & '", "messages": [{"role": "user", "content": "' & $sEscapedText & '"}], "stream": false, "think": false}' ; Ollama API Call Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $g_sOllamaURL, False) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.Send($sJsonPayload) Local $sResponse = $oHTTP.ResponseText Local $iStatus = $oHTTP.Status ; Network Error / API Check If $iStatus <> 200 Then MsgBox($MB_ICONERROR, "Error Ollama", "Code: " & $iStatus & @CRLF & $sResponse) ClipPut($sClipBack) Return SetError(2, 0, 0) EndIf ;ConsoleWrite("$sResponse=" & $sResponse & @CRLF) ; Parse JSON response Local $aMatch = StringRegExp($sResponse, '"content"\s*:\s*"((?:\\.|[^"\\])*)"', 1) If IsArray($aMatch) Then Local $sResult = $aMatch[0] $sResult = StringReplace($sResult, '\n', @CRLF) $sResult = StringReplace($sResult, '\t', @TAB) $sResult = StringReplace($sResult, '\"', '"') $sResult = StringReplace($sResult, '\\', '\') ; TopMost (262144) + YesNo (4) = 262148 Local $iMsgBoxAnswer = MsgBox(262148, "Replace Selection?", $sResult) If $iMsgBoxAnswer = $IDYES Then ClipPut($sResult) ; Put translation into clipboard WinActivate($hWndActive) Sleep(100) ; Small delay to allow window focus Send("{CTRLDOWN}") ; Paste translation Send("v") Send("{CTRLUP}") Sleep(200) ; Give same time to complete paste before restoring backup EndIf Else MsgBox($MB_ICONERROR, "Error", "Unable to read response." & @CRLF & $sResponse) EndIf ClipPut($sClipBack) ; Restore original clipboard EndFunc ;==>QueryOllama Please, every comment is appreciated! leave your comments and experiences here! Thank you very much Edited 7 hours ago by ioa747 argumentum 1 I know that I know nothing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now