sanddoctor Posted December 5, 2009 Share Posted December 5, 2009 (edited) Hello:) What I want is mouse-right-down = enable shift+w which holds it down <click mouse-right> Mouse-right-up = disable shift+w holding down. This for a game I've difficult setting it up. I've tried to use this script from the forum but I have no luck. This is the script I've been trying to use HotKeySet(+MouseDown{right}, "hammer_toggle") global $autohammer = 0 Func hammer_toggle() If $autohammer = 0 Then Send("+{w down}") Sleep(100) $autohammer = 1 HotKeySet("+MouseUp{right}" HotKeySet(MouseDown("right"), "hammer_toggle") Else Send("+{w Up}") Sleep(100) $autohammer = 0 HotKeySet("+MouseUp{right}") HotKeySet(MouseDown("right"), "hammer_toggle") EndIf EndFunc ; Idle While 1 Sleep(10) Wend What am I doing wrong? Edited December 5, 2009 by sanddoctor Link to comment Share on other sites More sharing options...
picea892 Posted December 5, 2009 Share Posted December 5, 2009 Are you certain you can use hotkeyset with a mouse press? Where did you get this from "+MouseDown{right}" Think you need to investigate _ispressed or a mousehook Link to comment Share on other sites More sharing options...
sanddoctor Posted December 6, 2009 Author Share Posted December 6, 2009 Are you certain you can use hotkeyset with a mouse press? Where did you get this from "+MouseDown{right}"Think you need to investigate _ispressed or a mousehookWeird u cant set the mouse to a hotkeyset. I've never used macros before so if u could help me a bit more with commands ect it would be very helpfull:) Seen some script that u need shift in your commands and then I tried to improvise with the "+MouseDown{right}" Link to comment Share on other sites More sharing options...
picea892 Posted December 6, 2009 Share Posted December 6, 2009 Below is the easy way with _ispressed. Notice that you still get a context menu when hitting the right mouse button. If you used a low level mouse hook you could avoid the context menu showing up. But that's for another day Just so you aren't wondering what consolewrite is. When you run a script in scite(press f5) you can have text write to the console (at bottom) for debugging purposes. Good luck and welcome to the forum. Picea #include <Misc.au3> $dll = DllOpen("user32.dll") global $autohammer = 0 Func hammer_toggle() If $autohammer = 0 Then ; Send("+{w down}") Sleep(100) $autohammer = 1 ConsoleWrite("on") Else ; Send("+{w Up}") Sleep(100) $autohammer = 0 ConsoleWrite("off") EndIf EndFunc ; Idle While 1 if _IsPressed("02", $dll) and _IsPressed("10", $dll) Then hammer_toggle();right mouse and shift Sleep(10) Wend Servant 1 Link to comment Share on other sites More sharing options...
skyboy Posted December 6, 2009 Share Posted December 6, 2009 really, you weren't even consistent with your attempts =\ but since someone else has posted a solution, here's the help file's content on HotKeySet:Function Reference HotKeySet--------------------------------------------------------------------------------Sets a hotkey that calls a user function. Parameterskey The key combination to use as the hotkey. Same format as Send(). function [optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey. Return ValueSuccess: Returns 1. Failure: Returns 0. RemarksIf two AutoIt scripts set the same HotKeys, you should avoid running those scripts simultaneously. (The second script cannot capture the hotkey unless the first script terminates or unregisters the key prior to the second script setting the hotkey.)A hotkey-press *typically* interrupts the active AutoIt function/statement and runs its user function until it completes or is interrupted. Exceptions are as follows:1) If the current function is a "blocking" function, then the key-presses are buffered and execute as soon as the blocking function completes. MsgBox and FileSelectFolder are examples of blocking functions. Try the behavior of Shift-Alt-d in the Example.2) If you have paused the script by clicking on the AutoIt Tray icon, any hotkeys pressed during this paused state are ignored.The following hotkeys cannot be set:Ctrl+Alt+Delete It is reserved by Windows F12 It is also reserved by Windows, according to its API. NumPad's Enter Key Instead, use {Enter} which captures both Enter keys on the keyboard. Win+B,D,E,F,L,M,R,U; and Win+Shift+M These are built-in Windows shortcuts. Note: Win+B and Win+L might only be reserved on Windows XP and above. Alt, Ctrl, Shift, Win These are the modifier keys themselves! Other Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'. When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application, with one exception: the Lock keys (NumLock, CapsLock, and ScrollLock) still toggle their respective state!To Send() a key combination which will trigger a HotKeySet() event, either use ControlSend() or unregister the HotKeySet() event, otherwise, the Send() event may trigger an infinite loop.; capture and pass along a keypress HotKeySet("{Esc}", "captureEsc") Func captureEsc() ; ... can do stuff here HotKeySet("{Esc}") Send("{Esc}") HotKeySet("{Esc}", "captureEsc") EndFuncThe called function can not be given parameters. They will be ignored.@HotKeyPressed macro can be used inside the function to handle several keys in the same function. RelatedSend, ControlSend Example; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(4096,"","This is a message.") EndFuncthe function reference included with your install of autoit is quite handy : "C:\Program Files\AutoIt3\AutoIt.chm" Link to comment Share on other sites More sharing options...
sanddoctor Posted December 6, 2009 Author Share Posted December 6, 2009 Below is the easy way with _ispressed. Notice that you still get a context menu when hitting the right mouse button. If you used a low level mouse hook you could avoid the context menu showing up. But that's for another day Just so you aren't wondering what consolewrite is. When you run a script in scite(press f5) you can have text write to the console (at bottom) for debugging purposes.Good luck and welcome to the forum.Picea#include <Misc.au3> $dll = DllOpen("user32.dll") global $autohammer = 0 Func hammer_toggle() If $autohammer = 0 Then ; Send("+{w down}") Sleep(100) $autohammer = 1 ConsoleWrite("on") Else ; Send("+{w Up}") Sleep(100) $autohammer = 0 ConsoleWrite("off") EndIf EndFunc ; Idle While 1 if _IsPressed("02", $dll) and _IsPressed("10", $dll) Then hammer_toggle();right mouse and shift Sleep(10) WendThx for the help and your replies:) But I cant get the script to work when I run it:( Trust me I've spend several hours on this and I'm not good at it. Link to comment Share on other sites More sharing options...
picea892 Posted December 6, 2009 Share Posted December 6, 2009 okay...I think there is another lesson I forgot to give. When you put ; in front of a line it comments out the line. I did that for the juicy parts and forgot to delete the ; Change these lines ; Send("+{w down}") ; Send("+{w Up}") to this Send("+{w down}") Send("+{w Up}") Link to comment Share on other sites More sharing options...
sanddoctor Posted December 6, 2009 Author Share Posted December 6, 2009 okay...I think there is another lesson I forgot to give.When you put ; in front of a line it comments out the line. I did that for the juicy parts and forgot to delete the ;Change these lines; Send("+{w down}") ; Send("+{w Up}")to thisSend("+{w down}") Send("+{w Up}")Tried it and still it's not working Does it have anything to do with this command or others?#include <Misc.au3> $dll = DllOpen("user32.dll") Link to comment Share on other sites More sharing options...
sanddoctor Posted December 6, 2009 Author Share Posted December 6, 2009 (edited) Kk it seems to work if I press right mouse and shift as u stated:). But the problem is it's not holding shift+w down when I press right mouse and shift to activate it. It only uses shift if I hold shift down while only "w" is down when the script is enabled. I thought just using right mouse could enable and close the script and not using shift+right mouse to do it. Edited December 6, 2009 by sanddoctor Link to comment Share on other sites More sharing options...
jaenster Posted December 6, 2009 Share Posted December 6, 2009 Diablo II AutoHammers (with w as standstill?) -jaenster Link to comment Share on other sites More sharing options...
BugFix Posted December 6, 2009 Share Posted December 6, 2009 Look at this: #657180Maybe, that's what you want. Best Regards BugFix Link to comment Share on other sites More sharing options...
sanddoctor Posted December 6, 2009 Author Share Posted December 6, 2009 Diablo II AutoHammers (with w as standstill?)No it's for Darkfall where I want to press right mouse to enable shift+w holding down and press mouse right to stop it Look at this: #657180Maybe, that's what you want.Wow thx but I'll try look at it but I'm pretty sure I'll fail trying implement the shift+w in the command 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