AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Play music as long as the keyboard is used (-> Anykey)
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 8:27 am    Post subject: Play music as long as the keyboard is used (-> Anykey) Reply with quote

Hi Forum,

I'd like to trigger a certain hotkey action when any key is pressed (letters and numbers only would actually suffice).

Is there an easy way to do this (in the meantime), or does it still require a rather complex loop, as I've learned from several older posts on a similar subject?

Thanks already,

David.P


Last edited by David.P on Fri Sep 12, 2008 5:16 pm; edited 2 times in total
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Fri Sep 12, 2008 8:52 am    Post subject: Re: How to "AnyKey::DoSomething" ? Reply with quote

David.P wrote:
Is there an easy way to do this (in the meantime), or does it still require a rather complex loop, as I've learned from several older posts on a similar subject?


Not unless a command/function is built-in Smile
_________________
URLGet - Internet Explorer based Downloader
Back to top
View user's profile Send private message Send e-mail
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 9:00 am    Post subject: Reply with quote

Well will I have to use something like:

Code:
~a::
~b::
~c::
~d::
~e::
....
~z::
DoSomething
Return

then?

Will this possibly have any negative impact on e.g. script performance or slow down keyboard typing input (provided "DoSomething" itself is quite light?

Cheers David.P
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Fri Sep 12, 2008 9:06 am    Post subject: Reply with quote

You could probably bump the following topic:

I am not sure, but there is a possibility for a two line solution.

Smile
_________________
URLGet - Internet Explorer based Downloader
Back to top
View user's profile Send private message Send e-mail
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 9:14 am    Post subject: Reply with quote

WOW -- but...

this is way beyond my intellectual capabilites Embarassed

I've searched that entire thread for words like "input", "keyboard" and "any key", but nothing that made sense to me hit my visual cortex Embarassed

Maybe someone with better understanding of that thread can point me to the right posting number...?

Thanks David
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Fri Sep 12, 2008 9:19 am    Post subject: Reply with quote

David.P wrote:
I've searched that entire thread for words like "input", "keyboard" and "any key", but nothing that made sense to me hit my visual cortex Embarassed


That topic does not already contain a solution..
I suggested you to request Laszlo on whether Wait-For-Any-Key could be implemented as machine code.

Smile
Back to top
View user's profile Send private message Send e-mail
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 9:55 am    Post subject: Reply with quote

Aahh, thanks.

I'll try my above quick'n'dirty solution then.

Cheers David.
Back to top
View user's profile Send private message
Sivvy



Joined: 21 Jul 2008
Posts: 726
Location: Calgary, AB, Canada

PostPosted: Fri Sep 12, 2008 1:30 pm    Post subject: Reply with quote

Maybe using the "Input" command?

Help File wrote:
L: Length limit (e.g. L5). The maximum allowed length of the input. When the text reaches this length, the Input will be terminated and ErrorLevel will be set to the word Max unless the text matches one of the MatchList phrases, in which case ErrorLevel is set to the word Match. If unspecified, the length limit is 16383, which is also the absolute maximum.

Maybe set length limit to one... then use "If ErrorLevel = Max".
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2214
Location: switzerland

PostPosted: Fri Sep 12, 2008 2:47 pm    Post subject: Reply with quote

maybe
Code:
;----------------------- anykey ---------------------------------
!a::
msgbox,,,You should press any key Use Escape to quit [Show this for 7 seconds] ,7
AA:
Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
msgbox,You have anykey pressed
;goto,aa
return

~esc::exitapp


or just this
http://www.autohotkey.com/forum/topic35683.html
Code:
AA:
Input, L, L1
msgbox,You have anykey pressed
goto,aa
return

~esc::exitapp


Last edited by garry on Fri Sep 12, 2008 2:58 pm; edited 1 time in total
Back to top
View user's profile Send private message
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 2:58 pm    Post subject: Reply with quote

Thanks -- but I don't want the script to WAIT for the user to press any key.

I need the script to "do something" every time any key is pressed -- but only in the background.

At the same time, the computer must be usable just normally.

For example "beep on any key".

Greetings David.P
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2214
Location: switzerland

PostPosted: Fri Sep 12, 2008 3:07 pm    Post subject: Reply with quote

not sure, tried write to editor , maybe use controlsend ....
Code:
AA:
Input, L, L1
send,%L%
SoundBeep,400,150
goto,aa
return

~esc::exitapp
Back to top
View user's profile Send private message
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 3:27 pm    Post subject: Reply with quote

Yeah, works with most keys, even capital letters, but not with Strg+[Key] nor with function keys.

(The latter don't have to beep -- but I need them to work normally).

Actually, what I need to do is

Code:
-  on any key press
-> send F10 and wait a little
-  if any more key is pressed, wait a little more
-  if no key was pressed for a while
-> send F9

Any idea how to do this...?

Cheers David.P
Back to top
View user's profile Send private message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Fri Sep 12, 2008 5:05 pm    Post subject: Reply with quote

You can use Input in a Loop:

Code:
Loop
{
   Input, SingleKey, L1 V, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
   Tooltip % SingleKey, 0, 0
}

_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
David.P



Joined: 18 Nov 2006
Posts: 304

PostPosted: Fri Sep 12, 2008 5:14 pm    Post subject: Reply with quote

Thanks but as said already, it is not about WAITING for any key, the problem is - simply put - just like:

Code:
"Dont' stop to play music in the background as long as the keyboard is being used. Then stop."

Any idea how to code such a thing would be much appreciated,

Thanks David.P

[edited the thread title for better clarity of the question]
Back to top
View user's profile Send private message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Fri Sep 12, 2008 5:23 pm    Post subject: Reply with quote

Did you try the code I posted? Earlier you said:

Quote:
I need the script to "do something" every time any key is pressed -- but only in the background.

At the same time, the computer must be usable just normally.

For example "beep on any key".


Just replace ToolTip with SoundBeep:

Code:

Loop
{
   Input, Key, L1 V, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}      
   If ErrorLevel
      SoundBeep
}


You can check the variable A_TimeIdle for time since keyboard input.
_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group