mdueck Posted November 10, 2018 Share Posted November 10, 2018 I have some, but very little experience with AHK so please be patient with me. I have tried researching and playing around with things to try and figure it out on my own, but I can't seem to get anywhere. I bought this N64 USB controller by iNNext and I ran the test script from here. AHK recognized all my buttons, so I recorded the numbers for each button. But when I try to make a script to do something with the buttons I can't get anything to work. To test out the button numbers I had recorded I decided to try some simple send commands. For instance I am trying to use button 10 to tab across in a word file with Joy10::Send {Tab} return but that won't work. I tried a few other Send commands but the .ahk script never recognizes my controller buttons even though I can use a keyboard button to do the same Send command that I'm testing. Any help you can offer to correct me where I am messing up would be greatly appreciated. The end goal is to use AHK so that I can have buttons on my controller for Load/Save state and also a button combination to shutdown my computer. I found a shutdown script posted by jayjay that looks really promising, but I can't get it to work either since none of my controller buttons seem to work with my .ahk scripts. Quote Link to comment Share on other sites More sharing options...
jayjay Posted November 20, 2018 Share Posted November 20, 2018 The shutdown script is now pointless as you can shutdown through BB. The only thing I can think of why this wouldnt work is the n64 controller isnt the only controller or peripheral you have plugged in? Does the test script say what joy number it is... something like joy, 2joy or 3joy. Try changing joy10 :: Send {tab down}{tab up} to 2joy10 :: Send {tab down}{tab up} then 3joy10 and so on. Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 21, 2018 Author Share Posted November 21, 2018 (edited) YES! Thank you @jayjay for this help. I read somewhere if you didn't put a number in front of Joy__ that it would then apply to all controllers, I guess it doesn't work that way in my case. I found out that the controller I hooked up was 3Joy. Now that I am able to get a single button on my controller to actually do something, I have some more questions I am hoping someone could help me with. I have played around with stuff, but I couldn't get things working. I would like to make it so that a combination of controller buttons will Send the Esc key. I tried 3Joy5 & 3Joy6:: Send {Esc} return It would press the ESC key when I hit button 5, but not only on the combination of the two buttons. I am also wanting a different combination of buttons to Send F6 and F8 as those are my save and load state buttons. I am hoping to use a combination of about 3 or 4 buttons so that I don't accidentally initiate them with just regular button pressing combinations. I also got your @jayjay's shutdown script that he posted on November 17, 2017 here to work, but just wondering if anyone has a nice Shutdown.png file that they made. Thanks for all your help! Edited November 21, 2018 by mdueck Quote Link to comment Share on other sites More sharing options...
jayjay Posted November 22, 2018 Share Posted November 22, 2018 (edited) 3Joy5:: if GetKeyState("3Joy6") Goto, SomeFunction Return 3Joy6:: if GetKeyState("3Joy5") Goto, SomeFunction Return SomeFunction: { Send {esc down}{esc up} } Return or 4 buttons: 3Joy5:: if GetKeyState("3Joy6") if GetKeyState("3Joy7") if GetKeyState("3Joy8") Goto, SomeFunction Return 3Joy6:: if GetKeyState("3Joy5") if GetKeyState("3Joy7") if GetKeyState("3Joy8") Goto, SomeFunction Return 3Joy7:: if GetKeyState("3Joy5") if GetKeyState("3Joy6") if GetKeyState("3Joy8") Goto, SomeFunction Return 3Joy8:: if GetKeyState("3Joy5") if GetKeyState("3Joy6") if GetKeyState("3Joy7") Goto, SomeFunction Return SomeFunction: { Send {esc down}{esc up} } Return Edited November 22, 2018 by jayjay Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 24, 2018 Author Share Posted November 24, 2018 @jayjay you're the best, thanks for all the help so far. I tried the above script for a couple different scripts so that a combination of controller buttons will send a keyboard key but AHK doesn't like it if I use the same button in more than one of my button combinations. I get this error Is there a way around this? Thanks! Quote Link to comment Share on other sites More sharing options...
jayjay Posted November 24, 2018 Share Posted November 24, 2018 Give me an example of what combinations you want. As an example... I use 360 controller. I want select and RB to send esc and I want select and LB to send enter. That would be joy7 and joy5 to send esc. And joy7 and joy6 to send enter. So reply with the gamepad button numbers that you want to press and the keyboard button to send. Hope that makes sense. I'll get back to you after iv had some sleep. Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 24, 2018 Author Share Posted November 24, 2018 I tried writing up the code that I am hoping to use to save and load states with a 3 button combination, I have two issues with it though. I can use the save state and load state code separately, but AHK gives me that error if I have them both running simultaneously. The second problem I have is that I can get the button combination to send the F# key in windows, but it doesn't work in Project64. ; must press C-left + Z + Start for F6 (load state) 3Joy4:: if GetKeyState("3Joy8") if GetKeyState("3Joy10") Goto, LoadState Return 3Joy8:: if GetKeyState("3Joy4") if GetKeyState("3Joy10") Goto, LoadState Return 3Joy10:: if GetKeyState("3Joy4") if GetKeyState("3Joy8") Goto, LoadState Return LoadState: { Send {F6 down}{F6 up} } Return ; must press C-right + Z + Start for F8 (save state) 3Joy2:: if GetKeyState("3Joy8") if GetKeyState("3Joy10") Goto, SaveState Return 3Joy8:: if GetKeyState("3Joy2") if GetKeyState("3Joy10") Goto, SaveState Return 3Joy10:: if GetKeyState("3Joy2") if GetKeyState("3Joy8") Goto, SaveState Return SaveState: { Send {F8 down}{F8 up} } Return I did a google search and I found a post that said some games block computerized keystrokes (not exactly sure what that means), he suggested that a SendInput code might work instead. I tried the code below just to test if it would work, but again it worked in Windows but not in Project64. There was some other code mentioned later on, but I didn't understand what it meant or how to incorporate it. 3Joy5:: SendInput, {F6} return I was also wondering if you'd be able to write up a script that would allow me to hold down 3Joy10 (my start button) for 5 seconds to then send my Escape button so that I can exit emulators with my controller. No need to rush your replies if you're busy at all, I just really appreciate the help you're providing. Thanks again for everything! Quote Link to comment Share on other sites More sharing options...
jayjay Posted November 25, 2018 Share Posted November 25, 2018 (edited) 3Joy2:: if getkeystate("3Joy8") && getkeystate("3Joy10") { keywait, 3Joy2 goto SaveState } return 3Joy4:: if getkeystate("3Joy8") && getkeystate("3Joy10") { keywait, 3Joy4 goto LoadState } return 3Joy8:: if getkeystate("3Joy2") && getkeystate("3Joy10") { keywait, 3Joy8 goto SaveState } if getkeystate("3Joy4") && getkeystate("3Joy10") { keywait, 3Joy8 goto LoadState } return 3Joy10:: if getkeystate("3Joy2") && getkeystate("3Joy8") { keywait, 3Joy10 goto SaveState } if getkeystate("3Joy4") && getkeystate("3Joy8") { keywait, 3Joy10 goto LoadState } keywait, 3Joy10, t5 if errorlevel <> 0 { Send {esc down}{esc up} } return SaveState: Send {F8 down}{F8 up} return LoadState: Send {F6 down}{F6 up} return This seems to work for me. Let me know if it doesn't work for you, there is another way to try. All the "KeyWait"... it will wait for you to release the gamepad buttons before it sends the keyboard keys. This is so it doesn't send the keyboard keys multiple times with each gamepad button press. Apart from this keywait: keywait, 3Joy10, t5 if errorlevel <> 0 { Send {esc down}{esc up} } All this is saying is... wait 5 seconds for 3joy10 to be released if it is not released in 5 seconds send escape Project 64. I use retroarch for n64 but can try... Im assuming your using Launchbox built in autohotkey. Go to Launchbox/autohotkey directory. Right click on autohotkey.exe, properties, compatibility, run as admin, apply. Edited November 25, 2018 by jayjay Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 26, 2018 Author Share Posted November 26, 2018 I was using AHK outside of launchbox, but I added your script into launchbox now. I added it to Tools>Edit AutoHotkey Script for Windows Games... Sadly, I am not finding that any of those three functions are working. I am not sure if it makes a difference at all but whenever I open PJ64 it always asks me to "all this app from an unknown publisher to make changes to this device". I tried to google how to get rid of it, but I couldn't figure it out. Now that I added your code into the launchbox script (or maybe because I selected run as admin for autohotkey.exe) I get the same popup dialogue for autohotkey as well. So pretty much, when I open a N64 game I get the pop up twice. I don't know why I get that popup for PJ64, I thought that it could be due to installing the program in my Program Files, so I uninstalled and placed it in a C:/Games directory. But that didn't help. The funny thing is though that I have PJ64 on my HTPC (in Program Files) as well, but it doesn't give me that pop up. I am thinking I haven't done a reformat in a few years, so that is something I just might do to see if it makes a difference. Quote Link to comment Share on other sites More sharing options...
jayjay Posted November 26, 2018 Share Posted November 26, 2018 (edited) The popups are your UAC. Google UAC windows 10 or whatever OS your on and read up on it. Iv disabled it on my computer, your have to decide for yourself to disable it or not. In Launchbox go to tools manage emulators select project 64 autohotkey tab and paste the script there. Each emulator has its own autohotkey tab. Also test to see if the script works for you, prob best to test it outside launchbox. Change all the send commands to "msgbox hello" to make sure the script works ok. Edited November 26, 2018 by jayjay Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 27, 2018 Author Share Posted November 27, 2018 It Works!! Hey another quick question, would it work to create message that flashes on the screen when you save state (and load state maybe too)? A textbox could work, but could it be something like subtitles for a video so that only the text is visible, not a box around the text? Quote Link to comment Share on other sites More sharing options...
jayjay Posted November 27, 2018 Share Posted November 27, 2018 Its possible to create transparent gui's etc etc with ahk but the problem your have is when it pops up it will take the focus away from the emulator. You might be able to find a script that modifies a tooltip to be larger, different font, colour etc etc but thats not something i'll be looking into. You could easily play a sound file when you save/load using "SoundPlay, path-to-audio-file". But obviously thats not as good as a popup. Anyway glad you got it working. Quote Link to comment Share on other sites More sharing options...
mdueck Posted November 27, 2018 Author Share Posted November 27, 2018 Yeah that makes total sense. I'll play around with it and see what I can muster up. Thank you again for all your support this last week. I spent hours and hours searching around the internet trying to get things working, I even went on AHK's discord channel. But nobody else was able to figure out my issue. You have made a big impression on me as to the type of people here in the Launch Box community. Thank you again! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.