AutoHotkey Community

It is currently May 26th, 2012, 12:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: September 12th, 2008, 9:27 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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 September 12th, 2008, 6:16 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 12th, 2008, 9:52 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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 :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 10:00 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 10:06 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
You could probably bump the following topic:

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

:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 10:14 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
WOW -- but...

this is way beyond my intellectual capabilites :oops:

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 :oops:

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

Thanks David


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 10:19 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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 :oops:


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.

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 10:55 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Aahh, thanks.

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

Cheers David.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 2:30 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
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".


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 3:47 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
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 September 12th, 2008, 3:58 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 3:58 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 4:07 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
not sure, tried write to editor , maybe use controlsend ....
Code:
AA:
Input, L, L1
send,%L%
SoundBeep,400,150
goto,aa
return

~esc::exitapp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 4:27 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 6:05 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 6:14 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2008, 6:23 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
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
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, kkkddd1, RUBn, sks, StepO and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group