seres Posted July 30, 2008 Share Posted July 30, 2008 hello how can i make a combination of key pressed so it activates something, like i want to open a window by typing lm i got an idea but im not sure While 1 if _ispressed (4c) & if _ispressed (4D) then MsgBox(0, "window","nop1") Sleep(100) WEnd Link to comment Share on other sites More sharing options...
Jon8c Posted July 30, 2008 Share Posted July 30, 2008 Sounds like you should use "HotKeySet()." Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 30, 2008 Share Posted July 30, 2008 Typing "lm" and holding l+m at the same time are two different things, you need to be more specific. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
FreeFry Posted July 30, 2008 Share Posted July 30, 2008 Using your example, this could work: #include <Misc.au3> While 1 If _IsPressed("4c") And _IsPressed("4D") Then; use the logical operator And instead of &(as & adds stuff together) MsgBox(0, "window","nop1") EndIf Sleep(10); If you're gonna use _IsPresed, you must use it in a tight loop, or you might "miss" keystrokes. WEnd But as AdmiralAlkex said, if you want to type it(as in a sentence), then it's a whole other thing(involving having to check every key on the keyboard most probably)... Link to comment Share on other sites More sharing options...
Paulie Posted July 30, 2008 Share Posted July 30, 2008 But as AdmiralAlkex said, if you want to type it(as in a sentence), then it's a whole other thing(involving having to check every key on the keyboard most probably)...Or use a Keyboard Hook.http://www.autoitscript.com/forum/index.php?showtopic=55694 Link to comment Share on other sites More sharing options...
FreeFry Posted July 31, 2008 Share Posted July 31, 2008 Or use a Keyboard Hook.http://www.autoitscript.com/forum/index.php?showtopic=55694Indeed. Link to comment Share on other sites More sharing options...
rasim Posted July 31, 2008 Share Posted July 31, 2008 seresTry this:Global Const $L = 0x4C Global Const $M = 0x4D HotKeySet("{ESC}", "_Exit") While 1 $aLRet = DllCall("user32", "ushort", "GetKeyState", "int", $L) $aMRet = DllCall("user32", "ushort", "GetKeyState", "int", $M) If ($aLRet[0] > 1) And ($aMRet[0] > 1) Then MsgBox(0, "window","nop1") Sleep(100) WEnd Func _Exit() Exit EndFunc Link to comment Share on other sites More sharing options...
FreeFry Posted July 31, 2008 Share Posted July 31, 2008 seres Try this: Global Const $L = 0x4C Global Const $M = 0x4D HotKeySet("{ESC}", "_Exit") While 1 $aLRet = DllCall("user32", "ushort", "GetKeyState", "int", $L) $aMRet = DllCall("user32", "ushort", "GetKeyState", "int", $M) If ($aLRet[0] > 1) And ($aMRet[0] > 1) Then MsgBox(0, "window","nop1") Sleep(100) WEnd Func _Exit() Exit EndFunc That'll only work if the two keys are pressed at the same time, he's probably wanting to detect a sentence being written. Nice example though. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now