Sign in to follow this  
Followers 0
Hello Me You

If _IsPressed("any_key") Then ..

25 posts in this topic

Is it possible to make to do this?


Random

Share this post


Link to post
Share on other sites



Is it possible to make to do this?

:whistle: Of course :)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Ya... that's what he was looking for...

Guess it was really hard to find (Considering that's the exact copy of the example in the help file :whistle: )

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm being sarcastic. It's pretty obvious what he's looking for, and that wasn't it.

Edited by xcal

Share this post


Link to post
Share on other sites

I still can't find it.... Any suggestions?


Random

Share this post


Link to post
Share on other sites

ummm....where is the "any key" on the keyboard? That is what you are asking..right?

Otherwise....are you asking for when whatever key is pressed, you get a report on that key? If the later is what you want, what you are asking for is a keylogger. and that is a :whistle:

Share this post


Link to post
Share on other sites

Maybe he's just looking to check for keyboard input to end a screensaver or something like that, just to test for idle time? If that's the case I'm currently using something like this in a screensaver I made:

Dim $i_LastActive = _LastActive()
While 1
     If $i_LastActive <> _LastActive() Then ExitLoop
     Sleep(100)
WEnd

Func _LastActive($v_User32Dll = 'user32.dll')
    Local $str_LastInput = DllStructCreate('uint;dword')
    DllStructSetData($str_LastInput, 1, DllStructGetSize($str_LastInput))
    DllCall($v_User32Dll, 'int', 'GetLastInputInfo', 'ptr', DllStructGetPtr($str_LastInput))

    Return DllStructGetData($str_LastInput, 2)
EndFunc

This is a modified version of a function that Gary once wrote. I don't have the original anymore though.

Share this post


Link to post
Share on other sites

Another simple way to to just use a for loop, like

For $i = 1 to 100

If _IsPressed(hex($i)) Then MsgBox(0, "Something", "Something else"

Next

You may need to strip the hex string of the 0x...

Share this post


Link to post
Share on other sites

You can't find the "any key?"

ummm....where is the "any key" on the keyboard? That is what you are asking..right?

Otherwise....are you asking for when whatever key is pressed, you get a report on that key? If the later is what you want, what you are asking for is a keylogger. and that is a :whistle:

I want if ANY key ("a" or "b" or "c" or "d" or "e" or other keys...) do something

Random

Share this post


Link to post
Share on other sites

I want if ANY key ("a" or "b" or "c" or "d" or "e" or other keys...) do something

You are not going to get help like that - what you are asking for is a keylogger, look it up via search and you will see why.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

You are not going to get help like that - what you are asking for is a keylogger, look it up via search and you will see why.

What about the ocasional program that says "Press any key to Continue"?? Where did he say he wanted to log the key that was pressed? All i can see he wants is If any key (a, b, c, d, e, f, g...) was press, do something. I will admit it looks slightly suss though..... :whistle:

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I think you guys need to stop being so suspicious, if he wanted a keylogger, he would just download one, not write it! And besides, who cares if he does want to write one, that's his choice!

#Include <misc.au3>

While 1

GUIGetMsg()

For $i = 1 to 94

If _IsPressed(Hex($i)) Then MsgBox(0, "Key press!", "You pressed key number: " & $i)

Next

WEnd

Hope that's what you wanted

Edited by magician13134

Share this post


Link to post
Share on other sites

Maybe he's just looking to check for keyboard input to end a screensaver or something like that, just to test for idle time? If that's the case I'm currently using something like this in a screensaver I made

Hm-m... may be my edition with tow functions more flexible for screensavers:
#include <Date.au3>

$IdleMinimum = 5000 ; Minimum inactivity in seconds

While 1
    $iIdle = _IdleWaitStart ($IdleMinimum)
    ConsoleWrite (_Now () & ' ' & @UserName & ' already inactive ' & _TickToTimeString ($iIdle) & @CRLF)
    $iIdle = _IdleWaitCommit($IdleMinimum)
    ConsoleWrite (_Now () & ' ' & @UserName & ' inactivity amounts to ' & _TickToTimeString ($iIdle) & @CRLF)
Wend

Func _TickToTimeString ($iTicks)
    Local $iHours, $iMins, $iSecs, $sText = ''
    _TicksToTime  ($iTicks, $iHours, $iMins, $iSecs)
    If $iHours Then $sText = $iHours & ' hours '
    If $iMins  Then $sText = $sText & $iMins & ' minutes '
    If $iSecs  Then $sText = $sText & $iSecs & ' seconds'
    If $sText = '' Then $sText = 'less than second'
    Return $sText
EndFunc

; Wait for starting user inactivity
; Return inactivity time in milliseconds
; $idlesec - minimum inactivity period in milliseconds
Func _IdleWaitStart ($idlesec)
    Local $aRet, $iSave, $iTick, $LastInputInfo = DllStructCreate ("uint;dword")
    DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))
    DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
    Do
        Sleep(200)
        $iSave= DllStructGetData ($LastInputInfo, 2)
        DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
        $aRet = DllCall ("kernel32.dll", "long", "GetTickCount")
    Until ($aRet[0] - DllStructGetData ($LastInputInfo, 2))> $idlesec
    Return $aRet[0] - DllStructGetData ($LastInputInfo, 2)
EndFunc

; Wait for ending user inactivity
; Return inactivity time in milliseconds
; $idlesec - minimum inactivity period in milliseconds
Func _IdleWaitCommit ($idlesec)
    Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword")
    DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))
    DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
    Do
        $iSave = DllStructGetData ($LastInputInfo, 2)
        Sleep(200)
        DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
    Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec
    Return DllStructGetData ($LastInputInfo, 2)-$iSave
EndFunc

Share this post


Link to post
Share on other sites

of course noone cares if he makes a keylogger, it just makes AutoIt look bad...lol


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

I think you guys need to stop being so suspicious, if he wanted a keylogger, he would just download one, not write it! And besides, who cares if he does want to write one, that's his choice!

#Include <misc.au3>

While 1

GUIGetMsg()

For $i = 1 to 94

If _IsPressed(Hex($i)) Then MsgBox(0, "Key press!", "You pressed key number: " & $i)

Next

WEnd

Hope that's what you wanted

Yes, thanks! That was exactly what I wanted.

Random

Share this post


Link to post
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
Sign in to follow this  
Followers 0