Jump to content

combinations


Recommended Posts

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

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

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

:P

Link to comment
Share on other sites

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

:P

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. :P
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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