SHARE
TWEET

Untitled

a guest Dec 14th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/env python
  2. #  -*- coding: utf-8 -*-
  3.  
  4. """
  5. CONFIG SECTION
  6. =====
  7. """
  8.  
  9. #Debug:
  10. Debug = False #Debug Mode, used for Output of Debug Info.
  11. Debug_Movement = False #If Debug Mode is On, output Mouse Movement Info.
  12. Debug_Buttons = False #If Debug Mode is On, output Mouse Button Activity.
  13. Debug_Wheel = False #If Debug Mode is On, output Mouse Wheel Movement Info.
  14. Debug_Keyboard = False #If Debug Mode is On, output Keyboard Activity.
  15.  
  16. #Macro Keybinds
  17. Keybind_Enable = "middle" #Key to Enable/Disable the Macro.
  18. Keybind_Crouch = "p"
  19. Keybind_Heal = "y"
  20.  
  21. #Ingame Keybinds
  22. Ingame_Keybind_Crouch = "c"
  23. Ingame_Keybind_Jump = "space"
  24.  
  25. """
  26. =====
  27. END CONFIG SECTION
  28. """
  29. #Imports:
  30.  
  31. #Timing and Delays
  32. from time import gmtime, strftime, sleep, time, asctime
  33.  
  34. #C Types and Interfaces
  35. from ctypes import windll, c_uint, Structure, c_long, byref
  36.  
  37. #Win32API for hardware level mouse and keyboard reading
  38. from win32api import GetKeyState, GetAsyncKeyState, Beep
  39. import sys, os
  40.  
  41. #Mouse and Keyboard for Virtual Mouse Control
  42. import mouse
  43. import keyboard
  44.  
  45.  
  46. #Globals:
  47. global Running #Macro is Running
  48. global Enabled #Macro is Enabled
  49. global Crouched #Player is Crouching
  50.  
  51.  
  52. #Debugging:
  53.  
  54. #Debug PrintFunction: Print's Debug Output if Debug is Enabled.
  55. def DebugPrint(s):
  56.     if Debug:
  57.         print("{0}:{1}".format(strftime("%H:%M:%S", gmtime()),s));
  58.    
  59.    
  60. def DebugPrintGlobals():
  61.     for k, v in globals().items():
  62.         print("{0} = {1}".format(k, v))
  63.        
  64.  
  65. #Main Function: Gets run at start after init.
  66. def main():
  67.     #Debug;
  68.    
  69.     # Print out a List of the Globals to Check Inits.
  70.     DebugPrint('Debug-General: Printing Globals List:')
  71.     DebugPrintGlobals()
  72.    
  73.     #Hooks;
  74.    
  75.     #Hook Logical Mouse Events.
  76.     DebugPrint('Debug-General: Hooking Mouse Input')
  77.     mouse.hook(Mouse_Input)
  78.    
  79.     #Hook Logical Keyboard Events.
  80.     DebugPrint('Debug-General: Hooking Keyboard Input')
  81.     keyboard.hook(Keyboard_Input)
  82.    
  83.     # Stop Script from Ending
  84.     input("Script Loaded!!!\nPress Enable Key to Start the Script\n")
  85.  
  86.  
  87. #Toggle the Script On/Off
  88. def Toggle_Enabled():
  89.     global Enabled
  90.     if Enabled:
  91.         Enabled = False
  92.     else:
  93.         Enabled = True
  94.     print("{0}:Debug-General: Enabled changed to {1}".format(strftime("%H:%M:%S", gmtime()),Enabled));
  95.    
  96.    
  97. def Handle_MB2_Down():
  98.     DebugPrint("Debug-Weapon: MB2 UP Event Detected")
  99.     keyboard.press_and_release('l')
  100.    
  101.    
  102. #Mouse Hook Callback Function: Gets run when Mouse activity is detected.
  103. def Mouse_Input(Mouse_Event):
  104.     if Running:
  105.         #Mouse Wheel Event.
  106.         if type(Mouse_Event) == mouse._mouse_event.MoveEvent:
  107.             if Debug_Movement:
  108.                 DebugPrint("Debug-Mouse_Move: Move_Event: x:{0}, y:{1}, Time:{2}".format(Mouse_Event.x, Mouse_Event.y, Mouse_Event.time))
  109.        
  110.         #Mouse Button Event.
  111.         if type(Mouse_Event) == mouse._mouse_event.ButtonEvent:
  112.             if Debug_Buttons:
  113.                 DebugPrint("Debug-Mouse_Buttons: Button_Event: Type:{0}, Button:{1}, Time:{2}".format(Mouse_Event.event_type, Mouse_Event.button, Mouse_Event.time))
  114.            
  115.             # Handle ADS
  116.             if Mouse_Event.event_type == "up" and Mouse_Event.button == "right" and Enabled:
  117.                 Handle_MB2_Down()
  118.  
  119.             #Handle Enable Event
  120.             elif Mouse_Event.event_type == "down" and Mouse_Event.button == Keybind_Enable:
  121.                 Toggle_Enabled()
  122.                
  123. #Bhop Macro V0.1
  124. def bhop():
  125.     keyboard.press_and_release(Ingame_Keybind_Jump)
  126.     sleep(0.020)
  127.     keyboard.press_and_release(Ingame_Keybind_Jump)
  128.     sleep(0.020)
  129.     keyboard.release(Ingame_Keybind_Jump)
  130.  
  131.  
  132. #Keyboard Hook Callback Function: Gets run when Keyboard activity is detected.    
  133. def Keyboard_Input(Keyboard_Event):
  134.     global Crouched
  135.     global CrouchedTimestamp
  136.    
  137.     if type(Keyboard_Event) == keyboard._keyboard_event.KeyboardEvent:
  138.         if Debug_Keyboard:
  139.             DebugPrint("Debug-Keyboard_Event: Key:{0},Scancode:{1}, Action:{2},Modifier:{3} Time:{4}".format(Keyboard_Event.name,Keyboard_Event.scan_code, Keyboard_Event.event_type, Keyboard_Event.modifiers, Keyboard_Event.time))
  140.        
  141.         #Handle Crouch Key
  142.         if Keyboard_Event.event_type == "down" and Keyboard_Event.name == Keybind_Crouch and Enabled:
  143.             if Crouched == False:
  144.                 CrouchedTimestamp = time()
  145.                 Crouched = True
  146.             else:
  147.               DebugPrint("Debug-bhop: Time Elapsed:{0}".format(time() - CrouchedTimestamp))
  148.            
  149.             #Hold Delay before start bhopping
  150.             if time() - CrouchedTimestamp > 0.15:
  151.                 bhop()
  152.        
  153.         elif Keyboard_Event.event_type == "up" and Keyboard_Event.name == Keybind_Crouch and Enabled:
  154.             Crouched = False
  155.            
  156.         #Behop on Med Use
  157.         elif Keyboard_Event.event_type == "down" and Keyboard_Event.name == Keybind_Heal and Enabled:
  158.             bhop()
  159.        
  160. #Detect if we are being run
  161. if __name__ == '__main__':
  162.    
  163.     #Output Info to Message Box
  164.     DebugPrint('Debug-General: Starting Script\n')
  165.     DebugPrint('Debug-General: Initalizing Globals\n')
  166.    
  167.     Running = True
  168.     Enabled = False
  169.     Crouched = False
  170.     CrouchedTimestamp = 0
  171.    
  172.     try:
  173.         main() #Start Script.
  174.         DebugPrint("Debug-General: Exiting Script") #After Script is finished I.E on Exit, Log the Event.
  175.         try:
  176.             sys.exit(0)
  177.            
  178.         except SystemExit:
  179.             os._exit(0)
  180.        
  181.     except ValueError:
  182.         print("Error: Could not Run Script")
  183.        
  184.     except KeyboardInterrupt:
  185.         print('Interrupted')
  186.        
  187.         try:
  188.             sys.exit(0)
  189.            
  190.         except SystemExit:
  191.             os._exit(0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top