Jump to content

Change typed words


James
 Share

Recommended Posts

This is definetly possible, I asked the same question and got a great response, here is an example:

This will work.

$GUI = GUICreate("Example", 315, 98)
GUICtrlCreateLabel("Type Something!", 0, 0, 84, 17)
$Input = GUICtrlCreateInput("", 0, 16, 313, 21)
GUICtrlCreateLabel("Words supported:", 0, 64, 88, 17)
GUICtrlCreateLabel("Hello - Howdy", 0, 80, 70, 17)
GUISetState(@SW_SHOW)

While 1
    _ReplaceWords(GUICtrlRead($Input), "Hello", "Howdy", $Input)
    _ReplaceWords(GUICtrlRead($Input), "Hi", "Hello", $Input)
    Switch GUIGetMsg()
        Case - 3
            Exit
    EndSwitch
WEnd

; $String = The string of words to replace. $Word = The word to replace. $ReplaceWord = The word to replace $Word. $Control = The control to set the data.
Func _ReplaceWords($String, $Word, $ReplaceWord, $Control)
    If StringInStr($String, $Word) Then GUICtrlSetData($Control, StringReplace($String, $Word, $ReplaceWord))
EndFunc
Edited by JustinReno
Link to comment
Share on other sites

Not quite what I was after. When you type in anything it changes the word:

$Hotkey = "i,o,a,s,e,b,t,I,O,S,E,B,T"; l3tt3r$ d13 0mg3z3t m033t3n word3n
$l33t   = "1,0,4,$,3,8,7,1,0,$,3,8,7"; d3 n44r om t3 z3tt3n l3tt3r$

Global Const $aHotkey = StringSplit($Hotkey,",")
Global Const $al33t = StringSplit($l33t,",")

For $x = 1 to $aHotkey[0]
    HotKeySet($aHotkey[$x],"l33tfunc")
Next

While 1
    Sleep(1000)
WEnd

Func l33tfunc()
    For $x = 1 to $aHotkey[0]
        If $aHotkey[$x] = @HotKeyPressed Then Send($al33t[$x])
    Next
EndFunc
Link to comment
Share on other sites

Hes looking for a script that runs in the background and parses typing...so...if your typing here...and its running...you type: Hello...it will AUTOmatically change it to

Howdy...but wont type Hello...understand now?

Link to comment
Share on other sites

ahh so somethign like MS word's auto correct feature outside the program. hmm you could check each key entered and if it = this key then if the next key is this and so on then if all those are in the right order, backspace however many letters there are and send the new word, if that makes since lol :)

Link to comment
Share on other sites

I wrote the exact thing ... for me it was a "shorthand" script. I used a Keyboard hook and would evaluate words whenever a non-alphanumeric key was pressed (with a few other exceptions). If the eval fell though, I left the word alone, otherwise I backspaced and Send() the replacement. I had to backspace to make it work in all apps. You see the problem if you type too fast... But I never set it for more than just short words. Ignore the hook when Send()ing.

Anyway... it was a useful script that I believe I have deleted. Good luck.

Lar.

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Link to comment
Share on other sites

Here's what Larry created, I changed it a bit and don't remember how he got it to work. Now, if you type "hello" it will send backspace until "h" and then send "owdy" but it still sends the "o" after that and I'm not sure how to stop it in an efficient way.

#include <DllCallBack.au3>

Opt("OnExitFunc", "_FuncTest")

Global Const $WH_KEYBOARD_LL = 13
Global $hHook
Global $pStub_KeyProc = _DllCallBack("_KeyProc","int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0)
Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int", _
            $WH_KEYBOARD_LL,"ptr",$pStub_KeyProc,"hwnd",$hmod[0],"dword",0)
Global $buffer = ""

While 1
    Sleep(30)
WEnd

Func EvaluateKey($keycode)
    If (($keycode > 64) And ($keycode < 91)) _
        Or (($keycode > 47) And ($keycode < 58)) Then
        $buffer &= Chr($keycode)
        
        If $buffer = "hello" then 
            Send('{BS 3}owdy')
            $buffer = ""
        EndIf
    EndIf
EndFunc 

Func _KeyProc($nCode, $wParam, $lParam) 
    Local $ret,$KEYHOOKSTRUCT
    If $nCode < 0 Then
        $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                        "int",$nCode,"ptr",$wParam,"ptr",$lParam)
        Return $ret[0]
    EndIf
    If $wparam = 256 Then
        $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr",$lParam)
        EvaluateKey(DllStructGetData($KEYHOOKSTRUCT,1))
    EndIf
    $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                    "int",$nCode,"ptr",$wParam,"ptr",$lParam)
    Return $ret[0]
EndFunc

Func _FuncTest() 
    DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0])
    _DllCallBack_Free ($pStub_KeyProc)
EndFunc
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...