Advertisement
WolfieMario

SignBuilder.ahk

Jun 3rd, 2014
1,206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  /*===================================================================================*\
  2.  |                         Sign Builder script by WolfieMario                          |
  3.  |   Feel free to use for Minecraft or other purposes, and feel free to make changes.  |
  4.  |   I would appreciate if you do not remove this notice if distributing this script.  |
  5.  |          I am not liable for any way in which you use or abuse this script.         |
  6.  \*=================================================================================\  /
  7.                                                                                      */
  8. ; You can pre-set lines of text for the script to use here.
  9. ; Put text inside the quotes only. It can be changed later with Alt+I.
  10. global line1 := ""
  11. global line2 := ""
  12. global line3 := ""
  13. global line4 := ""
  14.  
  15. ; If you game is slow and Alt+B (Build Sign) does not work, make this number bigger.
  16. global delayStep := 70
  17. ; Its default value is 70.
  18.  
  19.                             /*==============================*\
  20.                            /     Script Command Reference     \                        
  21. /===============v==========^==================================^=========================\
  22. |    Hotkeys    |                              Description                              |
  23. |---------------|-----------------------------------------------------------------------|
  24. |     Alt+I     |              Input lines of text to be typed onto signs.              |
  25. |     Alt+T     |    Type stored lines of text onto sign (have sign interface open).    |
  26. |     Alt+V     |    Type text from clipboard into game (allows "pasting" on signs).    |
  27. |     Alt+B     |      Build Sign: Place a sign, type all stored text, and confirm.     |
  28. \===============^=======================================================================/
  29.  |_____       Everything beyond this is actual code. Play at your own risk!            |
  30.  \    /================================================================================/
  31.   \  /
  32.    */
  33.  
  34. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  35. #Warn  ; Recommended for catching common errors.
  36.  
  37. ; Prevents script from interfering with (most) non-Minecraft windows
  38. GroupAdd, Minecraft, ahk_class SunAwtFrame  ; Minecraft 1.5.2 and earlier
  39. GroupAdd, Minecraft, ahk_class LWJGL        ; Minecraft 1.6 and later
  40. #IfWinActive ahk_group Minecraft
  41. #MaxThreadsPerHotkey 2
  42. global hasText := !textEmpty()
  43. global guiButtonPressed
  44.  
  45. !I:: inputText()
  46.  
  47. !T:: typeText()
  48. !V:: SendInput %Clipboard%
  49. !B:: buildSign()
  50.  
  51. buildSign()
  52. {
  53.     Click Right
  54.     Sleep delayStep
  55.    
  56.     if(hasText) ;Is there any text to put on the signs?
  57.     {
  58.         typeText()
  59.         Sleep delayStep
  60.     }
  61.     SendInput {Escape}
  62. }
  63.  
  64. typeText()
  65. {
  66.     SendInput {Raw}%line1%
  67.     SendInput {Down}
  68.     SendInput {Raw}%line2%
  69.     SendInput {Down}
  70.     SendInput {Raw}%line3%
  71.     SendInput {Down}
  72.     SendInput {Raw}%line4%
  73. }
  74.  
  75. inputText()
  76. {
  77.     static popupWidth := 220
  78.     static inputWidth := 170
  79.     static inputOffset := (popupWidth - inputWidth) / 2
  80.     static buttonWidth := 75
  81.     static buttonOffset := (popupWidth - buttonWidth * 2 - 6) / 2
  82.    
  83.     Gui New, +LastFound, Input Sign Text
  84.     Gui Add, Text, Center W%popupWidth% X0 Y10, Input lines of text for sign (max 15 char/line):
  85.     Gui Font, S12, Courier New Bold
  86.     Loop, 4
  87.     {
  88.         Gui Add, Edit, % "Vline" . A_Index . " Limit15 Center 0x200 wp" . (A_Index = 1 ? " Y+10 W" . inputWidth . " X" . inputOffset : ""), % line%A_Index%
  89.     }
  90.     Gui Font
  91.     Gui Add, Button, gGuiSubmit Default W%buttonWidth% X%buttonOffset%, OK
  92.     Gui Add, Button, gGuiClose W%buttonWidth% yp X+6, Cancel
  93.     Gui Show, W%popupWidth%
  94.     WinWaitClose % "AHK_ID " WinExist()
  95.     hasText := !textEmpty()
  96. }
  97.  
  98. textEmpty()
  99. {
  100.     return line1 = "" and line2 = "" and line3 = "" and line4 = ""
  101. }
  102.  
  103. GuiSubmit:
  104.     guiButtonPressed := A_GuiControl
  105.     Gui Submit
  106. Return
  107.  
  108. GuiClose:
  109. GuiEscape:
  110.     guiButtonPressed := "Close"
  111.     Gui Cancel
  112. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement