 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Apr 22, 2009 2:05 pm Post subject: HangMan Solver |
|
|
Heres a simple script that uses OneLook.com's wildcard dictionary searches to give posible matches for a game of hangman. Say the board looks like this:Then put HA?GM?N in the input box.
| Code: | ;Hangman Solver
Top:
InputBox, Input, Hangman Solver, Enter what you have so far`, for letters you don't know use a question mark (?). Example: Han?m?n
If !Input
ExitApp
URLDownloadtoFile, http://onelook.com/?w=%Input%&scwo=1&sswo=1, Search.html
FileRead, Html, Search.html
FileDelete, Search.html
Words =
Loop, Parse, HTML, `n, `r
If RegExMatch(A_LoopField, "\d\. (.*?)>(.*?)</a>", Match)
{
Match := RegExReplace(Match, "\d\. (.*?)>")
StringReplace, Match, Match, </a>
Words .= Match . "`n"
}
Msgbox, 0, Posible Matches:, %Words%
Goto, Top |
Update: Look 5 posts down for an updated version. It doesn't use InputBox or even require pressing {Enter}  _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Last edited by Frankie on Tue Aug 02, 2011 4:32 am; edited 2 times in total |
|
| Back to top |
|
 |
Hezzu
Joined: 08 Aug 2008 Posts: 117 Location: Raahe, Finland
|
Posted: Thu Apr 23, 2009 4:38 am Post subject: |
|
|
Awesome script
I Really like it! _________________ Hezzu - excuse the english! |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Thu Apr 23, 2009 1:08 pm Post subject: |
|
|
Thanks  _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
jeannette Guest
|
Posted: Tue Mar 30, 2010 5:45 pm Post subject: Re: HangMan Solver |
|
|
at_a_ _e
_ _c _u _ Also 2nd word has a (a/n) in it but I don't know where they go
clues are
long term
could grow |
|
| Back to top |
|
 |
_ac_ets Guest
|
Posted: Sat Jul 30, 2011 12:28 pm Post subject: |
|
|
| Hezzu wrote: | Awesome script
I Really like it! |
|
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Tue Aug 02, 2011 4:29 am Post subject: |
|
|
The script in my first post is pretty basic. I used goto...
Here's an updated version. It searches while you type.
| Code: | ; An updated Hangman Solver script by Frankie
; This script is released into the public domain
; AutoHotkey forum thread: http://www.autohotkey.com/forum/viewtopic.php?t=43482
Default_Text := "w?o?d"
Gui, +Resize
Gui, Margin, 10 5
Gui, Font, s18
Gui, Add, Edit, vInput gInputChange, % Default_Text
Gui, Font, s13
Gui, Add, ListView, r10 vOutput, Matches
LV_ModifyCol(1, "Integer Left")
Gui, Show, w300, H?ngman Solv?r
GuiControlGet, Output, Pos
GoSub, InputChange
return
InputChange:
GuiControlGet, Input
If (Input = Default_Text || Input = "")
{
Gui, Font, cBBBBBB
GuiControl, Font, Input
GuiControl,, Input, % Default_Text
SendInput {End} ; Hacky, but it works
return
}
else If InStr(Input, Default_Text)
{
Gui, Font, c000000
GuiControl, Font, Input
StringReplace, NewText, Input, % Default_Text
GuiControl,, Input, % NewText
SendInput {End}
}
else if (InStr(Input, "?") = false)
&& (InStr(Input, "*") = false) || (StrLen(Input) < 3)
return
Input := RegExReplace(Input, "([^/])\?", "$1%3F")
URLDownloadToFile, http://onelook.com/?w=%Input%&scwo=1&sswo=1, Hangman_Temp_File.html
FileRead, HTML, Hangman_Temp_File.html
FileDelete, Hangman_Temp_File.html
GuiControl, -ReDraw, Output
LV_Delete()
while (Pos>StrLen(Html)||!Pos ? Pos:=1 : Pos) := RegExMatch(HTML
, "(?P<Index>\d+)\. <.*?>(?P<Word>\w+)(?=</a>)"
, Match, Pos+StrLen(Match))
LV_Add("", MatchIndex . ": " MatchWord)
LV_ModifyCol()
GuiControl, +ReDraw, Output
return
GuiSize:
If (A_EventInfo != 1) ; Do nothing when minimized
{
; Fit the Input and Output controls to the new window size
GuiControl, Move, Output
, % "w" (A_GuiWidth - 20) A_Space "h" (A_GuiHeight - OutputY - 10)
GuiControl, Move, Input
, % "w" (A_GuiWidth - 20)
}
return
GuiClose:
ExitApp
|
I have no idea why it sometimes (about 1/5 chance) doesn't show the listview. If it happens just resize the window by dragging the corner. _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Tue Aug 02, 2011 5:08 am Post subject: Re: HangMan Solver |
|
|
| jeannette wrote: | at_a_ _e
_ _c _u _ Also 2nd word has a (a/n) in it but I don't know where they go
clues are
long term
could grow | Sorry for the late reply. If you're still trying to figure it out, and haven't used all your guesses, try "attache lockup".
HTH  _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
gogo Guest
|
Posted: Tue Dec 13, 2011 10:14 pm Post subject: easier way |
|
|
just do:
Ctrl+u
go down and find at the end of a line:
value="(the answer)"
it is as easy as that |
|
| Back to top |
|
 |
ton80
Joined: 18 Dec 2009 Posts: 62
|
Posted: Wed Dec 14, 2011 3:03 am Post subject: |
|
|
| nice script frankie! works great, now you need to add an 'excluded letters' option, example.. if S isnt in the answer, exclude all the remaining words with S, etc.. that will narrow the list down much faster i think. |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Dec 14, 2011 3:06 am Post subject: |
|
|
Good idea. I'll get on that! _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
ton80
Joined: 18 Dec 2009 Posts: 62
|
Posted: Wed Dec 14, 2011 3:16 am Post subject: |
|
|
| Frankie wrote: | | Good idea. I'll get on that! |
great.. also... ??an shouldnt show adan, akan, alan, etc.. because A is known letter.. please get these implemented so i can pwn some fools in some hangman.. lol.  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|