dlaso

Foreign Characters (Polish, French, Etc)

Apr 14th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 KB | None | 0 0
  1. ;=============================================
  2. ; Foreign Characters GUI
  3. ;=============================================
  4. ; This script creates a graphical user interface (GUI) for easily inputting foreign Characters
  5. ;
  6. ; =Usage=
  7. ; Run the script, select the language to use, and you will see a menu with all the relevant characters.
  8. ; This script will always stay on top of other windows.
  9. ; While typing in your working document, click the respective character button to input it.
  10. ;
  11. ; =Features=
  12. ; Currently supports Polish, Italian, Spanish and German characters
  13. ; Click and drag language name to reposition the GUI
  14. ; Double-click language name to 'minimise'/'restore' the GUI
  15. ;
  16. ;=Notes=
  17. ; To add a new language/character set, you must:
  18. ; 1. Add a new character set. Call it "FrenchChars" for example, and include all relevant symbols (separated by commas, no spaces).
  19. ; 2. Add a new language button in the selection menu (========== Select Language GUI ==========)
  20. ; 3. Increase selection menu GUI height
  21. ; 4. Add a new subroutine to link to the button. Make sure to change the 'Language' variable accordingly.
  22. ; 5.
  23. ; 6.
  24. ; 7.
  25. ;
  26. ;=============================================
  27.  
  28. #SingleInstance Force
  29. #Persistent
  30. SysGet, Size, MonitorWorkArea
  31. SetTitleMatchMode, 2
  32.  
  33. ;========== Can Change These ==========
  34.  
  35. ; CHARACTER SETS
  36. PolishChars = Ą,ą,Ć,ć,Ę,ę,Ł,ł,Ń,ń,Ó,ó,Ś,ś,Ż,ż,Ź,ź,«,»,€,zł,–,—,„,”
  37. FrenchChars = À,à,Â,â,Æ,æ,Ç,ç,É,é,È,è,Ê,ê,Ë,ë,Ï,ï,Î,î,Ô,ô,Œ,œ,Ù,ù,Û,û,Ü,ü,Ÿ,ÿ,€,$,«,»,–,—
  38. ItalianChars = À,à,È,è,É,é,Ì,ì,Ò,ò,Ó,ó,Ù,ù,«,»,$,€
  39. SpanishChars = Á,á,É,é,Í,í,Ñ,ñ,Ó,ó,Ú,ú,Ü,ü,¿,¡,€,$,«,»,–,—
  40. GermanChars = Ä,ä,Ö,ö,Ü,ü,ß,€
  41.  
  42.  
  43. ; POSITIONING
  44. XPos1 = 5
  45. XPos2 = 40
  46. GuiWidth = 75
  47. GuiRight := SizeRight - 150
  48.  
  49. SelectLanguageButtonSpacing = 5
  50.  
  51. ;========== Select Language GUI ==========
  52. YGUI2 := SelectLanguageButtonSpacing
  53. Gui, 2: Color, cFFFFFF
  54. Gui, 2: Font, w700 c000000 s10
  55. Gui, 2: Add, Text, w130 h20 x0 y5 Center, Select Language
  56. Gui, 2: Font, w400 cFFFFFF s10
  57. 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)
  58. Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gFrench, French
  59. Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gItalian, Italian
  60. Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gSpanish, Spanish
  61. Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gGerman, German ; To add new languages, add them under here, copying similar format
  62. Gui, 2: Font, w600 c000000 s10
  63. Gui, 2: Add, Button, w120 h20 x5 y+%YGUI2% gClose, Close
  64. Gui, 2: +AlwaysOnTop -Caption +ToolWindow +Border
  65. Gui, 2: Show, w130 h180, Select Language ; If you add extra languages, increase height by 25
  66. return
  67.  
  68. Polish:
  69. Language = Polish
  70. Gosub ForeignChars
  71. return
  72.  
  73. French:
  74. Language = French
  75. Gosub ForeignChars
  76. return
  77.  
  78. Italian:
  79. Language = Italian
  80. Gosub ForeignChars
  81. return
  82.  
  83. Spanish:
  84. Language = Spanish
  85. Gosub ForeignChars
  86. return
  87.  
  88. German: ; If you add a new language button, make sure to create a subroutine here which changes the "Language" variable. Copy this format.
  89. Language = German
  90. Gosub ForeignChars
  91. return
  92.  
  93. ;========== SHOULDN'T NEED TO CHANGE MUCH FROM HERE==========
  94.  
  95. ;========== Foreign Characters GUI ==========
  96.  
  97. ForeignChars:
  98. Gui, 2: Destroy
  99. YPos = 5
  100. Gui, 1: Color, cFFFFFF ; GUI Background Colour
  101. Gui, 1: Font, w700 c000000 s12 ; Heading colour, size and bold
  102. Gui, 1: Add, Text, w%GuiWidth% h20 x0 y%YPos% Center gDragFull, %Language% ; Heading - i.e. "Polish". Also can drag on heading to reposition.
  103. YPos += 25
  104. Gui, 1: Font, w400 cFFFFFF ; Button colour (inside loop)
  105. Loop, parse, %Language%Chars, `, ; Parse each character as a separate variable
  106. {
  107. Character = %A_LoopField%
  108. Pos1:=!Pos1
  109. If Pos1
  110. {
  111. Gui, 1: Add, Button, w30 h30 x%XPos1% y%YPos% gSendChar, %Character% ; Add a button for each character
  112. }
  113. else
  114. {
  115. Gui, 1: Add, Button, w30 h30 x%XPos2% y%YPos% gSendChar, %Character% ; Add a button for each character
  116. YPos += 35
  117. }
  118. }
  119. Gui, 1: Font, w600 c000000 s10
  120. Gui, 1: Add, Button, w65 h20 x%XPos1% y%YPos% gClose, Close ; Close button
  121. YPos += 25
  122. GuiBottom := SizeBottom - YPos - 90
  123. ;
  124. Gui, 1: +AlwaysOnTop -Caption +Border ; Removed +ToolWindow
  125. Gui, 1: Show, NoActivate w%GuiWidth% h%YPos% x%GuiRight% y%GuiBottom%, Foreign Characters
  126. Gosub Reposition
  127. return
  128.  
  129. DragFull: ; When full GUI, drag on heading to reposition. Otherwise, double click to minimize
  130. If A_GuiEvent = DoubleClick
  131. {
  132. GoSub Minimized
  133. Return
  134. }
  135. PostMessage, 0xA1, 2,,, A
  136. return
  137.  
  138. Minimized: ; Show minimized/compact GUI. Only shows Language heading and 'Close' button
  139. WinGetPos GUI1X, GUI1Y, , , Foreign Characters ahk_class AutoHotkeyGUI ; Gets position of full GUI so compact GUI will be in the same place.
  140. Gui, 1: Hide ; Hides full GUI, in order to show compact GUI
  141. Gui, 3: Color, cFFFFFF ; GUI Background Colour
  142. Gui, 3: Font, w700 c000000 s12 ; Heading Colour
  143. Gui, 3: Add, Text, w%GuiWidth% h20 x0 y5 Center gDragMin, %Language% ; Heading - i.e. "Polish". Can drag on heading to reposition.
  144. Gui, 3: Font, w600 c000000 s10
  145. Gui, 3: Add, Button, w65 h20 x5 y+5 gClose, Close
  146. Gui, 3: +AlwaysOnTop -Caption +Border ; Removed +ToolWindow
  147. Gui, 3: Show, NoActivate w%GuiWidth% h55 x%GUI1X% y%GUI1Y%, Foreign Characters - MIN ; Show compact GUI in same position
  148. return
  149.  
  150. DragMin: ; When compact GUI, drag on heading to reposition. Otherwise, double click to maximize
  151. If A_GuiEvent = DoubleClick
  152. {
  153. WinGetPos GUI3X, GUI3Y, , , Foreign Characters - MIN ahk_class AutoHotkeyGUI ; Gets current position of full GUI so compact GUI is in same place
  154. Gui, 3: Destroy
  155. Gui, 1: Show, NoActivate x%GUI3X% y%GUI3Y%, Foreign Characters
  156. Return
  157. }
  158. PostMessage, 0xA1, 2,,, A
  159. return
  160.  
  161. SendChar: ; Send character upon button press.
  162. Gui, 1: Hide ; This currently works by 'hiding' the GUI (reactivating window below it), then sending the character, and bringing the GUI back.
  163. SendInput %A_GuiControl%
  164. Gui, 1: Show, NoActivate
  165. return
  166.  
  167. Reposition: ; Upon script start, reposition in bottom-right corner, above start menu bar.
  168. WinGetPos X, Y, Width, Height, Foreign Characters ahk_class AutoHotkeyGUI
  169. MaxY := SizeBottom - Height
  170. MaxX := SizeRight - Width - IndentFromRight
  171. WinMove Foreign Characters ahk_class AutoHotkeyGUI, , %MaxX%, %MaxY%
  172. return
  173.  
  174.  
  175. ;========== SHORTCUTS ==========
  176.  
  177.  
  178.  
  179.  
  180. ;========== EXIT SCRIPT ==========
  181. ; Close script by activating the GUI and pressing Esc, or simply press 'Close' buttons.
  182.  
  183. GuiEscape:
  184. 2GuiEscape:
  185. Close:
  186. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment