AutoHotkey Community

It is currently May 27th, 2012, 9:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 8th, 2006, 1:40 am 
basically I want to be able to toggle pressing of the "]" key, i need this key to be pressed down continuously for a period of time.

For example i'd like to be able to press the + key to activate the ] key being pressed continuously, then press + again to turn it off.

I'm pretty sure its a simple script, but i couldn't knock together a working one from the FAQ.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2006, 1:44 am 
I meant to say, that I figured this could be done using a Loop of some sort to continously 'send' ] to windows.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2006, 6:17 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Try this:

Code:
count = 0

NumpadAdd::
if count = 0
{
  count = 1
  settimer, send, 1
}
else
{
  count = 0
  settimer, send, off
}
return


send:
send, {]}
return

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2006, 7:19 am 
Online
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
Serenity wrote:
Try this:
  • You don't need to initialize vars to 0
  • When doing a toggle it's much shorter to do: flag:=!flag
  • ] is not special enough to need {]}
Code:
NumpadAdd::
if !sending
   SetTimer, Send, 0
else
   SetTimer, Send, Off
sending:=!sending
return

Send:
Send, ]
return

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2006, 7:29 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Thanks for the tips!

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2006, 2:33 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
For the original request, it's possible something simpler would satisify it:
Code:
NumpadAdd::
if GetKeyState("]")
    Send {] up}
else
    Send {] down}
return

Of course, this won't be sufficient if you need the character to auto-repeat as though you're holding it down physically on the keyboard.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2006, 10:10 pm 
Thanks for all of your input! Your last script worked perfect thanks Chris :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2006, 10:19 am 
Online
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
Chris wrote:
Of course, this won't be sufficient if you need the character to auto-repeat...

...I notcied that too in Notepad & didn't know if his prog would work better holding it down or auto repeating...so I posted the auto repeat version...cuz it had more of a visible effect...

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 1:13 am 
I'm trying to write something very similar but I want to toggle the function key "F23" on and off. But I don't seem to be getting it right. Any help would be great.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 1:24 am 
Offline

Joined: November 17th, 2005, 10:14 pm
Posts: 196
Location: Leicester, UK
Hello christopher

Lets see what you have so far.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 2:40 am 
yeah i'm not very proactive with my post. i would have posted code but i was on my way out to dinner.

alright, i basically modeled it after the last posts.

I have a specialized keyboard that uses the special character "SC06E" which also equates to F23 on the keyboard. So I guess I can use any syntax, but I had to write it properly.

Code:
F23::
if GetKeyState("F23")  ; should find F23 is up, after initial press down
    Send {F23 down}   ; sets the function key down and exits program until it is pressed again.
else
    Send {F23 up}
return


This isn't working, i think some of my syntax is wrong. How could I go about this using the SC06E designation?

Also, do I need a $F23 in the first line of the code?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 1:04 pm 
Hello Christopher

This has been a good exercise for me so thanks. :)
I don't have an F23 so F1 was the order of the day.
To use a scan code just replace F1 with it (or F23!)
Code:
F1::
KeyState:=!KeyState
If !KeyState {
   Send {F1 Down}
   MsgBox % A_ThisHotkey " = " GetKeyState("F1") " = Down"
   }
Else {
   Send {F1 Up}
   MsgBox % A_ThisHotkey " = " GetKeyState("F1") " = Up"
   }
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 2:12 pm 
Offline

Joined: August 30th, 2006, 2:40 am
Posts: 5
!MsgBox thanks for you help! btw, i registered now.

But as I suspected, this doesn't work and I have the latest version of AHK.

I think my keyboard is just too picky. Check out what I have...
http://www.pocketnow.com/html/portal/re ... layout.jpg

You script works, beause when I press the "Num" key on my keyboard (which is F23), all the correct MsgBoxes appear but in the end it will not keep the key held down. When I press another key while it is "toggled" the desired effect does not occur. For example, the "s" key should yield {up} but this doesn't happen. However, if I physically press them together it does work.

I have had some minor success with using "if" statements, but I need some more help. I'll post code later.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 4:50 pm 
Offline

Joined: November 17th, 2005, 10:14 pm
Posts: 196
Location: Leicester, UK
Hello sleepytime :)

Ok, this time we'll use a timer. Try this, it should work now.
That keyboard :shock: , it's tiny!! Is it easy to use?
Code:
F1::
   KeyState:=!KeyState
   If !KeyState {
      SetTimer F23, off
      Send {F1 Up}
      ToolTip % A_ThisHotkey " = " GetKeyState("F1") " = Up"
     
      }
   Else SetTimer F23, 100
Return

F23:
   KeyState:=!KeyState
   Send {F1 Down}
   ToolTip % A_ThisHotkey " = " GetKeyState("F1") " = Down"
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 5:55 pm 
Offline

Joined: August 30th, 2006, 2:40 am
Posts: 5
Hmmm. still nothing with that code. I tried to mess around with it a little.

At the "F23:" part did you really mean "F23::"? Unless you meant it as a Label? That didn't work either. I'll try to come up with some code to post, as I may need to try another way.


FYI, the keyboard is pretty cool, about the size of a credit card. I use it with my Home Theatre PC so I can control it very easily. It will be much easier to control once I get this whole AHK script working.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Maestr0, migz99, tomoe_uehara and 74 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