Jump to content

Recommended Posts

Posted

You can specify a hot key for CTRL-ALT-DEL but not block it. This is impossible in Windows NT-based systems (I think). Moreover there are no good reasons to do so.

Block Crtl+Alt+Delete

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe]

"Debugger"="Hotkey Disabled"

Posted (edited)

That's not really blocking. It's asking not to run. There is a difference.

Where blocking would be not letting windows take action on ctrl+alt+del by providing a veto as done to other "blockable" key combinations.

This registry editing method still lets windows initiate a process to run taskmgr.exe which check either the registry value tells it to run or not.

So, this is not blocking and essentially not reliable as it is not practical to keep checking whether the value of registry has been changed or not as other programs or the user might set it to On.

Edited by Shafayat

[Not using this account any more. Using "iShafayet" instead]

Posted

The opt('onexitfunc'.... Has been removed. Search the autoit help file for details.

[Not using this account any more. Using "iShafayet" instead]

Posted (edited)

Thx, I guess I fixed it:

Global $OnHotKeyExit = Opt(OnAutoItExitRegister('OnHotKeyExit'))

After this example scripts from the first post work well but I wanted to check another simple script and it doesnt work.

#Include <HotKey.au3>

Global Const $VK_F12 = 0x7B

_HotKeyAssign($VK_F12, 'Set')


While 1
    Sleep(10)
WEnd

Func Set()
    send("a")
EndFunc

I really dont know wtf? ;/

Edited by m4tius
Posted (edited)

Thx, I guess I fixed it:

Global $OnHotKeyExit = Opt(OnAutoItExitRegister('OnHotKeyExit'))

Should be

OnAutoItExitRegister("OnHotKeyExit")

and delete the call to $OnHotKeyExit in the function "OnHotKeyExit" itself.

After this example scripts from the first post work well but I wanted to check another simple script and it doesnt work.

#Include <HotKey.au3>

Global Const $VK_F12 = 0x7B

_HotKeyAssign($VK_F12, 'Set')


While 1
    Sleep(10)
WEnd

Func Set()
    send("a")
EndFunc

I really dont know wtf? ;/

Beats me, add a consolewrite("a" & @crlf) to the set function and you'll see that it IS called, but send doesn't seem to work....

Edit:

This works...

Func Set()
    ConsoleWrite("a" & @crlf)
    ControlSend("","","","a")
EndFunc
Edited by KaFu
Posted (edited)

I was just changing the numbers in $VK_F12 of previous script and shift, alt, ctrl and winkey didnt work for me... The rest was ok.

Func Set()
    ControlSend("","","","a")
EndFunc

^ works without ConsoleWrite

Edited by m4tius
Posted (edited)

Unfortunate problem with this UDF... using these hotkeys causes pauses in the program's reading of my input. This includes mouse movement and keyboard controls. Though mouse clicks seem fine. Anyone have any idea how to fix this?

Just found out that NOBLOCKHOTKEY flag prevents this problem... unfortunately that's a silly workaround. Any ideas?

Edited by Gar
Posted

Unfortunate problem with this UDF... using these hotkeys causes pauses in the program's reading of my input. This includes mouse movement and keyboard controls. Though mouse clicks seem fine. Anyone have any idea how to fix this?

Just found out that NOBLOCKHOTKEY flag prevents this problem... unfortunately that's a silly workaround. Any ideas?

Where your code?
Posted (edited)

_HotKeyAssign($VK_F2, 'MyFunction', $HK_FLAG_DEFAULT, $hWND)

Func MyFunction()

EndFunc

I was able to reduce it to just this and it still caused the blocked input... I believe this program checks physical key states for its input, too, if that matters.

Edited by Gar
  • 8 months later...
Posted (edited)

Under Windows 7 (64 bit), assigning Win+L to a HotKey doesn't replace Win+L. Both the HotKey func and the Win+L key are executed. It therefore seems like Win+L can't be disabled as is the case with Ctrl+Alt+Del. Does anybody know if there is a workaround for this? Can Win+L be completely replaced using HotKey or any other method?

Here's a quick example showing this:

#Include <HotKey.au3>
#Include 'vkConstants.au3'

HotKeySet('{Esc}', '_Quit')
_HotKeyAssign(BitOR($CK_WIN, $VK_L), 'ReplaceWinLock')

While 1
    Sleep(10)
WEnd

Func ReplaceWinLock()
    MsgBox (0, "Win+L Pressed", "Lock Station (Win+L) still executed and so did the 'ReplaceWinLock' function which displayed this dialog.")
EndFunc   ;==>ReplaceWinLock

Func _Quit()
    Exit
EndFunc   ;==>_Quit

I've been trying to find a solution to this problem for several days now without success...

Any help would be greatly appreciated,

Ian

P.S.: Please note that the same problem occurs when using the following UDF's: _LimitInputEx.au3, _BlockInputEx.au3. Blocking Win+L is not possible even if the WinKey is disabled. Disabling the LockWorkStation feature using the following registry fix [link] doesn't help since the Win+L key combination is still executed even though the LockWorkStation screen does not appear. Pressing Win+L actually re-enables other WinKey combinations such as Win+R, Win+M, Win+D, etc. even though the WinKey is still disabled. Furthermore, the WinKey remains pressed following a Win+L key combination. Pressing 'R' on it's own will therefore execute the 'Run' dialog. I will most likely post the above in the _LimitInputEx.au3 or _BlockInputEx.au3 topics if no solution is found here.

Edited by intime69

Developer and Co-OwnerInTime Applicaitons Inc.

Posted

I've been working with HotKey.au3 for a couple days now ... and am getting strange results. Yet, the UDF seems to be just what I need. I've attached a simplified version of what I'm trying. I open WordPad and try to insert characters ... with very limited success. Plus, there's something I'm confused about in the first post, which includes this comment:

You can specify a hot key, any key, including the CTRL-ALT-DEL, F12, WIN-..., etc

But when I've tried to use the RWIN key, I get no result ... and it seems to affect Windows to the point that I had to reboot to restore full keyboard functionality after exiting my test script. I've tried to model after the examples, so I don't see where it's missing anything. Another strange result is that only the Carat() function ever executes ... never the Amper(). My goal is simply to have the APPSKEY send one of two different characters (depending on the shift state). Having access to the RWIN key would be icing on the cake.

#Include <HotKey.au3>

Global Const $VK_ESCAPE = 0x1B
Global Const $VK_RWIN = 0x5C
Global Const $VK_APPS = 0x5D
Global Const $VK_SHIFT = 0x10
$ex = Chr(120)

; Assign "CTRL-ESC" with Quit() ... and the other keys
_HotKeyAssign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit')               ;  this works ... all the time
_HotKeyAssign($VK_APPS, "Amper")                             ;  this works ... some of the time
_HotKeyAssign(BitOr($CK_CONTROL, $VK_APPS), "Carat")        ;  this works ... most of the time
_HotKeyAssign(BitOr($VK_SHIFT, $VK_APPS), "Carat")              ;  this doesn't work <<<<<<<
_HotKeyAssign($VK_RWIN, "Exes")                                ;  this doesn't work <<<<<<<

_HotKeyEnable()         ; is this needed?

While 1
    Sleep(10)
WEnd
;------------------------------------------------------------------------------------
Func Amper()
    MsgBox(0, 'AppKey', '... has been pressed!', 2)
    Send("{ASC 38}")
EndFunc

Func Carat()
    MsgBox(0, 'Shift Apps', '... has been pressed!',2)
    Send("{ASC 94}")
EndFunc

Func Exes()
    MsgBox(0, 'Exes', '... has been pressed!',2)
    Send("{" & $ex & " 3}")
EndFunc

Func Quit()
    MsgBox(0, 'Ctrl-Esc', '... has been pressed!',2)
_HotKeyDisable()        ; is this needed?
Exit
EndFunc   ;==>Quit

If someone who's successfully used this UDF could take a look at this, I could certainly use some help. Thanks in advance.

BTW, the only change I've made to v1.6 was to implement the OnAutoitExitRegister("OnHotkeyExit") fix.

Posted (edited)
Posted

Yashied, thank you for responding.

I think I understand you in that Windows will always process the RWIN key, so it's not practical to use it. But the other part about CK, I don't quite follow. Which of these three Hotkey assignments are OK:

_HotKeyAssign($VK_APPS, "Amper")
_HotKeyAssign(BitOr($CK_CONTROL, $VK_APPS), "Carat")
_HotKeyAssign(BitOr($VK_SHIFT, $VK_APPS), "Carat")
Is it only the VK_SHIFT and VK_APPS combination that won't work?

Also, is there anything special I need to do to cause Windows to ignore the key that I've used? Or is that all handled by HotKey.au3? And I was uncertain whether I need to do any clean up when my script exits. Or is that also handled by HotKey.au3?

Sorry for these basic questions, but I'm trying to get this right. I appreciate your help.

Posted (edited)

_HotKeyAssign($VK_APPS, "Amper") - OK

_HotKeyAssign(BitOr($CK_CONTROL, $VK_APPS), "Carat") - OK

_HotKeyAssign(BitOr($VK_SHIFT, $VK_APPS), "Carat") - Invalid combination

Replace to

_HotKeyAssign(BitOr($CK_SHIFT, $VK_APPS), "Carat")

Do not use the following values.

VK_SHIFT

VK_CONTROL

VK_MENU

VK_LWIN

VK_RWIN

VK_LSHIFT

VK_RSHIFT

VK_LCONTROL

VK_RCONTROL

VK_LMENU

VK_RMENU

Edited by Yashied
  • 4 weeks later...
Posted

_HotKeyAssign($VK_APPS, "Amper") - OK

_HotKeyAssign(BitOr($CK_CONTROL, $VK_APPS), "Carat") - OK

_HotKeyAssign(BitOr($VK_SHIFT, $VK_APPS), "Carat") - Invalid combination

Replace to

_HotKeyAssign(BitOr($CK_SHIFT, $VK_APPS), "Carat")

Do not use the following values.

VK_SHIFT

VK_CONTROL

VK_MENU

VK_LWIN

VK_RWIN

VK_LSHIFT

VK_RSHIFT

VK_LCONTROL

VK_RCONTROL

VK_LMENU

VK_RMENU

Yashied, so does this mean that there is no way to assign a hot key to the WinKey. I simply want to display a message if the WinKey is pressed (which usually shows the Start Menu). Is this possible?

Developer and Co-OwnerInTime Applicaitons Inc.

Posted

Yes it is, just use the values as defined in the script itself:

Global Const $CK_SHIFT = 0x0100

Global Const $CK_CONTROL = 0x0200

Global Const $CK_ALT = 0x0400

Global Const $CK_WIN = 0x0800

Posted

Yes it is, just use the values as defined in the script itself:

Global Const $CK_SHIFT = 0x0100

Global Const $CK_CONTROL = 0x0200

Global Const $CK_ALT = 0x0400

Global Const $CK_WIN = 0x0800

I tried it a few times and it doesn't seem to work. Furthermore, those global constants are already defined in the UDF. Here's my code:

_HotKeyAssign($CK_WIN, 'Message')

... but it doesn't do nothing. Am I assigning this the wrong way?

Ian

Developer and Co-OwnerInTime Applicaitons Inc.

Posted (edited)

Yep, see doc for _HotKeyAssign():

; The combination of keys can be composed of one function key (VK) and some system keys (CK). This code can not consist
; only of the system keys. To combine system keys with the function key use BitOR(). See following examples.
; (VK-constants are used in the vkConstants.au3)

#Include <HotKey_v1.6.au3>

Global Const $VK_ESCAPE = 0x1B
Global Const $VK_M = 0x4D

; Assign "WIN+M" with Message() and set extended function call
_HotKeyAssign(BitOR($CK_WIN,$VK_M), 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL))

; Assign "ESC" with Quit()
_HotKeyAssign($VK_ESCAPE, 'Quit')

While 1
    Sleep(10)
WEnd

Func Message($iKey)
    MsgBox(0, 'Hot key Test Message', 'WIN+M (0x' & Hex($iKey, 4) & ') has been pressed!')
EndFunc   ;==>Message

Func Quit()
    Exit
EndFunc   ;==>Quit
Edited by KaFu
Posted

Yep, see doc for _HotKeyAssign():

Okay, so setting the WinKey on it's own doesn't work... I guess I should use _isPressed instead! :)

Oh well! Thanks for taking the time to code up an alternative example. I really appreciate it!

Ian

Developer and Co-OwnerInTime Applicaitons Inc.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...