Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. #SingleInstance, Force
  2. #NoEnv
  3. SetBatchLines, -1
  4. #Include Resources\Gdip_All.ahk
  5. #Include Resources\Gdip_Ext.ahk
  6.  
  7. If !pToken := Gdip_Startup()
  8. {
  9. MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
  10. ExitApp
  11. }
  12. OnExit, Exit
  13.  
  14. Width:=800, height:=800
  15. Gui,1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
  16. Gui, 1: Add, Edit, w%Width% h20 y300, vMeEdit
  17. Gui,1: Show, NA
  18.  
  19. hwnd1 := WinExist()
  20. hbm := CreateDIBSection(Width, Height)
  21. hdc := CreateCompatibleDC()
  22. obm := SelectObject(hdc, hbm)
  23. G := Gdip_GraphicsFromHDC(hdc)
  24. Gdip_SetSmoothingMode(G, 4)
  25. pBrush := Gdip_BrushCreateSolid(0x00000000)
  26. Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 0)
  27. Gdip_DeleteBrush(pBrush)
  28.  
  29. ;--- CHANGING VARIABLES
  30. FontName = Gotham
  31. Fontsize2 := 17
  32. Fontsize .= "s"+Fontsize2
  33. cName :="Nosta"
  34. cGuild := "<Gobelins>"
  35. charRace := "Briton"
  36. charClass := "Friar"
  37. charLevel := "Lvl 50"
  38. charRanklevel := "R1L7"
  39.  
  40. FontSizes := [Fontsize2]
  41. ; Measure text width
  42. For Each, Size in FontSizes {
  43. T := MeasureText(charRace, "s" . Size, FontName)
  44. XW1 := T.W
  45. }
  46.  
  47. For Each, Size in FontSizes {
  48. T := MeasureText(charClass, "s" . Size, FontName)
  49. XW2 := T.W
  50. }
  51. For Each, Size in FontSizes {
  52. T := MeasureText(charLevel, "s" . Size, FontName)
  53. XW3 := T.W
  54. }
  55.  
  56. For Each, Size in FontSizes {
  57. T := MeasureText(charRankLevel, "s" . Size, FontName)
  58. XW4 := T.W
  59. }
  60.  
  61. if (FontName = "Tahoma")
  62. {
  63. xwI := 1.3
  64. }
  65. else if (FontName = "Verdana")
  66. {
  67. x1 := Fontsize2*1.85
  68. xwI := 1.5
  69. }
  70. else if ((FontName = "Arial") or (FontName = "Trebuchet MS") or (FontName = "Ubuntu Mono"))
  71. {
  72. xwI := 1.6
  73. }
  74. else if ((FontName = "Segoe UI") or (FontName = "Bariol") or (FontName = "Montserrat"))
  75. {
  76. xwI := 1.9
  77. }
  78. else if ((FontName = "Noto Sans UI") or (FontName = "Overpass"))
  79. {
  80. xwI := 2.2
  81. }
  82. else if (FontName = "Gotham")
  83. {
  84. xwI := 2.9
  85. }
  86. else
  87. {
  88. xwI := 100.5
  89. }
  90. XW1_1 := (XW1/2)-(0.5*Fontsize2)
  91. if (XW1 > XW2)
  92. XW2_2 := (FontSize2/xwI)+(((XW2/2)+(0.5*Fontsize2))-((XW2+XW1)*0.1008))
  93. else if (XW1 <= XW2)
  94. XW2_2 := (FontSize2/xwI)+((XW2/2)+(0.5*Fontsize2)-((XW2+XW1)*0.1008))
  95.  
  96. XW3_1 := (XW3/2)-(0.5*Fontsize2)
  97. if (XW3 > XW4)
  98. XW4_2 := (FontSize2/xwI)+(((XW4/2)+(0.5*Fontsize2))-((XW4+XW3)*0.1008))
  99. else if (XW3 <= XW4)
  100. XW4_2 := (FontSize2/xwI)+((XW4/2)+(0.5*Fontsize2)-((XW4+XW3)*0.1008))
  101.  
  102. X1_0 := ((XWI/2)-(0.5*Fontsize2))
  103. y:=0
  104. Options = x%X1_0% y%y% w90p Center Bold cFFff0000 ow1 ocFF000000 r4 %Fontsize%
  105. Gdip_TextToGraphics2(G, cName, Options , FontName, Width, Height)
  106.  
  107. y:=Fontsize2
  108. Options = x%X1_0% y%y% w90p Center cFFd60000 ow1 ocFF000000 r4 %Fontsize%
  109. Gdip_TextToGraphics2(G, cGuild, Options , FontName, Width, Height)
  110.  
  111. y:=Fontsize2*2
  112. Options = x-%XW4_2% y%y% w90p Center cFFd60000 ow1 ocFF000000 r4 %Fontsize%
  113. Gdip_TextToGraphics2(G,charLevel, Options , FontName, Width, Height)
  114. Options = x%XW3_1% y%y% w90p Center Bold cFFff0000 ow1 ocFF000000 r4 %Fontsize%
  115. Gdip_TextToGraphics2(G,charRankLevel, Options , FontName, Width, Height)
  116.  
  117. y:=Fontsize2*3
  118. Options = x-%XW2_2% y%y% w90p Center cFFd60000 ow1 ocFF000000 r4 %Fontsize%
  119. Gdip_TextToGraphics2(G,charRace, Options , FontName, Width, Height)
  120. Options = x%XW1_1% y%y% w90p Center Bold cFFff0000 ow1 ocFF000000 r4 %Fontsize%
  121. Gdip_TextToGraphics2(G,charClass, Options , FontName, Width, Height)
  122.  
  123. UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)
  124.  
  125. OnMessage(0x201, "WM_LBUTTONDOWN")
  126.  
  127. ; Select the object back into the hdc
  128. SelectObject(hdc, obm)
  129.  
  130. ; Now the bitmap may be deleted
  131. DeleteObject(hbm)
  132.  
  133. ; Also the device context related to the bitmap may be deleted
  134. DeleteDC(hdc)
  135.  
  136. ; The graphics may now be deleted
  137. Gdip_DeleteGraphics(G)
  138.  
  139.  
  140. WM_LBUTTONDOWN()
  141. {
  142. PostMessage, 0xA1, 2
  143. }
  144. Return
  145.  
  146. MeasureText(Str, FontOpts = "", FontName = "") {
  147. Static DT_FLAGS := 0x0520 ; DT_SINGLELINE = 0x20, DT_NOCLIP = 0x0100, DT_CALCRECT = 0x0400
  148. Static WM_GETFONT := 0x31
  149. Size := {}
  150. Gui, New
  151. If (FontOpts <> "") || (FontName <> "")
  152. Gui, Font, %FontOpts%, %FontName%
  153. Gui, Add, Text, hwndHWND
  154. SendMessage, WM_GETFONT, 0, 0, , ahk_id %HWND%
  155. HFONT := ErrorLevel
  156. HDC := DllCall("User32.dll\GetDC", "Ptr", HWND, "Ptr")
  157. DllCall("Gdi32.dll\SelectObject", "Ptr", HDC, "Ptr", HFONT)
  158. VarSetCapacity(RECT, 16, 0)
  159. DllCall("User32.dll\DrawText", "Ptr", HDC, "Str", Str, "Int", -1, "Ptr", &RECT, "UInt", DT_FLAGS)
  160. DllCall("User32.dll\ReleaseDC", "Ptr", HWND, "Ptr", HDC)
  161. Gui, Destroy
  162. Size.W := NumGet(RECT, 8, "Int")
  163. Size.H := NumGet(RECT, 12, "Int")
  164. Return Size, W
  165. }
  166.  
  167. ;#######################################################################
  168.  
  169. Exit:
  170. ExitApp
  171. Return
  172.  
  173. Esc::
  174. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement