Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Autohotkey Shutdown Hotkey  (Read 4611 times)

0 Members and 1 Guest are viewing this topic.

SlainbytheBrain

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 25
  • Last login:August 23, 2011, 07:01:36 pm
Autohotkey Shutdown Hotkey
« on: June 29, 2011, 03:45:39 am »
I am trying to use Autohotkey to shutdown my computer with my arcade joystick. The button combination I want to use is pressing 1, 2, and 4 simultaneously.

I tried the following:

124::Shutdown 9

When trying to run the script, I was told that this was an invalid hotkey. What am I missing?

Thanks,
Matt

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Re: Autohotkey Shutdown Hotkey
« Reply #1 on: June 30, 2011, 01:10:07 am »
You can only use one hotkey such as

1::
shutdown, 9
return

or two hotkeys such as

1 & 2::
shutdown, 9
return

where 1 acts as a shift key.

However, here's a work around I cooked up:

Quote
$1::
send 1
KeyWait, 2, D T1
If (ErrorLevel = 0)
{
Keywait, 4, D T1
If (ErrorLevel = 0)
{
shutdown, 9
}
}
return

This works, but note that it has a couple of side effects - when you press 1, the 1 key is disabled for a second afterwards. This shouldn't be a problem if 1 is being used as a start button. Otherwise, you may wish to switch the keys around so that 2 or 4 is the hotkey. Also, this will also be activated if you pressed 1 then 2 then 4 fairly quickly, but assuming these aren't all "action" buttons, that's unlikely to happen by accident.

Blanka

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2248
  • Last login:January 25, 2018, 03:19:28 pm
Re: Autohotkey Shutdown Hotkey
« Reply #2 on: June 30, 2011, 02:22:07 am »
And for the maccies out there: just program your minipac to have "eject" on one button. Ctrl-eject is immediate shut down on a mac.

SlainbytheBrain

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 25
  • Last login:August 23, 2011, 07:01:36 pm
Re: Autohotkey Shutdown Hotkey
« Reply #3 on: June 30, 2011, 02:31:16 am »
You can only use one hotkey such as

1::
shutdown, 9
return

or two hotkeys such as

1 & 2::
shutdown, 9
return

where 1 acts as a shift key.

However, here's a work around I cooked up:

Quote
$1::
send 1
KeyWait, 2, D T1
If (ErrorLevel = 0)
{
Keywait, 4, D T1
If (ErrorLevel = 0)
{
shutdown, 9
}
}
return

This works, but note that it has a couple of side effects - when you press 1, the 1 key is disabled for a second afterwards. This shouldn't be a problem if 1 is being used as a start button. Otherwise, you may wish to switch the keys around so that 2 or 4 is the hotkey. Also, this will also be activated if you pressed 1 then 2 then 4 fairly quickly, but assuming these aren't all "action" buttons, that's unlikely to happen by accident.

Thanks for cooking that up, but it does not seem to be working for me. I copied that into a notepad file with .ahk at the end and ran it. It is showing up in the taskbar but pressing 1, 2, and 4 does not initiate shutdown regardless of speed of pressing or order or if all pressed simultaneously. Is there something simple I could be missing here?

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Re: Autohotkey Shutdown Hotkey
« Reply #4 on: June 30, 2011, 07:54:46 pm »
Hmm, works fine for me, though I admit I did not test this exact script because I didn't want to shutdown my computer. ;) I tested this one

Quote
$1::
send 1
KeyWait, 2, D T1
If (ErrorLevel = 0)
{
Keywait, 4, D T1
If (ErrorLevel = 0)
{
msgbox It works!
}
}
return

which is exactly the same as the other one except it should display a popup box saying "It works!" instead of shutting down your computer. Give this one a try and see if you get the popup box. Just to make sure the problem isn't that your computer isn't responding to autohotkey's shutdown command for some reason.

SlainbytheBrain

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 25
  • Last login:August 23, 2011, 07:01:36 pm
Re: Autohotkey Shutdown Hotkey
« Reply #5 on: July 01, 2011, 01:15:48 am »
I got it to work. Thanks. I was adding it into an existing autohotkey text file when it was not working. Creating a separate text document specifically for that script was the ticket. Still new to this stuff!

Thanks again!