Reidar Posted March 31, 2010 Share Posted March 31, 2010 (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 March 31, 2010 by Reidar Link to comment Share on other sites More sharing options...
KaFu Posted March 31, 2010 Share Posted March 31, 2010 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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Reidar Posted March 31, 2010 Author Share Posted March 31, 2010 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now