Exemplo n.º 1
0
    def changeListenedKey(self):
        self.changingLK = True

        self.auto.stop()
        self.auto = AutoHotPy()
        self.auto.exit_configured = True

        def showDialog():
            dialog = tk.Tk()
            dialog.attributes("-topmost", True)
            tk.Label(text="Listening for new key...", padx=20, pady=20).pack()
            dialog.update()
            return dialog

        def keyPressed(a, e):
            self.auto.stop()
            for key in self.auto.keys.values():
                if key.code == e.code:
                    self.listenedKey = key
                    return

        for key in self.auto.keys.values():
            self.auto.registerForKeyDown(key, keyPressed)

        dialog = showDialog()
        self.auto.start()
        dialog.destroy()

        self.auto = AutoHotPy()
        self.auto.exit_configured = True
        self.startKL()

        self.changingLK = False

        return self.listenedKey.string_representation
Exemplo n.º 2
0
    def keyboardListener(self):
        self.auto.stop()
        self.auto = AutoHotPy()
        self.auto.exit_configured = True

        self.listenedKey = self.auto.keys[self.listenedKey.get_id()]

        self.auto.registerForKeyDown(
            self.listenedKey, lambda a, b: self.add1()
            if self.isGameActive() else self.listenedKey.press())
        self.auto.start()
Exemplo n.º 3
0
    def __init__(self, eel):
        self.eel = eel
        self.auto = AutoHotPy()

        self.changingLK = False

        self.listenedKey = self.auto.P

        if os.path.exists("counter"):
            with open('counter', 'r') as f:
                try:
                    self.counter = int(f.read())
                except:
                    self.counter = 0
        else:
            with open('counter', 'w') as f:
                self.counter = 0
                f.write(str(self.counter))

        self.lockStartingKL = False
        self.startKL()
Exemplo n.º 4
0

def leftButton(autohotpy, event):
    """
    This function simulates a left click
    """
    stroke = InterceptionMouseStroke()
    stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN
    autohotpy.sendToDefaultMouse(stroke)
    stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_UP
    autohotpy.sendToDefaultMouse(stroke)


def mouseWheel(autohotpy, event):
    stroke = InterceptionMouseState()
    stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_WHEEL
    stroke.rolling = True
    autohotpy.sendToDefaultMouse(stroke)


if __name__ == "__main__":
    auto = AutoHotPy()
    auto.registerExit(
        auto.ESC, exitAutoHotKey
    )  # Registering an end key is mandatory to be able to stop the program gracefully

    # lets switch right and left mouse buttons!
    auto.registerForKeyDown(auto.N2, press_A_key)
    #auto.registerForMouseButton(InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,mouseWheel)
    #auto.registerForMouseButton(InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,leftButton)
    auto.start()
Exemplo n.º 5
0
#WARNING: handling mouse events is harder than keyboard events.
# You have to do most things manually
from AutoHotPy import AutoHotPy
from InterceptionWrapper import InterceptionMouseState,InterceptionMouseStroke,InterceptionMouseFlag


def exitAutoHotKey(autohotpy,event):
    """
    exit the program when you press ESC
    """
    autohotpy.stop()
        
def startStopMacro(autohotpy,event):
    autohotpy.macroStartStop()
    
def fireMacro(autohotpy,event):
    autohotpy.fireLastRecordedMacro()    

def clearMacro(autohotpy,event):
    autohotpy.clearLastRecordedMacro()
    
if __name__=="__main__":
    auto = AutoHotPy()
    auto.registerExit(auto.ESC,exitAutoHotKey)   # Registering an end key is mandatory to be able tos top the program gracefully
    
    auto.registerForKeyDown(auto.F1,startStopMacro)
    auto.registerForKeyDown(auto.F2,fireMacro)
    auto.registerForKeyDown(auto.F3,clearMacro)
    
    auto.start()
Exemplo n.º 6
0
class App:
    def __init__(self, eel):
        self.eel = eel
        self.auto = AutoHotPy()

        self.changingLK = False

        self.listenedKey = self.auto.P

        if os.path.exists("counter"):
            with open('counter', 'r') as f:
                try:
                    self.counter = int(f.read())
                except:
                    self.counter = 0
        else:
            with open('counter', 'w') as f:
                self.counter = 0
                f.write(str(self.counter))

        self.lockStartingKL = False
        self.startKL()

    def saveCounterToFile(self):
        with open('counter', 'w') as f:
            f.write(str(self.counter))

    def startKL(self):
        if self.lockStartingKL:
            return False
        self.threadKL = threading.Thread(target=self.keyboardListener)
        self.threadKL.start()

    def add1(self):
        self.counter += 1
        self.eel.setCounter(self.counter)

        self.saveCounterToFile()

    def remove1(self):
        if self.counter > 0:
            self.counter -= 1
            self.eel.setCounter(self.counter)

            self.saveCounterToFile()

    def resetCounter(self):
        self.counter = 0
        self.eel.setCounter(self.counter)

        self.saveCounterToFile()

    def isGameActive(self):
        def active_window_process_name():
            pid = win32process.GetWindowThreadProcessId(
                win32gui.GetForegroundWindow()
            )  #This produces a list of PIDs active window relates to
            return psutil.Process(pid[-1]).name(
            )  #pid[-1] is the most likely to survive last longer

        return True if active_window_process_name() == "sekiro.exe" else False

    def keyboardListener(self):
        self.auto.stop()
        self.auto = AutoHotPy()
        self.auto.exit_configured = True

        self.listenedKey = self.auto.keys[self.listenedKey.get_id()]

        self.auto.registerForKeyDown(
            self.listenedKey, lambda a, b: self.add1()
            if self.isGameActive() else self.listenedKey.press())
        self.auto.start()

    def changeListenedKey(self):
        self.changingLK = True

        self.auto.stop()
        self.auto = AutoHotPy()
        self.auto.exit_configured = True

        def showDialog():
            dialog = tk.Tk()
            dialog.attributes("-topmost", True)
            tk.Label(text="Listening for new key...", padx=20, pady=20).pack()
            dialog.update()
            return dialog

        def keyPressed(a, e):
            self.auto.stop()
            for key in self.auto.keys.values():
                if key.code == e.code:
                    self.listenedKey = key
                    return

        for key in self.auto.keys.values():
            self.auto.registerForKeyDown(key, keyPressed)

        dialog = showDialog()
        self.auto.start()
        dialog.destroy()

        self.auto = AutoHotPy()
        self.auto.exit_configured = True
        self.startKL()

        self.changingLK = False

        return self.listenedKey.string_representation
Exemplo n.º 7
0
def openTaskManager(autohotpy, event):
    """
    This function is called when you press DELETE key
    """
    if (autohotpy.LEFT_CTRL.isPressed() & autohotpy.LEFT_ALT.isPressed()
        ):  #check if ctrl and alt are also pressed
        autohotpy.LEFT_ALT.up()  #release alt
        autohotpy.sleep(
        )  #don't forget to sleep when you manually send a "down" state
        autohotpy.LEFT_SHIFT.down()
        autohotpy.sleep()
        autohotpy.ESC.down()
        autohotpy.sleep()
        autohotpy.LEFT_SHIFT.up()
        autohotpy.ESC.up()
    else:  #if ctrl +al is not pressed, then it's a normal  Del keypress. send it as is
        autohotpy.sendToDefaultKeyboard(event)


if __name__ == "__main__":
    auto = AutoHotPy()
    auto.registerExit(
        auto.F10, exitAutoHotKey
    )  # Registering an end key is mandatory to be able tos top the program gracefully

    # In win7 the task manager is launched when you press Ctrl + Shift + ESC
    # I don't like that. Lets call the task manager when you press Ctrl + Alt + Supr
    auto.registerForKeyDown(auto.DELETE, openTaskManager)
    auto.start()
Exemplo n.º 8
0
            )  # press() method simulates a key press by sending first the key down, and later the key up events
            autohotpy.V.up()
            time.sleep(random.randint(80, 200) / 1000)
        if count < 60 > 10:
            autohotpy.N6.down()
            time.sleep(
                random.randint(60, 200) / 1000
            )  # press() method simulates a key press by sending first the key down, and later the key up events
            autohotpy.N6.up()
            time.sleep(random.randint(80, 200) / 1000)
        if count < 10:
            autohotpy.N5.down()
            time.sleep(
                random.randint(70, 200) / 1000
            )  # press() method simulates a key press by sending first the key down, and later the key up events
            autohotpy.N5.up()
            time.sleep(random.randint(60, 200) / 1000)


# THIS IS WERE THE PROGRAM STARTS EXECUTING!!!!!!!!
if __name__ == "__main__":
    auto = AutoHotPy()  #Initialize the library
    auto.registerExit(
        auto.ESC, exitAutoHotKey
    )  # Registering an end key is mandatory to be able to stop the program gracefully
    auto.registerForKeyDown(
        auto.F1, superCombo
    )  # This method lets you say: "when I press A in the keyboard, then execute "superCombo"
    auto.start(
    )  #Now that everything is registered we should start runnin the program
Exemplo n.º 9
0
    autohotpy.RIGHT_ARROW.down()
    autohotpy.sleep(0.4998030662536621+random.randint(100,260)/10000)
    autohotpy.RIGHT_ARROW.down()
    autohotpy.sleep(0.500255823135376+random.randint(100,260)/10000)
    autohotpy.RIGHT_ARROW.down()
    autohotpy.sleep(0.5000472068786621+random.randint(100,260)/10000)
    autohotpy.RIGHT_ARROW.down()
    autohotpy.sleep(0.19176340103149414+random.randint(100,260)/10000)
    autohotpy.S.down()
    autohotpy.sleep(0.1322638988494873+random.randint(100,260)/10000)
    autohotpy.S.up()
    autohotpy.sleep(0.6137583255767822+random.randint(100,260)/10000)
    autohotpy.RIGHT_ARROW.up()
    autohotpy.sleep(0.005990266799926758+random.randint(100,260)/10000)
    autohotpy.LEFT_ARROW.down()
    autohotpy.sleep(1.0003645420074463+random.randint(100,260)/10000)
    autohotpy.LEFT_ARROW.down()
    autohotpy.sleep(0.49969911575317383+random.randint(100,260)/10000)
    autohotpy.LEFT_ARROW.down()
    autohotpy.sleep(0.5001978874206543+random.randint(100,260)/10000)
    autohotpy.LEFT_ARROW.down()
    autohotpy.sleep(0.5000302791595459+random.randint(100,260)/10000)
    autohotpy.LEFT_ARROW.down()
    autohotpy.sleep(0.3519623279571533+random.randint(100,260)/10000)
    autohotpy.LEFT_ARROW.up()
if __name__=="__main__":
    auto = AutoHotPy()
    auto.registerExit(auto.ESC,exitAutoHotKey)
    auto.registerForKeyDown(auto.F1,recorded_macro)
    auto.start()
Exemplo n.º 10
0
        print(count)
        time.sleep(random.randint(200, 400) / 1000)
        if count > 60:
            autohotpy.V.down()
            time.sleep(
                random.randint(80, 200) / 1000
            )  # press() method simulates a key press by sending first the key down, and later the key up events
            autohotpy.V.up()
            time.sleep(random.randint(80, 200) / 1000)
        if count < 60 > 10:
            autohotpy.N6.down()
            time.sleep(
                random.randint(60, 200) / 1000
            )  # press() method simulates a key press by sending first the key down, and later the key up events
            autohotpy.N6.up()
            time.sleep(random.randint(80, 200) / 1000)
        if count < 10:
            autohotpy.N5.down()
            time.sleep(
                random.randint(70, 200) / 1000
            )  # press() method simulates a key press by sending first the key down, and later the key up events
            autohotpy.N5.up()
            time.sleep(random.randint(60, 200) / 1000)


if __name__ == "__main__":
    auto = AutoHotPy()
    auto.registerExit(auto.ESC, exitAutoHotKey)
    auto.registerForKeyUp(auto.F1, mainmacro)
    auto.start()
Exemplo n.º 11
0

def rgbint2rgbtuple(RGBint):
    red = RGBint & 255
    green = (RGBint >> 8) & 255
    blue = (RGBint >> 16) & 255
    return (red, green, blue)


# END In-Game Helper functions

# Pre-configuration
def displayOptions():
    global start_time
    start_time=time.time()
    return int(input("1: Archer\n2: Asas\n3: Warrior\n4: Mage\n5: Priest Heal\n6: Only auto hp/mp"))


# END Pre-configuration

if __name__ == "__main__":
    auto = AutoHotPy()
    auto.registerExit(auto.F12,
                      exitAutoHotKey)  # Registering an end key is mandatory to be able tos top the program gracefully

    # Registry an entry point for our macro
    SELECTED_RUNTIME_CONFIGURATION = displayOptions()
    auto.registerForKeyDown(auto.F10, enableDisableLoopMacro)

    auto.start()
Exemplo n.º 12
0
from InterceptionWrapper import InterceptionMouseState, InterceptionMouseStroke, InterceptionMouseFlag


def exitAutoHotKey(autohotpy, event):
    """
    exit the program when you press ESC
    """
    autohotpy.stop()


def moveHandler(autohotpy, event):
    """
    This function inverts mouse axis!
    """
    if not (event.flags
            & InterceptionMouseFlag.INTERCEPTION_MOUSE_MOVE_ABSOLUTE):
        event.x *= -1
        event.y *= -1
    autohotpy.sendToDefaultMouse(event)


if __name__ == "__main__":
    auto = AutoHotPy()
    auto.registerExit(
        auto.ESC, exitAutoHotKey
    )  # Registering an end key is mandatory to be able tos top the program gracefully

    # lets switch right and left mouse buttons!
    auto.registerForMouseMovement(moveHandler)
    auto.start()
Exemplo n.º 13
0
    autohotpy.sendToDefaultMouse(stroke)
    stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_UP
    autohotpy.sendToDefaultMouse(stroke)


def leftButton(autohotpy, event):
    """
    This function simulates a left click
    """
    stroke = InterceptionMouseStroke()
    stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN
    autohotpy.sendToDefaultMouse(stroke)
    stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_UP
    autohotpy.sendToDefaultMouse(stroke)


if __name__ == "__main__":
    auto = AutoHotPy()
    auto.registerExit(
        auto.ESC, exitAutoHotKey
    )  # Registering an end key is mandatory to be able tos top the program gracefully

    # lets switch right and left mouse buttons!
    auto.registerForMouseButton(
        InterceptionMouseState.INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
        rightButton)
    auto.registerForMouseButton(
        InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
        leftButton)
    auto.start()