Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- CONFIG SECTION
- =====
- """
- #Debug:
- Debug = False #Debug Mode, used for Output of Debug Info.
- Debug_Movement = False #If Debug Mode is On, output Mouse Movement Info.
- Debug_Buttons = False #If Debug Mode is On, output Mouse Button Activity.
- Debug_Wheel = False #If Debug Mode is On, output Mouse Wheel Movement Info.
- Debug_Keyboard = False #If Debug Mode is On, output Keyboard Activity.
- #Macro Keybinds
- Keybind_Enable = "middle" #Key to Enable/Disable the Macro.
- Keybind_Crouch = "p"
- Keybind_Heal = "y"
- #Ingame Keybinds
- Ingame_Keybind_Crouch = "c"
- Ingame_Keybind_Jump = "space"
- """
- =====
- END CONFIG SECTION
- """
- #Imports:
- #Timing and Delays
- from time import gmtime, strftime, sleep, time, asctime
- #C Types and Interfaces
- from ctypes import windll, c_uint, Structure, c_long, byref
- #Win32API for hardware level mouse and keyboard reading
- from win32api import GetKeyState, GetAsyncKeyState, Beep
- import sys, os
- #Mouse and Keyboard for Virtual Mouse Control
- import mouse
- import keyboard
- #Globals:
- global Running #Macro is Running
- global Enabled #Macro is Enabled
- global Crouched #Player is Crouching
- #Debugging:
- #Debug PrintFunction: Print's Debug Output if Debug is Enabled.
- def DebugPrint(s):
- if Debug:
- print("{0}:{1}".format(strftime("%H:%M:%S", gmtime()),s));
- def DebugPrintGlobals():
- for k, v in globals().items():
- print("{0} = {1}".format(k, v))
- #Main Function: Gets run at start after init.
- def main():
- #Debug;
- # Print out a List of the Globals to Check Inits.
- DebugPrint('Debug-General: Printing Globals List:')
- DebugPrintGlobals()
- #Hooks;
- #Hook Logical Mouse Events.
- DebugPrint('Debug-General: Hooking Mouse Input')
- mouse.hook(Mouse_Input)
- #Hook Logical Keyboard Events.
- DebugPrint('Debug-General: Hooking Keyboard Input')
- keyboard.hook(Keyboard_Input)
- # Stop Script from Ending
- input("Script Loaded!!!\nPress Enable Key to Start the Script\n")
- #Toggle the Script On/Off
- def Toggle_Enabled():
- global Enabled
- if Enabled:
- Enabled = False
- else:
- Enabled = True
- print("{0}:Debug-General: Enabled changed to {1}".format(strftime("%H:%M:%S", gmtime()),Enabled));
- def Handle_MB2_Down():
- DebugPrint("Debug-Weapon: MB2 UP Event Detected")
- keyboard.press_and_release('l')
- #Mouse Hook Callback Function: Gets run when Mouse activity is detected.
- def Mouse_Input(Mouse_Event):
- if Running:
- #Mouse Wheel Event.
- if type(Mouse_Event) == mouse._mouse_event.MoveEvent:
- if Debug_Movement:
- DebugPrint("Debug-Mouse_Move: Move_Event: x:{0}, y:{1}, Time:{2}".format(Mouse_Event.x, Mouse_Event.y, Mouse_Event.time))
- #Mouse Button Event.
- if type(Mouse_Event) == mouse._mouse_event.ButtonEvent:
- if Debug_Buttons:
- DebugPrint("Debug-Mouse_Buttons: Button_Event: Type:{0}, Button:{1}, Time:{2}".format(Mouse_Event.event_type, Mouse_Event.button, Mouse_Event.time))
- # Handle ADS
- if Mouse_Event.event_type == "up" and Mouse_Event.button == "right" and Enabled:
- Handle_MB2_Down()
- #Handle Enable Event
- elif Mouse_Event.event_type == "down" and Mouse_Event.button == Keybind_Enable:
- Toggle_Enabled()
- #Bhop Macro V0.1
- def bhop():
- keyboard.press_and_release(Ingame_Keybind_Jump)
- sleep(0.020)
- keyboard.press_and_release(Ingame_Keybind_Jump)
- sleep(0.020)
- keyboard.release(Ingame_Keybind_Jump)
- #Keyboard Hook Callback Function: Gets run when Keyboard activity is detected.
- def Keyboard_Input(Keyboard_Event):
- global Crouched
- global CrouchedTimestamp
- if type(Keyboard_Event) == keyboard._keyboard_event.KeyboardEvent:
- if Debug_Keyboard:
- 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))
- #Handle Crouch Key
- if Keyboard_Event.event_type == "down" and Keyboard_Event.name == Keybind_Crouch and Enabled:
- if Crouched == False:
- CrouchedTimestamp = time()
- Crouched = True
- else:
- DebugPrint("Debug-bhop: Time Elapsed:{0}".format(time() - CrouchedTimestamp))
- #Hold Delay before start bhopping
- if time() - CrouchedTimestamp > 0.15:
- bhop()
- elif Keyboard_Event.event_type == "up" and Keyboard_Event.name == Keybind_Crouch and Enabled:
- Crouched = False
- #Behop on Med Use
- elif Keyboard_Event.event_type == "down" and Keyboard_Event.name == Keybind_Heal and Enabled:
- bhop()
- #Detect if we are being run
- if __name__ == '__main__':
- #Output Info to Message Box
- DebugPrint('Debug-General: Starting Script\n')
- DebugPrint('Debug-General: Initalizing Globals\n')
- Running = True
- Enabled = False
- Crouched = False
- CrouchedTimestamp = 0
- try:
- main() #Start Script.
- DebugPrint("Debug-General: Exiting Script") #After Script is finished I.E on Exit, Log the Event.
- try:
- sys.exit(0)
- except SystemExit:
- os._exit(0)
- except ValueError:
- print("Error: Could not Run Script")
- except KeyboardInterrupt:
- print('Interrupted')
- try:
- sys.exit(0)
- except SystemExit:
- os._exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement