Jump to content
Sign in to follow this  
Achilles

For Spanish people with English keyboards

Recommended Posts

Achilles

This code is a simple way of inserting the symbols á, é, í, ó, ú, ü or ñ... :) I just used it to insert those!

Anyways, here's the code:

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>

If Not _Singleton('Symbols.au3', 1) then 
    WinActivate('Symbols', 'Select the symbol you want to insert then click "Insert".')
    WinMove('Symbols', 'Select the symbol you want to insert then click "Insert".', @DesktopWidth / 2 - 200, @DesktopHeight / 2 - 54)
    Exit
EndIf

Opt('GUIOnEventMode', 1)

Local Const $COLOR = 7709680
Local Const $DEFAULT_BK_COLOR = 11848946
Local Const $BK_COLOR = 14671871
Local Const $DebugIt = 1 ;Used for the double click
Local Const $STN_DBLCLK = 1 ;Used for the double click

GuiCreate('Symbols', 400, 108, -1, -1, -1, $WS_EX_TOPMOST) 
    GuiSetOnEvent($GUI_EVENT_CLOSE, '_Exit')
    GuiSetBkColor($BK_COLOR)

GuiSetFont(12)

GuiCtrlCreateLabel('Select the symbol you want to insert then click "Insert".', 3, 3, 394, 20, $SS_CENTER)

Dim $symbols[7] = ['á', 'é','í', 'ó', 'ú', 'ü', 'ñ']
$old = -1
$firstTime = True

GuiCtrlCreateButton('Close', 30, 70, 160, 30)
    GuiCtrlSetOnEvent(-1, '_Exit')

GuiCtrlCreateButton('Insert', 210, 70, 160, 30)
    GuiCtrlSetOnEvent(-1, '_Insert')

GuiSetFont(15, 700)

$x = 56
For $count = 0 to 6 
    ConsoleWRite(GuiCtrlCreateLabel($symbols[$count], $x, 28, 35, 35, $SS_CENTERIMAGE + $SS_SUNKEN + $SS_CENTER) & ' ')
        GuiCtrlSetOnEvent(-1, '_LabelHandler')
        GuiCtrlSEtBkColor(-1, $DEFAULT_BK_COLOR)
    $x += 42
Next

GUIRegisterMsg(0x0111, 'MY_WM_COMMAND')
GuiSetState()

While 1 
    Sleep(300)
WEnd 

Func _Insert()
    $pass = _WinList()
    $index = $old - 6
    If $index < 0 then Return
    If $pass = '' then Return
    WinActivate($pass)
    Send($symbols[$index])
EndFunc

Func _InsertDoubleClick($index) 
    $pass = _WinList()
    If $index < 0 then Return
    If $pass = '' then Return
    WinActivate($pass)
    Send($symbols[$index])  
EndFunc

Func _LabelHandler()
    GuiCtrlSetBkColor(@GUI_CtrlId, $COLOR)
    If Not $firstTime and @GUI_CtrlID <> $old then 
        GUICtrlSetBkColor($old, $DEFAULT_BK_COLOR)
    Else 
        $firstTime = False 
    EndIf
    $old = @GUI_CtrlId
EndFunc

Func _WinList()
    $winList = WinList()
    $count = 0

    For $i = 1 to $winList[0][0]
        If $winList[$i][0] <> "" And BitAnd(WinGetState($winList[$i][1]), 2 ) and $winList[$i][0] <> "Program Manager" Then
            $count += 1
            If $count = 2 then 
                Return $winList[$i][0]
            EndIf
        EndIf
    Next
    
    Return ''
EndFunc

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0xFFFF)
    Local $hCtrl = $lParam

    If $nNotifyCode = $STN_DBLCLK then 
        _InsertDoubleClick(@GUI_CtrlId - 6)
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc

Func _Exit() 
    Exit
EndFunc
Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
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
Sign in to follow this  

×