bigbud78 Posted January 31, 2013 Share Posted January 31, 2013 So could I set up the following for depressing a single thumb button ? Keys are: 1 primary rifle 2 pistol 3,4,5,6 gadgets So if i'm currently on 1 a depress would change too 2 If on 2,3,4,5,6 a press would take me back to 1 Thanks Bud Link to comment Share on other sites More sharing options...
Laufer Posted January 31, 2013 Author Share Posted January 31, 2013 Yes, Bud, it is also possible. First of all lets discuss macro once again. I'll say how am I understood you: Depress of LMB (left mouse button) causes switching to some weapon. 1) If current weapon is 1 - switch to 2 2) If current weapon is 2 or 3 or 4 or 5 - switch to 1 Right? Besides we have to create keyboard macro for keys 1,2,3,4,5 so we could track current weapon. (Actually keyboard macro functionality not ready yet, but I know one trick :winking: ) Link to comment Share on other sites More sharing options...
bigbud78 Posted January 31, 2013 Share Posted January 31, 2013 Yes, Bud it is also possible. First of all lets discuss macro once again. I'll say how am I understood you: Right? Besides we have to create keyboard macro for keys 1,2,3,4,5 so we could track current weapon. I have an M60 :D: Depress of button 6 (Thumb button) causes switching to some weapon. 1) If current weapon is 1 - switch to 2 2) If current weapon is 2 or 3 or 4 or 5 - switch to 1 But yeah thats it, just wondered If I could do it off one button instead of using two buttons Link to comment Share on other sites More sharing options...
Laufer Posted January 31, 2013 Author Share Posted January 31, 2013 When you say some number that means key on keyboard or number of mouse button? :sigh!: Let us come to terms: (6) - means number of mouse button (also you should name your mouse... I got it - M60 :) ) "6" - means key on keyboard. Ok? Link to comment Share on other sites More sharing options...
bigbud78 Posted January 31, 2013 Share Posted January 31, 2013 When you say some number that means key on keyboard or number of mouse button? :sigh!: sorry for not being clear ! On my keyboard I have the following keys set up Key 1 rifle Key 2 pistol Key 3 med pack Key 4 c4 Key 5 squad beacon on my K60 I have button 6 (small thumb button) set as key press 1 So no matter what I currently have equipped I will change to my Rifle But I would like it so If I had the rifle equipped already pressing the 6 (small thumb button) on the M60 would change to Key 2 (my pistol) Link to comment Share on other sites More sharing options...
Laufer Posted January 31, 2013 Author Share Posted January 31, 2013 Alright, seems like I've got the Idea. Here is script for button (6): ; 6 ; ; Switch weapon 6_Switch: if % CurrWeapon=1 ; is it a rifle already? { Send {2} ; switch to weapon "2" (pistol) CurrWeapon:=2 ; remember current weapon } else ; its not a rifle { Send {1} ; switch to weapon "1" (rifle) CurrWeapon:=1 ; remember current weapon } return ; Macro for key "1" ~$1:: CurrWeapon:=1 ; remember current weapon return ; Macro for key "2" ~$2:: CurrWeapon:=2 ; remember current weapon return ; Macro for key "3" ~$3:: CurrWeapon:=3 ; remember current weapon return ; Macro for key "4" ~$4:: CurrWeapon:=4 ; remember current weapon return ; Macro for key "5" ~$5:: CurrWeapon:=5 ; remember current weapon return But you have to initialize thumb button (6) to default ("Browser Backward" as far as I can remember). p.s. Tested it on Notepad - works great :D Made script little smaller. p.p.s Made some optimization in keyboard macro. Put tilde instead of Send command. Link to comment Share on other sites More sharing options...
bigbud78 Posted January 31, 2013 Share Posted January 31, 2013 Wish there was a thank button :D: Thank you ! I'll try it tonight and will let you know how I get on :) Link to comment Share on other sites More sharing options...
Laufer Posted January 31, 2013 Author Share Posted January 31, 2013 Hope it will help :) One more question - what is your default weapon? A rifile? Link to comment Share on other sites More sharing options...
bigbud78 Posted February 6, 2013 Share Posted February 6, 2013 yes default is Rifle, still not had chance to try this but will asap :) Thanks Bud Link to comment Share on other sites More sharing options...
DukeOfPBJ Posted February 12, 2013 Share Posted February 12, 2013 I've been messing around with this with my M60 and I can't quite seem to get a rapid fire macro for button 7 to work. On the official M60 tool I made button 7 output F13. I'm using the LMB_RapidFire macro where I edited "while GetKeyState("F13", "P")" on button 7 and clicking save and launch. but this is my first time messing with this and I might just be missing something obvious. Link to comment Share on other sites More sharing options...
Laufer Posted February 13, 2013 Author Share Posted February 13, 2013 Hi, DukeOfPBJ! You don't have to reassign Button7 if you use M60. Leave it default (browser Backward). List of keys that should be reassigned is here. If you have problems with reassigning - just import default profile that HardMacro package includes (M60_default.xml). Use Corsair software option "Import profile". You also can use universal script (not only for Button7) for rapid fire. For example: ; Rapid fire ; ; Fire Rapidly while holding button RapidFire: Key := % A_ThisHotKey ; check if this hot key still pressed StringReplace, Key, Key, *$, , All while GetKeyState(Key, "P") ; while hot key pressed do... { Send {LButton down} ; press LMB Sleep, 50 ; wait 50 ms Send {LButton up} ; release LMB Sleep, 50 ; wait 50 ms } return I hope it will help :sunglasse Link to comment Share on other sites More sharing options...
DukeOfPBJ Posted February 13, 2013 Share Posted February 13, 2013 I hope it will help :sunglasse I tried that now I'm getting this error http://i.imgur.com/E5xBLDI.gif I'm probably just new to this and doing something really simple incorrectly, sorry. Link to comment Share on other sites More sharing options...
Laufer Posted February 14, 2013 Author Share Posted February 14, 2013 Name of macro file should be same as macro subroutine name (program looks for LMB_RapidFire label but there is only RapidFire one). Its written here at the conclusion. I will highlight that part. Here is final solution. Link to comment Share on other sites More sharing options...
meiner79 Posted March 17, 2013 Share Posted March 17, 2013 Hello, I´m to stupid. I have the M90 and I want the following. If I press key 10, it should send Space and if I hold key 10 it should send space constantly without breaks. Can someone help me? merci Link to comment Share on other sites More sharing options...
Laufer Posted March 17, 2013 Author Share Posted March 17, 2013 Hi, meiner79! Its not that hard as you think :biggrin:. Code you need described in this manual (3. Repeat while pressed...continuous pressing). And of course you have to assign extended mouse buttons (Step 2. Assign extended mouse buttons...M90) Here is solution one and solution two (if first will not work in your application). And please don't be shy to ask questions :sunglasse Link to comment Share on other sites More sharing options...
meiner79 Posted March 17, 2013 Share Posted March 17, 2013 Its working fine with your great manual and both macros are working, too. Thank you. But I need the macro without pressing another key. Maybe its inpossible? I consciously chose the mice with the softwarebugs, because you deliver a workarround. But after 3 hours using google, my head is buzzing. I will try it further. ;-) Link to comment Share on other sites More sharing options...
Laufer Posted March 17, 2013 Author Share Posted March 17, 2013 But I need the macro without pressing another key. Maybe its inpossible? Please, give me more details. I gave you universal macro for any mouse button, not only 10th. Link to comment Share on other sites More sharing options...
meiner79 Posted March 17, 2013 Share Posted March 17, 2013 I know. Ok I describe the whole problem. Space is for jump and swim up when holding. On ground it jumps, thats fine. If I press and hold the macro in water the character swims up for a short time (50ms). I have to hold the right mice button (RButton in the macro) to activate Space permanent. I want, if a button with the macro is pressed once, that it jumps once. And if i hold that button it should send Space the whole time without pressing right mice button (RButton in the macro). merci for the help Link to comment Share on other sites More sharing options...
Laufer Posted March 17, 2013 Author Share Posted March 17, 2013 Looks like you need toggle mode macro (see manual page 4. Toggle key press). I modified it a bit: ; Toggle Space button ToggleSpace: if % SpaceState=1 ; Space pressed already? { Send {Space Up} ; release Space button SpaceState:=2 ; remember Space state } else ; Space not pressed { Send {Space Down} ; press Space button SpaceState:=1 ; remember Space state } return Here macro to download. upd: Some application requires Send Key Down messages all time action goes on. For that case you will need this macro: ; Toggle Space button ToggleSpace2: If SpaceFlag ; If variable contents are blank (by default) or 0, it is considered false. Otherwise, it is true. { SetTimer, SpaceFlagSub, Off ; Turn off timer if button's been pressed second time } else { SetTimer, SpaceFlagSub, 75 ; Set timer to run every 75 milliseconds } SpaceFlag := not SpaceFlag ; Invert variable (if it has true make it false and vice versa) return SpaceFlagSub: Send {Space down} ; Send key press return Link to download Link to comment Share on other sites More sharing options...
filenotfound Posted March 19, 2013 Share Posted March 19, 2013 Well i really cant get this to work the way i want it to. Im ok at scripting, i know and have done C++ coding before, so im not entirely inept in coding logic. and this literally sends my brains into convulsions, and i cant possibly comprehend how its possible, that a "while key is not pressed" DOES NOT EXIST in autohotkey coding logic.... the getkeystate only allows for true or true conditions lol (P or T) it can return a false value, but it cant use a false value for a conditional???? like what??? ive tried using 0 (false in any coding logic) and it doesnt work. how is there literally NO documentation ANYWHERE on the internet about this? like EVERY GAME has this.... you need to do it to prone or cook grenades, etc because if you just press a key, it will just throw grenade or stand > crouch or crouch > stand. Like why cant you press C, and if holding C, it holds C (does no do the up key until release of the key, but if you have it do press c while c is held, it will spam c, and thats not going to work) i dont want a toggle where it will hold c until i click down c again, i want it in 1 button press and hold. So it makes stand > prone possible, or cook and hold grenades until release to up key and throw it. how is this not on the guide or ANY autohotkey documentation?? (like u and they have to get thousands of requests a day for this) its literally making me go crazy that its like COMPLETELY NON EXISTENT. i dont get it lol Link to comment Share on other sites More sharing options...
Laufer Posted March 19, 2013 Author Share Posted March 19, 2013 Less emotions - more thinking! If you are so good in C++ you might find some workaround about this issue. Whining won't help. Please, tell me in simple words what macro you want. I'll try to help you. Link to comment Share on other sites More sharing options...
filenotfound Posted March 19, 2013 Share Posted March 19, 2013 i never said i was "so good" i said i know coding logic due to doing some c++ programming. but i did say what i wanted in there lol Press C (C down) Hold C until i let go of C When i let go of C it releases C (C up) I only want 1 C down and 1 C up in this macro Its just something this simple i cant get to work, and i cant find anything about it anywhere on the internet (like this issue has never been brought up in autohotkey scripting history, and its NEEDED for things like going prone in a game which requires you to press and hold C to do), and thats whats driving me crazy lol Link to comment Share on other sites More sharing options...
Laufer Posted March 19, 2013 Author Share Posted March 19, 2013 Here is example from my tutorial page. I changed it for key "С" ; Press C repeatedly while C is pressed ; C_Continuous: Send {"C" down} ; press C while GetKeyState("C", "P") ; hold C pressed while C pressed { } Send {"C" up} ; depress C return Don't forget to name macro file same as subroutine name (C_Continuous.ahk) if you use it with Hard Macro. But still I can't get why do you need macro for key "C" to press it "C"? May be I missing something. English is not my language, sorry. Link to comment Share on other sites More sharing options...
filenotfound Posted March 19, 2013 Share Posted March 19, 2013 Here is example from my tutorial page. I changed it for key "С" ; Press C repeatedly while C is pressed ; C_Continuous: Send {"C" down} ; press C while GetKeyState("C", "P") ; hold C pressed while C pressed { } Send {"C" up} ; depress C return Don't forget to name macro file same as subroutine name (C_Continuous.ahk) if you use it with Hard Macro. But still can't get why do you need macro for key "C" to press it "C". May be I missing something. English is not my language, sorry. Well its not so much i want a macro to do this. I could do it in the corsair software just by making the button mapped to C. BUT i dont want to even have to change profiles for different games, i want the autohotkey to swap profiles automatically. Which is the delima. Now whats crazy is this doesnt work. Ill tell you exactly how im doing it. I set autohotkey.exe to run ad admin (im using the 64bit version of it, and 64bit os ofcourse). i set my corsair mouse profile to the corsair m60 one you made (with F13-F15), hardware playback is on, and i saved this profile to the M60. I made a new profile. set it for CoD. changed the dpi up key to 4 (special grenade) ; <Full script name> ; <Script description> ; Press4: Send {"4" down} while GetKeyState("4", "P") { } Send {"4" up} return have the "back" button (7) set up for crouch/prone ; <Full script name> ; <Script description> ; PressC: Send {"c" down} while GetKeyState("c", "P") { } Send {"c" up} return (they are named Press4.ahk and PressC.ahk, it auto-named them when you create new script using your hardmacro script) and then 6 as just a press of the N key (just normal press which works fine), and 8 (sniper button) as just press v, and it works fine. And ive tried MANY MANY MANY different combinations to get the C and 4 buttons to work as i described above. But i always get 1 of 2 results 1) button does literally no action 2) it just keeps pressing the button as i hold it after changing them i click save, then launch. but it seems to never work right. Again to make it sound easier to understand, better example. I want to cook a grenade before throwing it. like press grenade > hold grenade for like x seconds (x being the time im holding the button for), and throw it when i release it. Its basically like when you click on your keyboard and you are holding a button, and it holds until you let go of it. i just dont understand it at all... Link to comment Share on other sites More sharing options...
Laufer Posted March 19, 2013 Author Share Posted March 19, 2013 Thats what you should start from :) Ok, I'll fix it for you: ; Hold 4 while key is pressed ; Press4: Key := % A_ThisHotKey ; Use that construction to make macro universal. StringReplace, Key, Key, *$, , All Send {4 down} ; Push and hold 4 while GetKeyState(Key, "P") { } Send {4 up} return ; Hold C while key is pressed ; PressC: Key := % A_ThisHotKey ; Use that construction to make macro universal. StringReplace, Key, Key, *$, , All Send {c down} ; Push and hold C while GetKeyState(Key, "P") { } Send {c up} return I used universal construction so you can assign that macro to any mouse button. But, some application may not work properly with it so you have to set GetKeyState parameter directly. In your case this will be: ; Hold 4 while M60 button 4 is pressed ; Press4: Send {4 down} ; Push and hold 4 while GetKeyState("F13", "P") ; while M60 button 4 is pressed { } Send {4 up} return ; Hold C while M60 button 7 is pressed ; PressC: Send {c down} ; Push and hold C while GetKeyState("XButton1", "P") ; while M60 button 7 is pressed { } Send {c up} return Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.