AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HangMan Solver

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Frankie



Joined: 02 Nov 2008
Posts: 2850

PostPosted: Wed Apr 22, 2009 2:05 pm    Post subject: HangMan Solver Reply with quote

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:
Quote:
HA_GM_N
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} Very Happy
_________________
aboutscriptappsscripts
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
View user's profile Send private message
Hezzu



Joined: 08 Aug 2008
Posts: 117
Location: Raahe, Finland

PostPosted: Thu Apr 23, 2009 4:38 am    Post subject: Reply with quote

Awesome script Very Happy

I Really like it!
_________________
Hezzu - excuse the english!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frankie



Joined: 02 Nov 2008
Posts: 2850

PostPosted: Thu Apr 23, 2009 1:08 pm    Post subject: Reply with quote

Thanks Very Happy
_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Back to top
View user's profile Send private message
jeannette
Guest





PostPosted: Tue Mar 30, 2010 5:45 pm    Post subject: Re: HangMan Solver Reply with quote

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





PostPosted: Sat Jul 30, 2011 12:28 pm    Post subject: Reply with quote

Hezzu wrote:
Awesome script Very Happy

I Really like it!
Back to top
Frankie



Joined: 02 Nov 2008
Posts: 2850

PostPosted: Tue Aug 02, 2011 4:29 am    Post subject: Reply with quote

The script in my first post is pretty basic. I used goto... Rolling Eyes

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.
_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Back to top
View user's profile Send private message
Frankie



Joined: 02 Nov 2008
Posts: 2850

PostPosted: Tue Aug 02, 2011 5:08 am    Post subject: Re: HangMan Solver Reply with quote

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 Wink
_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Back to top
View user's profile Send private message
gogo
Guest





PostPosted: Tue Dec 13, 2011 10:14 pm    Post subject: easier way Reply with quote

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

PostPosted: Wed Dec 14, 2011 3:03 am    Post subject: Reply with quote

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
View user's profile Send private message
Frankie



Joined: 02 Nov 2008
Posts: 2850

PostPosted: Wed Dec 14, 2011 3:06 am    Post subject: Reply with quote

Good idea. I'll get on that!
_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Back to top
View user's profile Send private message
ton80



Joined: 18 Dec 2009
Posts: 62

PostPosted: Wed Dec 14, 2011 3:16 am    Post subject: Reply with quote

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. Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group