Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;=============================================
- ; Foreign Characters GUI
- ;=============================================
- ; This script creates a graphical user interface (GUI) for easily inputting foreign Characters
- ;
- ; =Usage=
- ; Run the script, select the language to use, and you will see a menu with all the relevant characters.
- ; This script will always stay on top of other windows.
- ; While typing in your working document, click the respective character button to input it.
- ;
- ; =Features=
- ; Currently supports Polish, Italian, Spanish and German characters
- ; Click and drag language name to reposition the GUI
- ; Double-click language name to 'minimise'/'restore' the GUI
- ;
- ;=Notes=
- ; To add a new language/character set, you must:
- ; 1. Add a new character set. Call it "FrenchChars" for example, and include all relevant symbols (separated by commas, no spaces).
- ; 2. Add a new language button in the selection menu (========== Select Language GUI ==========)
- ; 3. Increase selection menu GUI height
- ; 4. Add a new subroutine to link to the button. Make sure to change the 'Language' variable accordingly.
- ; 5.
- ; 6.
- ; 7.
- ;
- ;=============================================
- #SingleInstance Force
- #Persistent
- SysGet, Size, MonitorWorkArea
- SetTitleMatchMode, 2
- ;========== Can Change These ==========
- ; CHARACTER SETS
- PolishChars = Ą,ą,Ć,ć,Ę,ę,Ł,ł,Ń,ń,Ó,ó,Ś,ś,Ż,ż,Ź,ź,«,»,€,zł,–,—,„,”
- FrenchChars = À,à,Â,â,Æ,æ,Ç,ç,É,é,È,è,Ê,ê,Ë,ë,Ï,ï,Î,î,Ô,ô,Œ,œ,Ù,ù,Û,û,Ü,ü,Ÿ,ÿ,€,$,«,»,–,—
- ItalianChars = À,à,È,è,É,é,Ì,ì,Ò,ò,Ó,ó,Ù,ù,«,»,$,€
- SpanishChars = Á,á,É,é,Í,í,Ñ,ñ,Ó,ó,Ú,ú,Ü,ü,¿,¡,€,$,«,»,–,—
- GermanChars = Ä,ä,Ö,ö,Ü,ü,ß,€
- ; POSITIONING
- XPos1 = 5
- XPos2 = 40
- GuiWidth = 75
- GuiRight := SizeRight - 150
- SelectLanguageButtonSpacing = 5
- ;========== Select Language GUI ==========
- YGUI2 := SelectLanguageButtonSpacing
- Gui, 2: Color, cFFFFFF
- Gui, 2: Font, w700 c000000 s10
- Gui, 2: Add, Text, w130 h20 x0 y5 Center, Select Language
- Gui, 2: Font, w400 cFFFFFF s10
- Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gPolish, Polish ; List of languages to choose from in first menu (the g{Language} links it to the subroutines below)
- Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gFrench, French
- Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gItalian, Italian
- Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gSpanish, Spanish
- Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gGerman, German ; To add new languages, add them under here, copying similar format
- Gui, 2: Font, w600 c000000 s10
- Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gClose, Close
- Gui, 2: +AlwaysOnTop -Caption +ToolWindow +Border
- Gui, 2: Show, w130 h180, Select Language ; If you add extra languages, increase height by 25
- return
- Polish:
- Language = Polish
- Gosub ForeignChars
- return
- French:
- Language = French
- Gosub ForeignChars
- return
- Italian:
- Language = Italian
- Gosub ForeignChars
- return
- Spanish:
- Language = Spanish
- Gosub ForeignChars
- return
- German: ; If you add a new language button, make sure to create a subroutine here which changes the "Language" variable. Copy this format.
- Language = German
- Gosub ForeignChars
- return
- ;========== SHOULDN'T NEED TO CHANGE MUCH FROM HERE==========
- ;========== Foreign Characters GUI ==========
- ForeignChars:
- Gui, 2: Destroy
- YPos = 5
- Gui, 1: Color, cFFFFFF ; GUI Background Colour
- Gui, 1: Font, w700 c000000 s12 ; Heading colour, size and bold
- Gui, 1: Add, Text, w%GuiWidth% h20 x0 y%YPos% Center gDragFull, %Language% ; Heading - i.e. "Polish". Also can drag on heading to reposition.
- YPos += 25
- Gui, 1: Font, w400 cFFFFFF ; Button colour (inside loop)
- Loop, parse, %Language%Chars, `, ; Parse each character as a separate variable
- {
- Character = %A_LoopField%
- Pos1:=!Pos1
- If Pos1
- {
- Gui, 1: Add, Button, w30 h30 x%XPos1% y%YPos% gSendChar, %Character% ; Add a button for each character
- }
- else
- {
- Gui, 1: Add, Button, w30 h30 x%XPos2% y%YPos% gSendChar, %Character% ; Add a button for each character
- YPos += 35
- }
- }
- Gui, 1: Font, w600 c000000 s10
- Gui, 1: Add, Button, w65 h20 x%XPos1% y%YPos% gClose, Close ; Close button
- YPos += 25
- GuiBottom := SizeBottom - YPos - 90
- ;
- Gui, 1: +AlwaysOnTop -Caption +Border ; Removed +ToolWindow
- Gui, 1: Show, NoActivate w%GuiWidth% h%YPos% x%GuiRight% y%GuiBottom%, Foreign Characters
- Gosub Reposition
- return
- DragFull: ; When full GUI, drag on heading to reposition. Otherwise, double click to minimize
- If A_GuiEvent = DoubleClick
- {
- GoSub Minimized
- Return
- }
- PostMessage, 0xA1, 2,,, A
- return
- Minimized: ; Show minimized/compact GUI. Only shows Language heading and 'Close' button
- WinGetPos GUI1X, GUI1Y, , , Foreign Characters ahk_class AutoHotkeyGUI ; Gets position of full GUI so compact GUI will be in the same place.
- Gui, 1: Hide ; Hides full GUI, in order to show compact GUI
- Gui, 3: Color, cFFFFFF ; GUI Background Colour
- Gui, 3: Font, w700 c000000 s12 ; Heading Colour
- Gui, 3: Add, Text, w%GuiWidth% h20 x0 y5 Center gDragMin, %Language% ; Heading - i.e. "Polish". Can drag on heading to reposition.
- Gui, 3: Font, w600 c000000 s10
- Gui, 3: Add, Button, w65 h20 x5 y+5 gClose, Close
- Gui, 3: +AlwaysOnTop -Caption +Border ; Removed +ToolWindow
- Gui, 3: Show, NoActivate w%GuiWidth% h55 x%GUI1X% y%GUI1Y%, Foreign Characters - MIN ; Show compact GUI in same position
- return
- DragMin: ; When compact GUI, drag on heading to reposition. Otherwise, double click to maximize
- If A_GuiEvent = DoubleClick
- {
- WinGetPos GUI3X, GUI3Y, , , Foreign Characters - MIN ahk_class AutoHotkeyGUI ; Gets current position of full GUI so compact GUI is in same place
- Gui, 3: Destroy
- Gui, 1: Show, NoActivate x%GUI3X% y%GUI3Y%, Foreign Characters
- Return
- }
- PostMessage, 0xA1, 2,,, A
- return
- SendChar: ; Send character upon button press.
- Gui, 1: Hide ; This currently works by 'hiding' the GUI (reactivating window below it), then sending the character, and bringing the GUI back.
- SendInput %A_GuiControl%
- Gui, 1: Show, NoActivate
- return
- Reposition: ; Upon script start, reposition in bottom-right corner, above start menu bar.
- WinGetPos X, Y, Width, Height, Foreign Characters ahk_class AutoHotkeyGUI
- MaxY := SizeBottom - Height
- MaxX := SizeRight - Width - IndentFromRight
- WinMove Foreign Characters ahk_class AutoHotkeyGUI, , %MaxX%, %MaxY%
- return
- ;========== SHORTCUTS ==========
- ;========== EXIT SCRIPT ==========
- ; Close script by activating the GUI and pressing Esc, or simply press 'Close' buttons.
- GuiEscape:
- 2GuiEscape:
- Close:
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment