Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Crazy Scripting : Scriptlet to find Scancode of a Key


  • Please log in to reply
36 replies to this topic
EdScriptNewbie
  • Members
  • 117 posts
  • Last active: Aug 19 2013 07:32 PM
  • Joined: 20 Jan 2007
I'm really hoping to solve this b/c it's driving me batty.

> h=Hook Hotkey,
> s=Suppressed (blocked),
> i=Ignored because it was generated by an AHK script,
> a=Artificial,
> #=Disabled via #IfWinActive/Exist.


The problem keystrokes are all "i" keys. They show up when I'm running your AutoHotkey script, whether or not I have other scripts running. Could "i" keystrokes come from any source -other- than "generated by an AHK script"?

THANKS

...Ed


...Ed

michaelbeijer
  • Members
  • 16 posts
  • Last active: Jan 09 2015 09:26 AM
  • Joined: 13 Dec 2011

Thanks SKAN,

 

This is just what I needed!

 

Michael



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

Sorry to derail, but I am looking into the possibility of using scancode detection as a basis for replacing the hotkey gui control.

I have a post with a bit more info on what I am talking about here.

Any help appreciated.



New Daddy
  • Members
  • 12 posts
  • Last active: Dec 20 2013 07:28 PM
  • Joined: 15 Jan 2012

It's been a while since SKAN wrote this code, but it still works like charm!

This was what I was looking for. Thanks!

 

While experimenting with a keylogger that captures system-wide key strokes using a hook, I transferred a small snippet of the code which works in AHK natively.

Nothing special. Run it and when GUI is in focus press a key and the clipboard will contain the scancode of the key which can be used as hotkey or with Send commands:
 

SetFormat, Integer, Hex
Gui +ToolWindow -SysMenu +AlwaysOnTop
Gui, Font, s14 Bold, Arial
Gui, Add, Text, w100 h33 vSC 0x201 +Border, {SC000}
Gui, Show,, % "// ScanCode //////////"
Loop 9
  OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
Return

ScanCode( wParam, lParam ) {
 Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2) 
 GuiControl,, SC, %Clipboard%
}
:)

 



mazeratti
  • Members
  • 1 posts
  • Last active: Feb 08 2015 12:48 PM
  • Joined: 08 Feb 2015

Doesnt work for me.

When i press any button nothing changes, neither label in the GUI, neither by clipboard.

 

AHK 1.1.18.00.



3rror
  • Members
  • 18 posts
  • Last active:
  • Joined: 29 May 2013

From AHK 1.1 documentation:

 

GetKeyName(Key), GetKeyVK(Key), GetKeySC(Key) [v1.1.01+]: Retrieves the name/text, virtual key code or scan code of a key. Key can be a VK or SC code, such as "vkA2" or "sc01D", a combination of both, or a key name. For example, both GetKeyName("vk1B") and GetKeyName("Esc") return "Escape", while GetKeyVK("Esc") returns 27.

 

http://ahkscript.org....htm#GetKeyName



normanporman
  • New members
  • 1 posts
  • Last active: Jul 17 2015 10:52 AM
  • Joined: 17 Jul 2015
A slight improvement — exit by «Esc» and instant paste.
getScanCode.ahk
SetFormat, Integer, Hex
Gui +ToolWindow -SysMenu +AlwaysOnTop
Gui, Font, s14 Bold, Arial
Gui, Add, Text, w100 h33 vSC 0x201 +Border, {SC000}
Gui, Show,, % "// ScanCode //////////"
Loop 9
  OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
Return

ScanCode( wParam, lParam ) {
 value := SubStr((((lParam>>16) & 0xFF)+0xF000),-2)
 if(value!=001)
 	{
 	Clipboard := "SC" . value
 	}
 GuiControl,, SC, %Clipboard%
}

GuiClose:
GuiEscape:
ExitApp
main.ahk
!+CapsLock::
  RunWait, C:\ahk\getScanCode.ahk
  SendInput, %Clipboard%
return