AutoHotkey Community

It is currently May 27th, 2012, 8:15 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Code Golf
PostPosted: January 16th, 2012, 9:54 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
Update:
Rules:
1 Has to be done IN AutoHotkey.
2 No #Include's.
3 No functions

Challenge: Pull and output data from a file.
Code:
; dmg (25 but no msgbox)
filecopy,%a_scriptname%,5
; mickers (38)
MsgBox % FileOpen("f.txt","r").Read()
; fragman (41)
FileRead,t,%A_ScriptFullPath%
Msgbox %t%
Challenge: Login to AutoHotkey.com
Specs:
Pull from a file for passwords.
Must run on (almost) anyones system.
Code:
; mickers (379)
f:=FileOpen("f.txt","r")
u:=f.Readline()
w:=f.Readline()
(p:=ComObjCreate("InternetExplorer.Application")).Visible:=true
p.Navigate("autohotkey.com/forum/")
while p.busy
Sleep,1000
l:=p.Document.Links
Loop % l.Length
if(l[i:=A_Index-1].InnerText="Log In")
l[i].Click()
while p.Busy
Sleep,1000
(d:=p.Document.All).username.Value:=u
d.password.Value:=w
d.login.Click


Original:
I'd like to start a Code Golf thread. Only problem is that I can't think of a good project. :(

Any ideas?

I think this would be a fun way to pass time at work or between questions while picking up programming techniques.

Let the games begin!

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Last edited by Mickers on January 18th, 2012, 1:55 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 12:19 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Go on rosettacode.org -- look at either the "classics" (like ROT13) already solved in AHK, or something not yet solved in AHK. Uberi and I did a few challenges over IRC a while back. (He always beat me :P)

Here's a golf-challenge: make a quine as short as possible.

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 12:46 am 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Code:
FileRead,t,%A_ScriptFullPath%
Msgbox %t%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 1:00 am 
Offline
User avatar

Joined: November 19th, 2010, 3:12 pm
Posts: 787
Location: At my computer
Code:
filecopy,%a_scriptname%,5


fragman has me beat by a few characters. Is any output type allowed, meaning is his message box the same as my copied file as far as the rules go?

Edit:
I spoke too soon, now mine is shorter. 8)

_________________
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

My personal site


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 1:17 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
I made a thread called "Are you: Just Another AutoHotkey Hacker?" which is code-golf-like. There are probably some AutoHotkey-specific techniques in there which may come in handy. You could also get ideas from codegolf.se.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 2:27 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
dmg wrote:
Code:
filecopy,%a_scriptname%,5


fragman has me beat by a few characters. Is any output type allowed, meaning is his message box the same as my copied file as far as the rules go?

Edit:
I spoke too soon, now mine is shorter. 8)
Hmm I guess it would be up to opinion. :wink:
Code:
MsgBox % FileOpen("f.txt","r").Read()
38 characters. :wink:

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 2:52 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Your script requires a specific filename...If you wanted, you could remove the extension to save 4 characters.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 3:26 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
fragman wrote:
Your script requires a specific filename...If you wanted, you could remove the extension to save 4 characters.
Good idea. 8)
You gonna take a stab at the other challenge. :P
Edit:
On my machine it doesn't run if I don't include the .txt. :oops:

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 18th, 2012, 3:40 am 
Offline
User avatar

Joined: November 19th, 2010, 3:12 pm
Posts: 787
Location: At my computer
@Mickers Not to nitpick, but you have my quine as 26 characters. It is only 25.

And could you provide more information regarding the second challenge. As it is now both the description and rules are rather ambiguous.

_________________
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

My personal site


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 18th, 2012, 1:57 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
dmg wrote:
@Mickers Not to nitpick, but you have my quine as 26 characters. It is only 25.

And could you provide more information regarding the second challenge. As it is now both the description and rules are rather ambiguous.
It's not nitpicking. :)
If it's not a rule or in the description then you're free to do it. Just try to be as inventive as possible. :wink:

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: tomoe_uehara and 6 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