Advertisement
deseven

capser2

Apr 1st, 2015
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Capser
  2.  
  3. #myname = "Capser"
  4. #key_pressed = -32767
  5. appname.s = GetFilePart(ProgramFilename())
  6. Global n.INPUT
  7. n\type = #INPUT_KEYBOARD
  8. #num_stuff = 10
  9. Global stuff.s = " ^__^ | *~~^__^~~* | :-* | xD | <3 | :) |!!1 |!?? |))) |. "
  10.  
  11. Procedure toggleCaps()
  12.   n\ki\wVk = #VK_CAPITAL : n\ki\dwFlags = 0
  13.   SendInput_(1,@n,SizeOf(n))
  14.   n\ki\dwFlags = #KEYEVENTF_KEYUP
  15.   SendInput_(1,@n,SizeOf(n))
  16. EndProcedure
  17.  
  18. Procedure pasteStuff()
  19.   SetClipboardText(StringField(stuff,Random(#num_stuff,1),"|"))
  20.   n\ki\wVk = #VK_BACK : n\ki\dwFlags = 0
  21.   SendInput_(1,@n,SizeOf(n))
  22.   n\ki\dwFlags = #KEYEVENTF_KEYUP
  23.   SendInput_(1,@n,SizeOf(n))
  24.   n\ki\wVk = #VK_CONTROL : n\ki\dwFlags = 0
  25.   SendInput_(1,@n,SizeOf(n))
  26.   n\ki\wVk = #VK_V
  27.   SendInput_(1,@n,SizeOf(n))
  28.   n\ki\dwFlags = #KEYEVENTF_KEYUP
  29.   SendInput_(1,@n,SizeOf(n))
  30.   n\ki\wVk = #VK_CONTROL
  31.   SendInput_(1,@n,SizeOf(n))
  32. EndProcedure
  33.  
  34. Procedure keyPressed()
  35.   If GetAsyncKeyState_(#VK_SPACE) = #key_pressed : ProcedureReturn 1 : EndIf
  36.   For i=48 To 90
  37.     If GetAsyncKeyState_(i) = #key_pressed : ProcedureReturn 2 : EndIf
  38.   Next
  39.   ProcedureReturn #False
  40. EndProcedure
  41.  
  42. Procedure capser(dummy)
  43.   Repeat
  44.     Select keyPressed()
  45.       Case 1
  46.         If Random(100) > 40 : pasteStuff() : EndIf
  47.       Case 2
  48.         If Random(100) > 40 : toggleCaps() : EndIf
  49.       Default
  50.         Delay(10)
  51.     EndSelect
  52.   ForEver
  53. EndProcedure
  54.  
  55. OpenWindow(0,1,1,1,1,#myname,#PB_Window_Invisible)
  56. icon = ExtractIcon_(WindowID(0),appname,0)
  57. AddSysTrayIcon(1,WindowID(0),icon)
  58. SysTrayIconToolTip(1,#myname)
  59. CreatePopupMenu(0)
  60. MenuItem(1,#myname)
  61. DisableMenuItem(0,1,1)
  62. MenuBar()
  63. MenuItem(2,"Exit")
  64. capserThread = CreateThread(@capser(),dummy)
  65.  
  66. Repeat
  67.   ev = WaitWindowEvent()
  68.   If ev = #PB_Event_SysTray And EventType() = #PB_EventType_RightClick
  69.     DisplayPopupMenu(0,WindowID(0))
  70.   ElseIf ev = #PB_Event_Menu And EventMenu() = 2
  71.     Break
  72.   EndIf
  73. Until ev = #PB_Event_CloseWindow
  74.  
  75. KillThread(capserThread)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement