AutoHotkey Community

It is currently May 26th, 2012, 11:20 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: November 16th, 2009, 4:14 pm 
Offline

Joined: May 31st, 2007, 5:26 am
Posts: 23
#H::
{
; Call the Windows API function "SetSuspendState" to have the system suspend or hibernate.
; Windows 95/NT4: Since this function does not exist, the following call would have no effect.
; Parameter #1: Pass 1 instead of 0 to hibernate rather than suspend.
; Parameter #2: Pass 1 instead of 0 to suspend immediately rather than asking each application for permission.
; Parameter #3: Pass 1 instead of 0 to disable all wake events.

DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
Return
}


If I change the Hotkey from #H:: to ^Numpad0:: then this code is not executed when I enter ctrl+0 on the numpad.

Can someone explain?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2009, 4:43 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
I can't really explain, because it works for me (including Hibernate).
But aren't there any modifier keys stuck (not physically but acting like they are down)?
Just a remark, you don't need the braces {}, only in Functions, if-else, etc.
Although it seems to work, code like this is the normal way:
Code:
^Numpad0::
   msgbox test
   DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2009, 5:50 pm 
Offline

Joined: May 31st, 2007, 5:26 am
Posts: 23
Thanks for the reply.

I removed the braces, and my original Hotkey still works, but the new one still does not. No stuck keys either...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 3:34 am 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
Does it work with e.g. ^H hotkey?
Try script below, it should show the Ctrl and Numpad0 status. You can extend the script with other keys.
In case you have another keyboard, try with that one. If it's a hardware problem, then it could save you a lot of time.
Code:
Loop {
   numpad0Key := GetKeyState("Numpad0", "P")
   ctrlKey := GetKeyState("ctrl", "P")
   tooltip ctrlKey= %ctrlKey% `nnumpad0Key= %numpad0Key%
   Sleep 100
}
return
F9::ExitApp


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cerberus, Google Feedfetcher, Maestr0, rbrtryn, Tipsy3000, XstatyK, Yahoo [Bot] and 67 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group