Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 22, 2012, 03:23 AM   #1
dumlovesyou
macrumors newbie
 
Join Date: Nov 2012
Keystroke application

Hello,

I need to make a small application (fast). I just need to have the b key to be pressed for 10 minutes at 0.1 seconds intervals. Do you know how can I begin? I have just downloaded xcode 3.1.4 and used to use basic, turbo pascal and bit of c++ quite some time ago.

I also tried Automator. I recorded the b stroke and put a loop on, but it does it once and then it blocks on the watch me do. If I tick the ask to continue it loops for as long I asked for.

Thank you in advance!!
dumlovesyou is offline   0 Reply With Quote
Old Nov 22, 2012, 12:16 PM   #2
bumper314
macrumors member
 
Join Date: Jun 2009
Your best bet is AppleScript:

Code:
-- Give yourself 5 seconds to switch to the right app
delay 5

set finishedTime to (current date) + (10 * minutes)

tell application "System Events"
	repeat while (current date) < finishedTime
		keystroke "b"
		delay 0.1
	end repeat
end tell
bumper314 is offline   0 Reply With Quote
Old Nov 25, 2012, 04:08 PM   #3
Hmblebee
macrumors newbie
 
Join Date: Nov 2012
Location: Portland, Oregon
 
Take a look at CGEventCreateKeyboardEvent and CGEventPost. This will allow you to post raw keyboard events to simulate keystrokes.

Reference:
http://developer.apple.com/library/m...reference.html
Hmblebee is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Change Monitor Source with keystroke -BigMac- Mac Pro 0 May 16, 2014 10:04 AM
Mac Keystroke Encryption Software? projectmac Mac Applications and Mac App Store 1 Feb 11, 2014 09:35 PM
Locking Screen - CTRL SHIFT EJECT - Logitech Mouse Button Keystroke Kilamite OS X 1 Nov 29, 2013 05:43 AM
Weird keystroke problem Hookemfins Mac Basics and Help 3 Aug 28, 2013 09:12 PM
How to activate notifications with keystroke Drag'nGT MacBook Pro 4 Aug 5, 2012 08:30 PM

Forum Jump

All times are GMT -5. The time now is 01:31 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC