Sign in to follow this  
Followers 0
Reidar

Mouse Hotkey

3 posts in this topic

#1 ·  Posted (edited)

I wrote a little script that when pressing down the right mouse button the script should toggle to press down the "F12" button. I made this script for a game and "F12" is bound to sprint ingame.

My problem is that i can´t get my right mouse button set as a hotkey. When i run the script below nothing happends if i press my right mouse button, but if i press the button "1" the script starts executing the SprintToggle function. So basicalli the only problem is that i can´t figure out how to bind my right mouse button as a hotkey.

I tried searching the forum and google for a solution for this, but i couldn´t find it.

WinWaitActive( "Darkfall Online" )

Global $toggle = False

HotKeySet( MouseClick("Right"), "SprintToggle" ) ; Press right mouse button to toggle autorun.

  


Loop() 

Func SprintToggle()
    
if $toggle == False Then 
    Send( "{F12 Down}" )
    $toggle = True
    Stop() 
Else
Send( "{F12 Up}" )
$toggle = False
Stop() 
EndIf
EndFunc


Func Loop()
    While True
        Sleep( 50000 )
    WEnd
EndFunc
Edited by Reidar

Share this post


Link to post
Share on other sites



Where's the Stop() function?

Add it and try this...

#include <Misc.au3>

$dll = DllOpen("user32.dll")
Global $toggle = False

While 1
    Sleep(250)
    If WinActive("Darkfall Online") then
        If _IsPressed("02", $dll) Then
            While _IsPressed("02", $dll)
                Sleep(10)
            WEnd
            SprintToggle()
        EndIf
    EndIf
WEnd
DllClose($dll)

Func SprintToggle()
    If $toggle == False Then
        Send("{F12 Down}")
        $toggle = True
        Stop()
    Else
        Send("{F12 Up}")
        $toggle = False
        Stop()
    EndIf
EndFunc   ;==>SprintToggle

Share this post


Link to post
Share on other sites

Thanks alot, that was ecxactly what i wanted :) Sorry but having the the Stop() reference in the code wich basically was a call to the Stop() function, i just changed it before posting here. i removed those stop() references and the script works as a charm now.

Now i need to learn more about using those dll files :(

P.S This is the code from above without those needless Stop References()

$dll = DllOpen("user32.dll")
Global $toggle = False

While 1
    Sleep(250)
    If WinActive("Darkfall Online") then
        If _IsPressed("02", $dll) Then
            While _IsPressed("02", $dll)
                Sleep(10)
            WEnd
            SprintToggle()
        EndIf
    EndIf
WEnd
DllClose($dll)

Func SprintToggle()
    If $toggle == False Then
        Send("{F12 Down}")
        $toggle = True
        
    Else
        Send("{F12 Up}")
        $toggle = False
        
    EndIf
EndFunc   ;==>SprintToggle

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0