| Main > Software Forum |
| AHK fun! |
| (1/4) > >> |
| papaschtroumpf:
I used AutoHotKey a lot on my main window machine when it used to be called AutoIT but I had kind of forgotten about it until Howard mentionned it as part of the johnny5 project. AutoHotKey (AHK for short) is becoming my cab's best friend. I found lots of uses for it and I figured I'd share a few, maybe some of you that have good scripts could also share them in this thread. Basically it allows to make "wrappers" around games (especially PC games, but other emulators too) I'll make a post per script to make them easier to read. |
| papaschtroumpf:
I have a few PC games that do not have volume control. Everything in my cab is calibrated to have about the same level of output, so those games can be either too soft or too loud. There are other solutions to this problem (see http://glorysoft.omsk.ru/vlt_download.html for example) but I wanted a solution that would save the existing volume and restore it later. The following script takes an argument in the form of a percentage (0-100) or a relative percentage (+10 or -50 for example) that tells it what to set the new sound level to (for wave output). The current level is saved to a file in the current directory that the next script can use to retore the sound volume. --- Code: ---;AHKVolume.ahk ; Get the current volume write it to a file SoundGetWaveVolume, CurrentVolume FileRecycle, AHKVolFile FileAppend, %CurrentVolume%, AHKVolFile ; Now set to the new specified volume passed as an argument to the script. ;Can be an absolute (0-100) or relative value such as +10 SoundSetWaveVolume, %1% --- End code --- This script retrieves the saved volume and set its back to that value: --- Code: ---;AHK REstoreVolume.ahk ; Companion script to AHKVolume.ahk - restores the volume to the value ; saved by AHKVolume.ahk FileRead, SavedVolume, AHKVolFile SoundSetWaveVolume, %SavedVolume% --- End code --- All you now have to do is call the first script before you launch the game that is (for example too loud) and call the second script after the game returns, all of it in a batch file for example. --- Code: ---AHKVolume.ahk -50 RunMyGame.exe AHKRestoreVolume.ahk --- End code --- |
| papaschtroumpf:
I have several PC games from Reflexive Arcade (www.reflexive.com). One bad thing about those games is that after you exit the game, it displays a window for about 20s with button to play the game again or play other games from reflexive (I think it brigs you to their web site, not sure I ever tried clicking the button). This is obviously a pain, I could see that for demo version, but the game does it even if you register. The following script will launch the game specified as an argument, then dismiss the window htat is displayed after the game exit, allowing you to get right back to your front end: --- Code: ---;Reflexive.ahk ; This AHK script dismisses the "Wrapper" that appears after exiciting a Reflexive ; Arcade game (the window that offers "Play Game" or "Other Games", even on a fully ; licensed game). ; Usage: reflexive.ahk <shortcut to the reflexive game> ; ;How it works: ; Sleep at the start of the script to make sure that we don't catch the window ; when the game is just starting. ; we then wait for the Reflexive wrapper window to appear and automatically ; close it Run, %1% Sleep, 8000 WinWaitActive, ahk_class ReflexiveGameWrapper Winclose, ahk_class ReflexiveGameWrapper --- End code --- You can then setup your front end to call the game using the following command line (you may have to set up a batch file): Reflexive.ahk <path to the game> for example: "D:\PC Games List\reflexive\reflexive.ahk" "D:\Program Files\Wik And The Fable Of Souls\Wik.exe" |
| papaschtroumpf:
This one is a variation on the previous script: Reflexive has a game called GutterBall2 In addition to leaving an annoying window behind as explained in the previous post, GutterBall2 will go to window mode if you press the ESC key. If you want to exit the key, you need to click on a red X in the corner of the screen. People are pretty much used to pressing the exit keyy on my cab that is mapped to the ESC key, so they keep making the game go into windowed mode, which doesn't look good. So in addition to eliminate the undesirable window, this script also captures the ESC key and prevents it from reaching the game: the ESC key now has no effect. Note that if I wanted to be really fancy, I could have made it so that the script would "click" the red X on the screen when the ESC key is pressed to make the exit key work as an "exit" key. --- Code: ---; This AHK script dismisses the "Wrapper" that appears after exiciting a Reflexive ; Arcade game (the window that offers "Play Game" or "Other Games", even on a fully ; licensed game). ; Usage: reflexive.ahk <shortcut to the reflexive game> ; In addition this special version prevents the use of the ESC key because it caused the game to go to windowed mode. Click on the red X in the game to exit ; HotKey, ESC, ignoreESC Run, %1% Sleep, 8000 WinWaitActive, ahk_class ReflexiveGameWrapper Winclose, ahk_class ReflexiveGameWrapper ExitApp IgnoreESC: return --- End code --- By the way, I don't like GutterBall2, my one of my kids loves it and talked grandma into paying for the license, so I guess now it's part of the cab. |
| papaschtroumpf:
I have several PC games that are played with the mouse exclusively. While I do have a PC trackball embedded into my CP, it's often awkward to use the trackball (sometimes fantically) and click on the buttons mounted on it. The following script maps the left CTRL and left ALT keys (P1B1 and P1B2 by default in MAME) to left and right click. [code] ; Button2Mouse.ahk ; maps P1B1 and P1B2 to left and right mouse click respectively #SingleInstance force #MaxHotkeysPerInterval 500 ; Using the keyboard hook to implement the Numpad hotkeys prevents ; them from interfering with the generation of ANSI characters such ; as |
| Navigation |
| Message Index |
| Next page |