guys,
how do i make a macro which makes the keyboard press 123456789 automatically in a loop till i stop it....
awaiting reply,
thx
![](https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
123456789
Started by
aronincool
, Apr 15 2012 10:54 PM
20 replies to this topic
#1
-
Posted 15 April 2012 - 10:54 PM
![123456789: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
here ya go
x := 1 Loop { Send {%x%} if (x == 10) x := 1 else x := x + 1 } return
#2
-
Posted 15 April 2012 - 11:32 PM
![123456789: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Could I get a script to calculate the 1 billion digits of π (pi)?
Awaiting answer, thnx
Awaiting answer, thnx
#3
-
Posted 16 April 2012 - 12:25 AM
![123456789: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Would not getting the exact value of pi be more desirable? ![:)](//www.autohotkey.com/board/public/style_emoticons/default/happy.png)
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
MsgBox pi = π
#4
-
Posted 16 April 2012 - 10:23 AM
![123456789: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thank you! <---In case I forget to say it.
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
Would not getting the exact value of pi be more desirable?
Loop { MsgBox, 4,, pi = π. Close enough? IfMsgBox, Yes Break } ExitApp
Here's an algorithm for you...I just don't know how to code it. It'd be interesting to see if another could.
pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)
So loop that enough times and the square root of that series should nudge up pretty close to π. A billion digits? Can AHK handle that?
Here's another one:
pi = 3 + (1/(6 + 3^2/(6 + 5^2/ (6 + 7^2/(6 + 9^2/(6 + 11^2/(....
#5
-
Posted 16 April 2012 - 07:48 PM
![123456789: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thank you! <---In case I forget to say it.
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
<!-- m -->http://www.optimnem.co.uk/pi.php<!-- m -->
#6
-
Posted 16 April 2012 - 10:17 PM
![123456789: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Any code that I post will be for AHK Basic.
I'm not always right, but I still try to help.
I'm not always right, but I still try to help.
pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)
pi := 6/1 Loop, % 1000000000 - 1 pi += 6/(A_Index^2) pi := sqrt(pi)
...?
#7
-
Posted 16 April 2012 - 11:34 PM
![123456789: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)
pi := 6/1 Loop, % 1000000000 - 1 pi += 6/(A_Index^2) pi := sqrt(pi)
...?
Not right... that formula is wrong. This one works though 3+(1/(6+3**2/(6+5**2/(6+7**2..., but Autohotkey is not capable of making it for too long. My guess was to try and make it in parts, but I'm not in the mood to think about that right now.
#8
-
Posted 16 April 2012 - 11:44 PM
![123456789: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Let us not be lazy. Someday it might just kill us.
The first formula is right. It's Euler's solution to the Basel problem, solved for pi. Euler proved that the summation as n goes from 1 to infinity of 1/n^2 is pi^2/6. Multiplying through by 6 would give us that pi^2 = the summation as n goes from 1 to infinity of 6/n^2. Taking the square root of both sides would produce pi = the square root of (6/1 +6/2^2 + 6/3^2...). It's the code that "Guest" wrote that's wrong.pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)
pi := 6/1 Loop, % 1000000000 - 1 pi += 6/(A_Index^2) pi := sqrt(pi)
...?
Not right... that formula is wrong. This one works though 3+(1/(6+3**2/(6+5**2/(6+7**2..., but Autohotkey is not capable of making it for too long. My guess was to try and make it in parts, but I'm not in the mood to think about that right now.
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
#9
-
Posted 17 April 2012 - 01:27 AM
![123456789: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thank you! <---In case I forget to say it.
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
How does that code differ from your posted algo (1st one)?
#10
-
Posted 17 April 2012 - 02:10 AM
![123456789: post #10](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
That code is calculating a bunch of nested square roots rather than the square root of the sum.How does that code differ from your posted algo (1st one)?
Edit: The code below works pretty good. It produces 3.141018. I tried 100000 loops and it locked up on me.
Loop, 10000 { pi += 1/(A_Index**2) } pi := sqrt(6*pi) MsgBox, 4,, pi = %pi%...Close enough? IfMsgBox, Yes return
#11
-
Posted 17 April 2012 - 02:37 AM
![123456789: post #11](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thank you! <---In case I forget to say it.
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
Is there a limit on how many loops AHK will run?
#12
-
Posted 17 April 2012 - 06:49 PM
![123456789: post #12](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Thank you! <---In case I forget to say it.
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
Well... Autohotkey just finished making 100000000 (yup 8 0's) and it return only 16 decimal places... Took over half a hour for that and returned this 3.1415926449823899. Anyone willing to try a greater amount of loops?
PS: I've used setformat for it to show 50 decimal places.
PS: I've used setformat for it to show 50 decimal places.
#13
-
Posted 17 April 2012 - 07:30 PM
![123456789: post #13](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Let us not be lazy. Someday it might just kill us.
No it's not....That code is calculating a bunch of nested square roots rather than the square root of the sum.
pi := 6/1 ; Start off as 6 Loop, % 1000000000 - 1 ; Loop 1 less than a billion pi += 6/(A_Index^2) ; Add up 6/(A_Index^2)... the loop stops here pi := sqrt(pi) ; Calc the final square root... square root is only calc'd once
#14
-
Posted 17 April 2012 - 11:35 PM
![123456789: post #14](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
BTW, ^ is a bitwise-exclusive-or (^) in AHK, just in case that's trashing the formula.
#15
-
Posted 17 April 2012 - 11:43 PM
![123456789: post #15](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)