PageRenderTime 26ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/README.md

https://github.com/brigand/ahk_library
Markdown | 144 lines | 105 code | 39 blank | 0 comment | 0 complexity | aa1fb19ca918b4ef5969b75d737ca113 MD5 | raw file
  1. lordkrandel/ahk_library
  2. ================================
  3. An Autohotkey_L [http://l.autohotkey.net/] stand-alone library
  4. AHK_L has Object Oriented design, but very few object are included in the core.
  5. Included
  6. ---------------------------
  7. lib_CORE.ahk // Common functions
  8. lib_STRING.ahk // string manipulation
  9. lib_MATH.ahk // math, algebra, base change
  10. lib_LOG.ahk // logging
  11. lib_JSON.ahk // JSON parser ( requires valid json2.js source file )
  12. // [https://github.com/douglascrockford/JSON-js]
  13. lib_G.ahk // GUI classes library
  14. lib_GUI.ahk // External windows handling (stub)
  15. lib_EVENTDISPATHCER.ahk // GUI events Object Oriented handling
  16. lib_ODBC.ahk // Database connection library
  17. lib_SYNK.ahk // Utility for building auto-updating programs
  18. lib_TRAYTIP.ahk // Simple traytip library
  19. Examples
  20. ------------------------
  21. #include lib\lib_CORE.ahk
  22. #include lib\\lib_G.ahk
  23. t:= {}
  24. // Math examples ___________________________
  25. o := [ 1, 3, 6, 64, -3 ]
  26. // Min, Max
  27. t.insert( Math.max(o) ", " Math.min(o) )
  28. // First Valid
  29. t.insert( Core.firstValid( 0, "", "abba", 5 ) )
  30. // Hex functions
  31. t.insert( Math.hex(133) )
  32. t.insert( Math.fromHex(85) )
  33. // Xor
  34. fruits := { "Pear" : 5, "Orange" : 10 }
  35. if ( Math.xor( fruits["Pear"], fruits["Strawberry"] ) ) {
  36. t.insert( "There are Pears but no Strawberries" )
  37. }
  38. // String examples _________________________
  39. // Split
  40. s := "Purple,Brown,Green,Red,Yellow"
  41. o := s.split(",")
  42. p := {}
  43. for k,v in o {
  44. // Quote each element
  45. p.insert(k,v.q())
  46. }
  47. // Fmt ( sprintf ), Join, Quote with ()
  48. t.insert( "SELECT * FROM fruit WHERE color in %s;".fmt( ",".join(p).qb() ) )
  49. // Right, righttrim, toUpper
  50. t.insert( "abcdefghijklmnopqrstuvxyz".right(4).righttrim(2).toUpper() )
  51. // G examples ______________________________
  52. class SampleWindow extends g {
  53. win := { name: "Example"
  54. , title: "sampleWindow"
  55. , geom: { w : 400, h: 240 }
  56. , hotkeys: { "F2" : "f2slot" } // Defining callbacks for hotkeys
  57. , controls: { "Button1" : "close" } } // Defining callbacks for control g-labels
  58. __new(){
  59. global t
  60. g := this.win.name
  61. // Print the results of the tests
  62. Gui, %g%: Add, text, x10 y10, % "\n\n".join(["Test Results:", "\n".join(t), "Press F2 for window info"])
  63. Gui, %g%: Add, Button, x280 y200 w100 h25 gEventDispatcher, Close
  64. }
  65. f2slot(){
  66. // When F2 is pressed
  67. Msgbox, % "You just pressed F2"
  68. . "\n\n" "title: " this.win.title
  69. . "\n" "x: " this.geom.x
  70. . "\n" "y: " this.geom.y
  71. . "\n" "w: " this.geom.w
  72. . "\n" "h: " this.geom.h
  73. }
  74. close(){
  75. // On close
  76. base.close()
  77. ExitApp
  78. }
  79. }
  80. // Create and show the window
  81. ( new SampleWindow() ).show()
  82. License: Modified 3-clauses BSD
  83. -------------------------
  84. Copyright (c) 2012, Paolo Gatti, all rights reserved.
  85. https://github.com/lordkrandel/ahk_library
  86. Redistribution and use in source and binary forms, with or without
  87. modification, are permitted provided that the following conditions are met:
  88. * Redistributions of source code must retain the above copyright
  89. notice, this list of conditions and the following disclaimer.
  90. * Redistributions in binary form must reproduce the above copyright
  91. notice, this list of conditions and the following disclaimer in the
  92. documentation and/or other materials provided with the distribution.
  93. * Neither the name of the organization nor the
  94. names of its contributors may be used to endorse or promote products
  95. derived from this software without specific prior written permission.
  96. THIS SOFTWARE IS PROVIDED BY Paolo Gatti ``AS IS'' AND ANY
  97. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  98. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  99. DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  100. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  101. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  102. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  103. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  104. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  105. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.