Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

14 hours ago, JoeViking245 said:

I know your son appreciates all your hard work too.  "Game on!" :D

Thank you very much for your kind words. He is thrilled to have the game much more...accessible to him. The game frustrates me...so imagine how discouraging it is to a lil boy. Yeah..

So for years I have used the little google "hack" "site:blahblahblah.com" in my search terms to specifically narrow down a place I need searched. I do that for searching forums, and back in the ie11 days, when you could add your own search engine, I would have multiple google search engines for specific sites, namely megaupload...that long  ago. So yeah, your advice on the right tools in my tackle-box is right and I have been doing it for years, but the correct search term can be difficult to nail down at times. I really do get a kick outta the suggestions box when searching something, it's like a preview of how others use google. Using extra words that google doesn't need to provide the correct results.

 

Something else that has been bothering me though, LB/BB doesn't close all the way sometimes. I have a hotkey for closing LB down when it it left in task manager, but I would like to figure a way to close BB/LB down with a hotkey. Using my hotkey for shutting down BB doesn't work. I like using shift+escape in my always-on script for shutting down certain apps with ease. However BB wants to remain persistent. Any suggestions on using ahk to shutdown BB with a simple hotkey?

what I have used is this:

 

+Escape::
;there's a bunch of other process, close *.exe here
Process,Close,Bigbox.exe

I have tried using a batch file to close BigBox.exe as well, but it remains persistent. I am open to all suggestions here.

 

Edit: Nevermind, I solved it. I managed to stumble across a post where you were helping another guy with BB and found that BB spawns another process out of the core folder and changed my launch directory for BB and now my hotkey works. 

Edited by CtinD
Solved my issue and updated post explaining how
  • Like 2
Link to comment
Share on other sites

Also note that Process, Close is not a very 'nice' way to exit an app.  Almost as bad (forceful) as taskkill.  Suggest using

WinClose, ahk_exe BigBox.exe

The others will, well... 'kill' the process.  Whereas WinClose is like hitting Alt+F4 which is telling the app  "Hey, I need you to close.  So save all your data and do what you need to do, then shut down please." 

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, JoeViking245 said:

Also note that Process, Close is not a very 'nice' way to exit an app.  Almost as bad (forceful) as taskkill.  Suggest using


WinClose, ahk_exe BigBox.exe

The others will, well... 'kill' the process.  Whereas WinClose is like hitting Alt+F4 which is telling the app  "Hey, I need you to close.  So save all your data and do what you need to do, then shut down please." 

I use that hot key to kill hanging processes. Otherwise I exit using the assigned key. I still don't understand why Kodi and LB don't fully close the processes(it isn't every single time, though it's often enough to be a big enough thorn in my side to come up with this). What is happening is literally only the GUI is killed and thats it. I didn't fully go into detail as to why I have that HK set, there it is though. SO, I am wondering, is "winclose, ahk_exe BigBox.exe" going to kill the process as long as the window is terminated? I would like to use this on both LB and BB after closing the normal way if it kills the process afterwards, otherwise I am sticking with my current method as it my "contingency" plan. 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, CtinD said:

I use that hot key to kill hanging processes. Otherwise I exit using the assigned key. I still don't understand why Kodi and LB don't fully close the processes(it isn't every single time, though it's often enough to be a big enough thorn in my side to come up with this). What is happening is literally only the GUI is killed and thats it. I didn't fully go into detail as to why I have that HK set, there it is though. SO, I am wondering, is "winclose, ahk_exe BigBox.exe" going to kill the process as long as the window is terminated? I would like to use this on both LB and BB after closing the normal way if it kills the process afterwards, otherwise I am sticking with my current method as it my "contingency" plan. 

 

this is better than taskkill?

Link to comment
Share on other sites

59 minutes ago, CtinD said:

LB don't fully close the processes(it isn't every single time,

I've had this happen when I'm doing miscellaneous testing with plugins and am doing a lot of starting and exiting of LB/BB (exiting only via the respective UI).  I presume this has to do with impatient wait-times on my part.  I assimilate this to my refrigerator condenser it constantly running.  And though I open the fridge door every 3 to 5 minutes to make sure everything's still cold, the motor is still always running. ;) 

I have never had this happen on my cab nor with an occasional [single] start/exit.  So from what I've seen of it, I don't feel it's an issue that needs to be addressed.  As [for me] it operates under 'normal conditions', as it should.  I do know sometimes it does take a little longer for the LB 'process' to completely clear out from Task Manager as it's cleaning up after itself before vacating. And I'd rather it do that than leave a mess behind.

Again, this is just my experience/observations.  Your mileage may vary.

1 hour ago, Cnells2000 said:

this is better than taskkill?

Taskkill is a Windows command whereas Process, Close is inherent to AutoHotkey.  They both act with the same 'brute force'.  You could always do a 'Run, taskkill....' from within an AHK script if you wanted.  But the end results should have exactly the same outcome.

  • Thanks 1
Link to comment
Share on other sites

On 1/10/2021 at 6:24 PM, JoeViking245 said:

I've had this happen when I'm doing miscellaneous testing with plugins and am doing a lot of starting and exiting of LB/BB (exiting only via the respective UI).  I presume this has to do with impatient wait-times on my part.  I assimilate this to my refrigerator condenser it constantly running.  And though I open the fridge door every 3 to 5 minutes to make sure everything's still cold, the motor is still always running. ;) 

I have never had this happen on my cab nor with an occasional [single] start/exit.  So from what I've seen of it, I don't feel it's an issue that needs to be addressed.  As [for me] it operates under 'normal conditions', as it should.  I do know sometimes it does take a little longer for the LB 'process' to completely clear out from Task Manager as it's cleaning up after itself before vacating. And I'd rather it do that than leave a mess behind.

Again, this is just my experience/observations.  Your mileage may vary.

Taskkill is a Windows command whereas Process, Close is inherent to AutoHotkey.  They both act with the same 'brute force'.  You could always do a 'Run, taskkill....' from within an AHK script if you wanted.  But the end results should have exactly the same outcome.

I'm sorry for such a delayed response, my children's mother passed away yesterday. ? It's been extremely difficult on us all, I needed a distraction this whole situation which is why I am here RN. I am not looking for sympathy either, just needing to talk while being distracted. ?

 

I like your refrigerator analogy. Like always, you are brilliant. The only reason I even know if the LB process is hanging in Task Manager is say I just finished adding a few games and wanted to check it out in BB after closing LB, it throws the error about another instance already running. Other times, it has been hours after adding games and going back in to add some more, same error, so I added this hk. 

Which brings me to the distraction I am almost obsessive compulsively trying to figure out. Using AHK, how do I set 2 buttons on my XBONE controller to send a single keystroke? ie: RB+A (joy1+joy6) sending f5 ONLY when GTA V is running. (While still using what I currently have in my "always-on" script? Here is what I have in my script:

^!g::
keywait, g
if WinExist("ahk_exe GTA5.exe")
   {
      WinActivate
      return
   }
Run "J:\Games\Grand Theft Auto V Moded\GTA5.exe"
return

So in short, I want:

Using Ctrl+Alt+G as my HK.

If gta is already running, winactivate it

if not then launch GTA V 

ONLY when gta v is running, the right bumper and A button sends the f5 button.

I have most of it. The part that has a grip on me is with my gamepad and setting the conditions. I don't want it to send f5 at any other point

 

 

Edited by CtinD
Link to comment
Share on other sites

8 hours ago, CtinD said:

how do I set 2 buttons on my XBONE controller to send a single keystroke?

#IfWinActive ahk_exe GTA5.exe
1Joy1::
if GetKeyState("1Joy6")
{
  Send, {F5}
  Return
}
;Send, {1Joy1}
;Return

This assumes RB = Joy6 (opposite of how you wrote it ;)) .  You will need to press (hold) Joy6 first, then Joy1 for it to work.

Notes and Caveats:

If the controller works like keyboard (letter) presses, you'll need to uncomment the last 2 lines**.  Otherwise 1Joy1 (A-button) won't do anything.  (let me know what you find please :))  Hopefully you won't have to, because **I don't think you can actually "Send" a Joy_button-press.  ?

The #IfWinActive I'm pretty sure will effect EVERY hotkey assigned after it.  So put it at the end of your 'Always-On' script.

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

#IfWinActive ahk_exe GTA5.exe
1Joy1::
if GetKeyState("1Joy6")
{
  Send, {F5}
  Return
}
;Send, {1Joy1}
;Return

This assumes RB = Joy6 (opposite of how you wrote it ;)) .  You will need to press (hold) Joy6 first, then Joy1 for it to work.

Notes and Caveats:

If the controller works like keyboard (letter) presses, you'll need to uncomment the last 2 lines**.  Otherwise 1Joy1 (A-button) won't do anything.  (let me know what you find please :))  Hopefully you won't have to, because **I don't think you can actually "Send" a Joy_button-press.  ?

The #IfWinActive I'm pretty sure will effect EVERY hotkey assigned after it.  So put it at the end of your 'Always-On' script.

Honestly, for the method you explained, That is the only way I use RB+A to pull up the trainer in GTA V. So, I am guessing that I put the line of code under the return of my current HK? To circumvent that "issue" of needing it at the end of the script(already have an #IfWinActive at the end for kodi)can just make my hk call on the script separately when launching and keep it in my script's directory. The controller is a standard xbox one controller ie: XInput. After searching for my answer before posting here, i was trying UCR (Universal Controller Remapper), downloaded the xinput ahk library found here (x360) and here (Xbox One) go to the 4th post for Xbox One info. I tried a simple script that would give me a message box on joy1 press and I got nothing. SO I believe I need to add the updated Xinput.ahk to AutoHotKey. Unfortunately, I cannot make heads or tails of where to add new libraries for AHK to call on.

Edited by CtinD
Link to comment
Share on other sites

5 minutes ago, CtinD said:

Why is this commented?

Sorry to be difficult...

 

1 hour ago, JoeViking245 said:

If the controller works like keyboard (letter) presses, you'll need to uncomment the last 2 lines**.  Otherwise 1Joy1 (A-button) won't do anything.  (let me know what you find please :))  Hopefully you won't have to, because **I don't think you can actually "Send" a Joy_button-press.  ?

 

Link to comment
Share on other sites

3 minutes ago, JoeViking245 said:

Sorry to be difficult...

 

 

Lol I read it a 2nd time, thoroughly that go round and saw what you were saying, so I went back and updated my post with additional information. The reson my head is spinning with what is there is no lib folder to add new functions.

Edited by CtinD
Link to comment
Share on other sites

How about mapping your Guide Button?

#IfWinActive ahk_exe GTA5.exe
$vk07::
  Send, {F5}
  Return

This'll work for the XBox 360 controller.  Not sure if it's the same for the XBox One.   I've also seen "vk07sc000". That may be for the 'One' (or it's old information).

If you have other "#IfWinActive" statements, you can 'daisy-chain' them.   ...at the end of your script ;) 

1Joy1::
  MsgBox, You pressed "A"
  Return

#IfWinActive ahk_exe GTA5.exe
$vk07::
  Send, {F5}
  Return

#IfWinActive ahk_exe notepad.exe
$vk07::
  Send, This is a test.
  Return

Also, since these hotkeys are only doing 1 thing, "Return" is not required, as it is implied.  (Placed in the example by habit [and probably 'safe practice']

If you use the same 'button' for different things, in different [WinActive] programs (like in the example) you could write it like so

1Joy1::
  MsgBox, You pressed "A"
  Return

$vk07::
#IfWinActive ahk_exe GTA5.exe
  Send, {F5}

#IfWinActive ahk_exe notepad.exe
  Send, This is a test.

...at the END of your script.

Link to comment
Share on other sites

45 minutes ago, JoeViking245 said:

How about mapping your Guide Button?


#IfWinActive ahk_exe GTA5.exe
$vk07::
  Send, {F5}
  Return

This'll work for the XBox 360 controller.  Not sure if it's the same for the XBox One.   I've also seen "vk07sc000". That may be for the 'One' (or it's old information).

If you have other "#IfWinActive" statements, you can 'daisy-chain' them.   ...at the end of your script ;) 


1Joy1::
  MsgBox, You pressed "A"
  Return

#IfWinActive ahk_exe GTA5.exe
$vk07::
  Send, {F5}
  Return

#IfWinActive ahk_exe notepad.exe
$vk07::
  Send, This is a test.
  Return

Also, since these hotkeys are only doing 1 thing, "Return" is not required, as it is implied.  (Placed in the example by habit [and probably 'safe practice']

If you use the same 'button' for different things, in different [WinActive] programs (like in the example) you could write it like so


1Joy1::
  MsgBox, You pressed "A"
  Return

$vk07::
#IfWinActive ahk_exe GTA5.exe
  Send, {F5}

#IfWinActive ahk_exe notepad.exe
  Send, This is a test.

...at the END of your script.

The guide button works PERFECTLY!!!! Thank you so much! Are there $vk to use for the other buttons on the gamepad? So did the daisy-chaining. IN FACT....I was able to merge 2 scripts because of this unknown (to me) little trick.

Edited by CtinD
  • Game On 1
Link to comment
Share on other sites

1 hour ago, CtinD said:

So did the daisy-chaining. IN FACT....I was able to merge 2 scripts

Woot! Woot!.  Very Nice.  Glad it worked.  

All the 'other buttons' are numbered.

A             1
B             2
X             3
Y             4
LB (shoulder) 5
RB (shoulder) 6
Start         7
Back          8
Ljoy Click    9
Rjoy Click    10

(This is general.  They may vary between emulators/applications.) 

So "A" is Joy1.  "B" is Joy2"....   
Player 1 "A" is 1Joy1.  Player 2 "A" is 2Joy1.

There is someway to catch the (2) Z-Triggers and the (2) Joy-Sticks [movement], but I've no idea where I placed those notes.  And they weren't vk #'s.  Also, it might have been in C# I was messing with those.  Anyway, 10 'buttons' (11 including "Guide") plus an infinite amount of 2 (or even 3 or more) button combinations should get you what you need. ;) 

Link to comment
Share on other sites

57 minutes ago, JoeViking245 said:

Woot! Woot!.  Very Nice.  Glad it worked.  

All the 'other buttons' are numbered.


A             1
B             2
X             3
Y             4
LB (shoulder) 5
RB (shoulder) 6
Start         7
Back          8
Ljoy Click    9
Rjoy Click    10

(This is general.  They may vary between emulators/applications.) 

So "A" is Joy1.  "B" is Joy2"....   
Player 1 "A" is 1Joy1.  Player 2 "A" is 2Joy1.

There is someway to catch the (2) Z-Triggers and the (2) Joy-Sticks [movement], but I've no idea where I placed those notes.  And they weren't vk #'s.  Also, it might have been in C# I was messing with those.  Anyway, 10 'buttons' (11 including "Guide") plus an infinite amount of 2 (or even 3 or more) button combinations should get you what you need. ;) 

SO I am unable to use even my x360 gamepad with ahk, i tested with a small script to give me a message box when the a button is pressed(to no avail) and I originally thought it was an issue with me using an XBOX one controller which it actually is not. Now I believe it is my controller assignments within windows as I had vxbox and vjoy installed at one point, forgot about them after I realized they weren't helpful for what I needed them for (remember trying to send xinput presses from keyboard?) and never removed them. I remember at one point when trying to use vjoy it rendered my gamepads inoperable. SO, I removed both programs and virtual devices, still nothing. I have a feeling a fresh install of Windoze will clear up a fair bit of issues.

Also, I read (all of it this time) that I can specify which cont uses the HK like "2joy6" for joypad 2 Right Bumper. I tried that with my tester script, obliviously it didn't work. It did give mean idea though, suppose I am currently able to get HK working with my gamepads, could I have a script emulate a p2 controller? Say I wanted to p2 controller to do the Konomi code, would I be able to set say...RB+Start on p1 controller to have it input the Konomi code from p2 controller? Not that I need it to do that specifically, just an example. 

Edited by CtinD
spelling and grammatical errors
Link to comment
Share on other sites

I don't know what a x360 gamepad is.  I assume it's an Xbox 360 Controller clone.  Regardless, your Xbox One controller uses Xinput which (I'm fairly certain) is what AHK is looking for.  If whatever controller you're trying to test with is Dinput, that's probably why no message box pops up. 

I have seen it where Windows will rearrange the order your controllers are in when there's more than one hooked up.  Or for some arbitrary reason make your controller NOT 1Joy.  Try a 'catch-all' script and see if anything happens.  (May want to press ALL the buttons [on just one controller], just in case. ;) )

1Joy1::
MsgBox Controller 1 - Button "A"

2Joy1::
MsgBox Controller 2 - Button "A"

3Joy1::
MsgBox Controller 3 - Button "A"

4Joy1::
MsgBox Controller 4 - Button "A"

 

You can also press   {Win}+R   and then type in "joy.cpl" and press Enter.  Then you can see what Windows thinks is connected.

 

36 minutes ago, CtinD said:

could I have a script emulate a p2 controller?

I don't think you can have AHK "press" a controller button. (i.e. Send, 2Joy6)

Link to comment
Share on other sites

20 hours ago, JoeViking245 said:

I don't know what a x360 gamepad is.  I assume it's an Xbox 360 Controller clone.  Regardless, your Xbox One controller uses Xinput which (I'm fairly certain) is what AHK is looking for.  If whatever controller you're trying to test with is Dinput, that's probably why no message box pops up. 

I have seen it where Windows will rearrange the order your controllers are in when there's more than one hooked up.  Or for some arbitrary reason make your controller NOT 1Joy.  Try a 'catch-all' script and see if anything happens.  (May want to press ALL the buttons [on just one controller], just in case. ;) )


1Joy1::
MsgBox Controller 1 - Button "A"

2Joy1::
MsgBox Controller 2 - Button "A"

3Joy1::
MsgBox Controller 3 - Button "A"

4Joy1::
MsgBox Controller 4 - Button "A"

 

You can also press   {Win}+R   and then type in "joy.cpl" and press Enter.  Then you can see what Windows thinks is connected.

 

I don't think you can have AHK "press" a controller button. (i.e. Send, 2Joy6)

Yeah x360 is just me being lazy and not typing out "Xbox 360". I have the legit thing in both Xbox 360 and One controllers. When I was spazzing out over the Xinput lib thing, it is because MS changed something in the xinput API for XBONE (Xbox one) controllers. Both 360 and XBONE controllers may use Xinput but it changed after the w10 creators update in 2016 (i believe). I *can* roll back to a W8.1 xinput driver and ahk will work in harmony w/ that driver. I will however, lose the ability to control forza horizon 4 and Forza MS 7 with my XBONE controller. Honestly.....not worth it to me. I would rather reinstall W10, cause like I said...I believe vjoy and vxbox screwed things up. I had issues in the past in the those virtual joypads but persisted until I had them functioning like I needed them to(using my remote to send xinput signals to Netflix, remember?)...it seems as though I will not be able to achieve nirvana with my Arcade/HTPC. 

I will try to revisit this later when I reinstall w10. I am nearly finished setting up LB/BB, I have a little bit of media left to setup, all of my pc games are installed on separate drives and separated into 2 sections, (games that need to be reinstalled upon reinstallation of windoze and those that work regardless of old/new windoze install). I regularly backup "appdata" and "programdata" folders as well as all registry edits I make as I progress, so there is very little work for post-installation of w10. I even created a batch script for auo installation of all runtimes, ahk, np++ and other required files for gaming. I am also creating a stripped down copy of of w10 with all bloat removed, saving only the required parts for basic w10 functionality as well as MS store for UWP games. When that is installed, I will revisit this when that is accomplished and finally, my computer will be shelled with BB/Kodi and ready for prime time. Sorry for my distracted off topic tangent. lol

Link to comment
Share on other sites

Much like I'm sure everybody else has, I've been using the script to close an emulator (or application) upon pushing Esc.

However despite this working well, I wasn't fully satisfied with this solution, as it felt very abrupt and didn't leave much room for mistakes (Pushing Esc by accident).

 

So I've put together a script (with the help of the guys over at the AHK Discord) which prompts a message box asking if you'd like to quit, with Yes/No options upon pushing Esc.

The default selection is 'No', so you have to actively select 'Yes' for it to quit successfully.

'No' of course closes the message box, and it can be prompted again at any time via the Esc key.

 

I've put together 2 variations of this script.

The first one simply supports Mouse/Keyboard input.

 

However if you're like me, you likely have a button on your controller (Or multiple buttons) mapped to your Esc key to close the emulator.

So, the second variation temporarily maps Button 1 & Button 2 (usually A & B) to 'Enter', and maps the Joystick and the D-Pad to the arrow keys for the duration that the message box is active - allowing you to use a controller to select Yes or No.

 

I think this script might be useful to a lot of people, so I've decided to share it here.

Enjoy!

 

Variation 1 (Keyboard and Mouse Only):

;Keeps the MsgBox active.
stayactive() {
if !winactive("Quit")
winactivate Quit
}

; Makes sure the script doesn't overlap itself.
#Singleinstance, force
; Prevents the showing of a tray icon.
#NoTrayIcon

$Esc::
{
	; Sets the timer for the stayactive function.
	settimer stayactive, 1
	; Stores currently active window
	WinGetActiveTitle, Var_Active_Window
	; Hides AHK Script from appearing in the taskbar and puts the MsgBox always on top.
	Gui +OwnDialogs +AlwaysOnTop
	; Create a message box with Yes/No options, 260 sets the message box default to 'No'.
    MsgBox, 260, Quit, Are you sure you want to quit?
	; Turns off the stayactive timer
	settimer stayactive, off		

        IfMsgBox, Yes
        {
            WinClose, ahk_exe {{{StartupEXE}}}
        }
        IfMsgBox, No
        {
			; Activates emulator window
			WinActivate, %Var_Active_Window%
            exit
        }
}

 

Variation 2 (Also supports Controller Input):

;Keeps the MsgBox active.
stayactive() {
if !winactive("Quit")
winactivate Quit
}

; Makes sure the script doesn't overlap itself.
#Singleinstance, force
; Prevents the showing of a tray icon.
#NoTrayIcon

$Esc::
{
	; Sets the timer for the stayactive function.
	settimer stayactive, 1
	; Stores the emulator as active window
	WinGetActiveTitle, Var_Active_Window
	; Sets the timer for the Joystick mapping function.
    SetTimer, WatchAxis, 5
	; Sets the timer for the D-Pad mapping function.	
	SetTimer, WatchPOV, 5
	; Hides AHK Script from appearing in the taskbar and puts the MsgBox always on top.
	Gui +OwnDialogs +AlwaysOnTop
	; Create a message box with Yes/No options, 260 sets the message box default to 'No'.
    MsgBox, 260, Quit, Are you sure you want to quit?
	; Turns off the stayactive timer
	settimer stayactive, off
	
        IfMsgBox, Yes
        {
            SetTimer, WatchAxis, Off 
            WinClose, ahk_exe {{{StartupEXE}}}
        }
        IfMsgBox, No
        {
            SetTimer, WatchAxis, Off 
			; Activates emulator window
			WinActivate, %Var_Active_Window%
            exit
        }

}

#IfWinActive

; This section maps Button 1 & Button 2 to Enter while the MsgBox is active.
    Joy1::Enter
    Joy2::Enter

; This section maps the Joystick to the Arrow Keys while the MsgBox is active.

WatchAxis:
JoyX := GetKeyState("JoyX")  ; Get position of X axis.
JoyY := GetKeyState("JoyY")  ; Get position of Y axis.
KeyToHoldDownPrev := KeyToHoldDown  ; Prev now holds the key that was down before (if any).

if (JoyX > 70)
    KeyToHoldDown := "Right"
else if (JoyX < 30)
    KeyToHoldDown := "Left"
else if (JoyY > 70)
    KeyToHoldDown := "Down"
else if (JoyY < 30)
    KeyToHoldDown := "Up"
else
    KeyToHoldDown := ""

if (KeyToHoldDown = KeyToHoldDownPrev)  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1  ; Avoid delays between keystrokes.
if KeyToHoldDownPrev   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev% up}  ; Release it.
if KeyToHoldDown   ; There is a key to press down.
    Send, {%KeyToHoldDown% down}  ; Press it down.
return

; This section maps the D-Pad to the Arrow Keys while the MsgBox is active.

WatchPOV:
POV := GetKeyState("JoyPOV")  ; Get position of the POV control.
KeyToHoldDownPrev := KeyHeld  ; Prev now holds the key that was down before (if any).

; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if (POV < 0)   ; No angle to report
    KeyHeld := ""
else if (POV > 31500)               ; 315 to 360 degrees: Forward
    KeyHeld := "Up"
else if POV between 0 and 4500      ; 0 to 45 degrees: Forward
    KeyHeld := "Up"
else if POV between 4501 and 13500  ; 45 to 135 degrees: Right
    KeyHeld := "Right"
else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
    KeyHeld := "Down"
else                                ; 225 to 315 degrees: Left
    KeyHeld := "Left"

if (KeyHeld = KeyToHoldDownPrev)  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1  ; Avoid delays between keystrokes.
if KeyToHoldDownPrev   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev% up}  ; Release it.
if KeyHeld   ; There is a key to press down.
    Send, {%KeyHeld% down}  ; Press it down.
return

 

Edited by Darkshade
Link to comment
Share on other sites

  • 3 weeks later...

25 pages in this thread, my apologies if these answers are in there.  looking for a couple of things if anyone can help:

1. looking to send left and/or right mouse clicks with the push of a button, let’s say ‘N’ and/or ‘A’ for left click, ‘B’ and/or ‘S’ or right click

2. send one key when pressing another, e.g. send ‘P’ when pressing ‘H’

3. i’m using a launcher app to launch ScummVM.  i have tried plenty of exit scripts to send alt-f4 when pressing ESC, nothing seems to work.  any thoughts?

thanks everyone!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...