Jump to content

_IsPressed


 Share

Recommended Posts

Try this with the default parameter:

#include <Misc.au3>
While 1
    $key=_IsAnyKeyPressed(1)
    If $key then MsgBox(0,"",$Key)
WEnd
Func _IsAnyKeyPressed($UseNames=0)
    $number = StringSplit("01|02|04|05|06" & _
    "|08|09|0C|0D|10|11|12|13|14|1B|20|21|22" & _
    "|23|24|25|26|27|28|29|2A|2B|2C|2D|2E|30" & _
    "|31|32|33|34|35|36|37|38|39|41|42|43|44" & _
    "|45|46|47|48|49|4A|4B|4C|4D|4E|4F|50|51" & _
    "|52|53|54|55|56|57|58|59|5A|5B|5C|60|61" & _
    "|62|63|64|65|66|67|68|69|6A|6B|6C|6D|6E" & _
    "|6F|70|71|72|73|74|75|76|77|78|79|7A|7B" & _
    "|90|91|A0|A1|A2|A3|A4|A5", "|")
    
    $names = StringSplit("Left mouse|Right mouse" & _
    "|Middle mouse|X1 mouse|X2 mouse|BACKSPACE|TAB" & _
    "|CLEAR|ENTER|SHIFT|CTRL|ALT|PAUSE|CAPSLOCK|ESC" & _
    "|SPACEBAR|PAGEUP|PAGEDOWN|END|HOME|LEFT ARROW" & _
    "|UP ARROW|RIGHT ARROW|DOWN ARROW|SELECT|PRINT" & _
    "|EXECUTE|PRINT SCREEN|INS|DEL|0|1|2|3|4|5|6|7" & _
    "|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U" & _
    "|V|W|X|Y|Z|Left Win|Right Win|Num 0|Num 1|Num 2" & _
    "|Num 3|Num 4|Num 5|Num 6|Num 7|Num 8|Num 9|Multiply" & _
    "|Add|Separator|Subtract|Decimal|Divide|F1|F2|F3|F4" & _
    "|F5|F6|F7|F8|F9|F10|F11|F12|NUMLOCK|SCROLLLOCK|Left SHIFT" & _
    "|Right SHIFT|Left CONTROL|Right CONTROL|Left MENU|Right MENU","|")
    Dim $a=0
    For $i in $number
        $a+=1
        If _IsPressed(String($i)) Then 
            If $UseNames then 
                Return $names[$a-1]
            Else
                Return 1
            EndIf
        EndIf
    Next
    Return 0
EndFunc
Link to comment
Share on other sites

Try this with the default parameter:

#include <Misc.au3>
While 1
    $key=_IsAnyKeyPressed(1)
    If $key then MsgBox(0,"",$Key)
WEnd
Func _IsAnyKeyPressed($UseNames=0)
    $number = StringSplit("01|02|04|05|06" & _
    "|08|09|0C|0D|10|11|12|13|14|1B|20|21|22" & _
    "|23|24|25|26|27|28|29|2A|2B|2C|2D|2E|30" & _
    "|31|32|33|34|35|36|37|38|39|41|42|43|44" & _
    "|45|46|47|48|49|4A|4B|4C|4D|4E|4F|50|51" & _
    "|52|53|54|55|56|57|58|59|5A|5B|5C|60|61" & _
    "|62|63|64|65|66|67|68|69|6A|6B|6C|6D|6E" & _
    "|6F|70|71|72|73|74|75|76|77|78|79|7A|7B" & _
    "|90|91|A0|A1|A2|A3|A4|A5", "|")
    
    $names = StringSplit("Left mouse|Right mouse" & _
    "|Middle mouse|X1 mouse|X2 mouse|BACKSPACE|TAB" & _
    "|CLEAR|ENTER|SHIFT|CTRL|ALT|PAUSE|CAPSLOCK|ESC" & _
    "|SPACEBAR|PAGEUP|PAGEDOWN|END|HOME|LEFT ARROW" & _
    "|UP ARROW|RIGHT ARROW|DOWN ARROW|SELECT|PRINT" & _
    "|EXECUTE|PRINT SCREEN|INS|DEL|0|1|2|3|4|5|6|7" & _
    "|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U" & _
    "|V|W|X|Y|Z|Left Win|Right Win|Num 0|Num 1|Num 2" & _
    "|Num 3|Num 4|Num 5|Num 6|Num 7|Num 8|Num 9|Multiply" & _
    "|Add|Separator|Subtract|Decimal|Divide|F1|F2|F3|F4" & _
    "|F5|F6|F7|F8|F9|F10|F11|F12|NUMLOCK|SCROLLLOCK|Left SHIFT" & _
    "|Right SHIFT|Left CONTROL|Right CONTROL|Left MENU|Right MENU","|")
    Dim $a=0
    For $i in $number
        $a+=1
        If _IsPressed(String($i)) Then 
            If $UseNames then 
                Return $names[$a-1]
            Else
                Return 1
            EndIf
        EndIf
    Next
    Return 0
EndFunc

thanks a lot, it worked, now im trying to understand what u did, may i ask u to explain how does your program work

Link to comment
Share on other sites

thanks a lot, it worked, now im trying to understand what u did, may i ask u to explain how does your program work

Sure.

If works by simply rapidly cycling all the possible keys through the _IsPressed function. So effectively, it would be the equivalent to doing this:

While 1
If _IsPressed(01) then Return 1
If _IsPressed(02) then Return 1
;... etc
WEnd
Link to comment
Share on other sites

  • 2 weeks later...

Thanks, been away from Autoit and could`nt remember how to read the mouse keys!

If there`s a list of return hex codes for _ispressed in the help file, I could`nt find the darn thing...

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

01 Left mouse button
  02 Right mouse button
  04 Middle mouse button (three-button mouse)
  05 Windows 2000/XP: X1 mouse button
  06 Windows 2000/XP: X2 mouse button
  08 BACKSPACE key
  09 TAB key
  0C CLEAR key
  0D ENTER key
  10 SHIFT key
  11 CTRL key
  12 ALT key
  13 PAUSE key
  14 CAPS LOCK key
  1B ESC key
  20 SPACEBAR
  21 PAGE UP key
  22 PAGE DOWN key
  23 END key
  24 HOME key
  25 LEFT ARROW key
  26 UP ARROW key
  27 RIGHT ARROW key
  28 DOWN ARROW key
  29 SELECT key
  2A PRINT key
  2B EXECUTE key
  2C PRINT SCREEN key
  2D INS key
  2E DEL key
  30 0 key
  31 1 key
  32 2 key
  33 3 key
  34 4 key
  35 5 key
  36 6 key
  37 7 key
  38 8 key
  39 9 key
  41 A key
  42 B key
  43 C key
  44 D key
  45 E key
  46 F key
  47 G key
  48 H key
  49 I key
  4A J key
  4B K key
  4C L key
  4D M key
  4E N key
  4F O key
  50 P key
  51 Q key
  52 R key
  53 S key
  54 T key
  55 U key
  56 V key
  57 W key
  58 X key
  59 Y key
  5A Z key
  5B Left Windows key
  5C Right Windows key
  60 Numeric keypad 0 key
  61 Numeric keypad 1 key
  62 Numeric keypad 2 key
  63 Numeric keypad 3 key
  64 Numeric keypad 4 key
  65 Numeric keypad 5 key
  66 Numeric keypad 6 key
  67 Numeric keypad 7 key
  68 Numeric keypad 8 key
  69 Numeric keypad 9 key
  6A Multiply key
  6B Add key
  6C Separator key
  6D Subtract key
  6E Decimal key
  6F Divide key
  70 F1 key
  71 F2 key
  72 F3 key
  73 F4 key
  74 F5 key
  75 F6 key
  76 F7 key
  77 F8 key
  78 F9 key
  79 F10 key
  7A F11 key
  7B F12 key
  7C-7F F13 key - F16 key
  80H-87H F17 key - F24 key
  90 NUM LOCK key
  91 SCROLL LOCK key
  A0 Left SHIFT key
  A1 Right SHIFT key
  A2 Left CONTROL key
  A3 Right CONTROL key
  A4 Left MENU key
  A5 Right MENU key
  BA;
  BB =
  BC ,
  BD -
  BE .
  BF /
  C0 `
  DB [
  DC \
  DD ]

here they are if you dont dl beta...

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...