Jump to content

Recommended Posts

Posted

I'm trying to make a script work that will put my HTPC into sleep/standby mode on a particular keypress (cntrl+alt+s in this instance).  I found the following code online, but unfortunately it doesn't seem to work.  I don't have any experience writing scripts and am pretty unfamiliar with the syntax so I googled around to find an answer or an alternate script but so far have been unable to make anything work.  Creating a windows shortcut won't work in this instance, it has to be a script.  I'd appreciate any help that anyone could provide.  Thanks in advance!

 

;Sleep system: (ctrl+alt+s)
^!s::
DllCall("PowrProfSetSuspendState", "int", 0, "int", 0, "int", 0)
return

  • Moderators
Posted

twax462,

Welcome to the AutoIt forums. :)

That does not look like AutoIt syntax, more like AutoHotKey - are you sure you are in the right place? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

twax462,

Welcome to the AutoIt forums. :)

That does not look like AutoIt syntax, more like AutoHotKey - are you sure you are in the right place? :huh:

M23

You're absolutely right.  I had misread the post that I got the code from and made the mistake of thinking it was an autoit script as opposed to AutoHotKey.  That's what hours spent configuring Flirc, a logitech remote, and XBMC have done to my brain.  My apologies...but thank you for the quick respose. 

  • Moderators
Posted

twax462,

No problem. But are you sure you do not want to use AutoIt rather than its inferior spin-off? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

twax462,

No problem. But are you sure you do not want to use AutoIt rather than its inferior spin-off? :huh:

M23

Haha.  At this point in time I'm inclined to use whatever gets the job done.  I was able to get that code working as-is in AHK, but if someone feels inclined to come up with something equivalent for me with AutoIt that will work then I'd be happy to give that a try.

  • Moderators
Posted

twax462,

It looks as if this should work (untested): ;)

#include< AutoItConstants.au3>

HotKeySet("^!s", "_Standby")

While 1
    Sleep(10)
WEnd

Func _Standby()
    Shutdown($SD_STANDBY)
EndFunc
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...