Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Strict
  2.  
  3. ' Clipboard Text - Copy/Paste functions
  4.  
  5. 'Module leadwerks.clipboard
  6. 'ModuleInfo "Version: 1.0.0"
  7. 'ModuleInfo "Author: Joshua Klint"
  8. 'ModuleInfo "www.leadwerks.com"
  9.  
  10. Import brl.pixmap
  11. Import pub.win32
  12.  
  13. Extern "Win32"
  14.     Function OpenClipboard%(hwnd%)
  15.     Function CloseClipboard%()
  16.     Function EmptyClipboard%()
  17.     Function IsClipboardFormatAvailable%(format%)
  18.     Function GetClipboardData:Byte Ptr(Format:Int)
  19.     Function SetClipboardData(format%, hMem:Byte Ptr)
  20.     Function GlobalAlloc(Flags:Int, Bytes:Int)
  21.     Function GlobalFree(Mem:Int)
  22.     Function GlobalLock:Byte Ptr(Mem:Int)
  23.     Function GlobalUnlock(Mem:Int)
  24.     Function CreateBitmap:Byte Ptr(width:Int,height:Int,colorplanes:Int,bpp:Int,data:Byte Ptr)
  25.     'Function SetFocus%(hwnd%)
  26. End Extern
  27.  
  28. Const CF_TEXT%=$1
  29. Const CF_BITMAP%=2
  30. Const GMEM_MOVEABLE%=$2
  31. Const GMEM_DDESHARE%=$2000
  32.  
  33. ' -----------------------------------------------
  34.  
  35.  
  36. AppTitle$ = "GIMP.exe"
  37. Const screenWidth:Int = 164 * 2
  38. Const screenHeight:Int = 164 * 2
  39. Graphics(screenWidth, screenHeight,0,120)
  40. Incbin "mado.png"
  41. Global mado:TImage = LoadImage("Incbin::mado.png")
  42. Incbin "madoOff.png"
  43. Global madoOff:TImage = LoadImage("Incbin::madoOff.png")
  44. Incbin "madoDouble.png"
  45. Global madoDouble:TImage = LoadImage("Incbin::madoDouble.png")
  46. Global image:TImage
  47. Global active:Int = 1
  48. Global timer:Int = 0
  49. Global randomGimp:String
  50. Global jokerFile:TStream = ReadStream("gimps.txt")
  51. Global jokerArray:String[10000]
  52. Global fileExists:Int = 0
  53. Global doubleMode:Int = 0
  54. Global bridgeArray:String[5]
  55. bridgeArray[0] = "and"
  56. bridgeArray[1] = "but"
  57. bridgeArray[2] = "or"
  58. bridgeArray[3] = "btw"
  59. bridgeArray[4] = "also"
  60.  
  61. Local tempLine:String
  62.  
  63. Local i:Int
  64. Global numJokes:Int = 0
  65.  
  66. If jokerFile
  67.     fileExists = True
  68.     For i = 0 To Len(jokerArray)
  69.         tempLine = ReadLine(jokerFile)
  70.         jokerArray[i] = tempLine
  71.         If tempLine = Null
  72.             numJokes = i
  73.             Exit
  74.         EndIf
  75.     Next
  76.     CloseFile(jokerFile)
  77. Else
  78.     active = False
  79.     fileExists = False
  80. EndIf
  81.  
  82. 'Print (jokerArray[2] + " test")
  83. 'Print (numJokes + " is num jokes")
  84.  
  85. Repeat '------------------------------------------------------------------------------------------
  86.  
  87.  
  88.     If KeyHit(KEY_LCONTROL) Or KeyHit(KEY_RCONTROL)  active = Not active
  89.     If KeyHit(KEY_LALT) Or KeyHit(KEY_RALT)  doubleMode = Not doubleMode
  90.    
  91.    
  92.     If active And fileExists
  93.         If doubleMode
  94.             image = madoDouble
  95.         Else
  96.             image = mado
  97.         EndIf
  98.     Else
  99.         image = madoOff
  100.     EndIf
  101.    
  102.     'SetFocus()
  103.    
  104.     DrawImage(image, 0,0)
  105.    
  106.     If Not fileExists
  107.         DrawText("add gimps.txt in the",0 ,0)
  108.         DrawText("same directory as GIMP.exe",0 ,16)
  109.         DrawText("fucktard",264 ,264)
  110.     EndIf
  111.  
  112.     If GetChar() End
  113.    
  114.     If AppTerminate()
  115.         End
  116.     EndIf
  117.     If KeyHit(KEY_ESCAPE) Then End
  118.    
  119.     Local randomNumber:Int = Rand(0, numJokes -1)
  120.     Local randomNumber2:Int = Rand(0, numJokes -1)
  121.  
  122.    
  123.    
  124.     If active
  125.         'If timer = 0
  126.             If doubleMode
  127.                 SetClipboardText(jokerArray[randomNumber] + " " + bridgeArray[Rand(0,4)] + " " + jokerArray[randomNumber2])
  128.             Else
  129.                 SetClipboardText(jokerArray[randomNumber] + " ")
  130.             EndIf
  131.         'EndIf
  132.         timer = timer +1
  133.         If timer > 120 Then timer = 0
  134.         'Print (jokerArray[randomNumber])
  135.     EndIf
  136.        
  137.     Flip
  138.  
  139. Forever '-----------------------------------------------------------------------------------------
  140.  
  141.  
  142.  
  143.  
  144.  
  145.    
  146. Function SetClipboardText:Int(txt:String)
  147.     'Print "setClip"
  148.     'Print txt
  149.     Local result:Int=False
  150.     If txt$="" Return
  151.     Local TextBuf:Byte Ptr = Txt.ToCString()
  152.     Local Memblock:Int = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, txt.Length+1)
  153.     Local DataBuf:Byte Ptr = GlobalLock(Memblock)
  154.     MemCopy DataBuf, TextBuf, Txt.length
  155.     If OpenClipboard(0)
  156.         EmptyClipboard
  157.         SetClipboardData CF_TEXT, DataBuf
  158.         CloseClipboard
  159.         result=True
  160.     Else
  161.         Print "failed to open clipboard."
  162.     EndIf
  163.     GlobalUnlock Memblock
  164.     GlobalFree Memblock
  165.     Return result
  166. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement