Advertisement
WolfieMario

SignBuilder Classic.ahk

Jun 4th, 2014
926
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. line1 := ""
  11. line2 := ""
  12. line3 := ""
  13. line4 := ""
  14.  
  15. ; If you game is slow and Alt+B (Build Sign) does not work, make this number bigger.
  16. 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. hasText := !textEmpty()
  43.  
  44. !I:: inputText()
  45.  
  46. !T:: typeText()
  47. !V:: SendInput %Clipboard%
  48. !B:: buildSign()
  49.  
  50. buildSign()
  51. {
  52.     global delayStep, hasText
  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.     global line1, line2, line3, line4
  67.     SendInput {Raw}%line1%
  68.     SendInput {Down}
  69.     SendInput {Raw}%line2%
  70.     SendInput {Down}
  71.     SendInput {Raw}%line3%
  72.     SendInput {Down}
  73.     SendInput {Raw}%line4%
  74. }
  75.  
  76. inputText()
  77. {
  78.     global hasText
  79.     static popupWidth := 220
  80.     static inputWidth := 170
  81.     static inputOffset := (popupWidth - inputWidth) / 2
  82.     static buttonWidth := 75
  83.     static buttonOffset := (popupWidth - buttonWidth * 2 - 6) / 2
  84.    
  85.     Gui New, +LastFound, Input Sign Text
  86.     Gui Add, Text, Center W%popupWidth% X0 Y10, Input lines of text for sign (max 15 char/line):
  87.     Gui Font, S12, Courier New Bold
  88.     Loop, 4
  89.     {
  90.         Gui Add, Edit, % "Vline" . A_Index . " Limit15 Center 0x200 wp" . (A_Index = 1 ? " Y+10 W" . inputWidth . " X" . inputOffset : ""), % line%A_Index%
  91.     }
  92.     Gui Font
  93.     Gui Add, Button, gGuiSubmit Default W%buttonWidth% X%buttonOffset%, OK
  94.     Gui Add, Button, gGuiClose W%buttonWidth% yp X+6, Cancel
  95.     Gui Show, W%popupWidth%
  96.     WinWaitClose % "AHK_ID " WinExist()
  97.     hasText := !textEmpty()
  98. }
  99.  
  100. textEmpty()
  101. {
  102.     global line1, line2, line3, line4
  103.     return line1 = "" and line2 = "" and line3 = "" and line4 = ""
  104. }
  105.  
  106. GuiSubmit:
  107.     guiButtonPressed := A_GuiControl
  108.     Gui Submit
  109. Return
  110.  
  111. GuiClose:
  112. GuiEscape:
  113.     guiButtonPressed := "Close"
  114.     Gui Cancel
  115. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement