Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Game] Hangman


  • Please log in to reply
10 replies to this topic
Banane
  • Members
  • 46 posts
  • Last active: Apr 07 2012 03:58 PM
  • Joined: 25 Nov 2009
Posted Image

Well, today was one of these days, were the boredom takesover... as a way to entertain myself, I thought I'd program something funny, that's what this script is all about.

The script gathers it's word list from a defineable file, the default filename is "Hangman_Words.txt".

Every line of the file will be a new word.

Script + Resources:
https://ahknet.autoh...ngman-1.0.1.zip

Script:
;===========================================================================================================================================================
;Directives
;===========================================================================================================================================================

#SingleInstance, Force
#NoTrayIcon
#NoEnv

;===========================================================================================================================================================
;Setup base variables
;===========================================================================================================================================================

;Application Info
App_Name    := "Hangman"
App_Version := "1.0.1"

;Gui Numbers
Gui_Hangman := 1

;File Paths
Files_Pictures := "Images"
Files_Hangman  := "Hangman_{Nr}.png" ;{Nr} will be replaced by count of wrong answers
Files_Wordlist := "Hangman_Words.txt"

;Letters
Letters_Alpha := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;Letters the player has to guess

;Word specific
Words0     := 0  ;Count of Array Entries
Word_Game  := "" ;Word as visible in game
Word_Full  := "" ;Word as loaded from file
Word_Count := 0  ;Last replacement count of a letter
Word_AllLt := 0  ;Count of all revealed letters
Word_Wrong := 0  ;Count of wrong guessings

;Gameplay
Game_MaxWrong := 6 ;Count of wrong answers for gameover

;===========================================================================================================================================================
;Setup the program
;===========================================================================================================================================================

Main:
  ;Load all words into memory
  Hangman_LoadWordList()
  ;Create all windows
  GoSub, Hangman_CreateGui
  ;Load the first random word
  GoSub, Hangman_NewWord
  Return

;===========================================================================================================================================================
;Hangman Labels
;===========================================================================================================================================================

Hangman_CreateGui:
  ;Setup the gui options
  Gui, %Gui_Hangman%:-Border +ToolWindow +LastFound +LabelHangman_ -Theme
    ;Setup the font setting
    Gui, %Gui_Hangman%:Font, Bold, Arial
    ;Create the titlebar
    Gui, %Gui_Hangman%:Add, Text, x5 y5 w350 h20 +0x1000, % "  " App_Name " [V" App_Version "] - " Words0 " Words loaded"
    Gui, %Gui_Hangman%:Add, Text, x5 y5 w330 h20 +BackgroundTrans gHangman_MoveGui
    Gui, %Gui_Hangman%:Add, Button, x335 y8 w15 h15 gHangman_Close, X
    ;Create hangman picture
    Gui, %Gui_Hangman%:Add, Picture, x5 y30 w350 h350 +0x1000 vHangman_Pic
    ;Create the word container
    Gui, %Gui_Hangman%:Add, Text, x5 y395 w350 h40 +0x1000 vHangman_Word
    Gui, %Gui_Hangman%:Add, Text, x5 y440 w350 h65 +0x1000
    ;Only use hotkeys on this window
    Hotkey, IfWinActive, Hangman
    ;Create the alphabetical buttons
    Loop, Parse, Letters_Alpha
    {
      ;If it's first button, or first button of second line, use 40
      If (A_Index = 1 || A_Index = 14)
        XPos := 40
      ;Increment the horizontal position by 22 otherwise
      Else XPos := "p+22"
      ;Use vertical position 40 on first line, on second line 65
      YPos := (A_Index < 14) ? 450 : 475
      Gui, %Gui_Hangman%:Add, Button, x%XPos% y%YPos% w20 h20 vHangman_Letter%A_Index% gHangman_NewLetter, % A_LoopField
      ;Create a hotkey as well
      Hotkey, % A_LoopField, Hangman_NewLetterByHotkey, On
    }
    ;Create gameplay specific controls
    Gui, %Gui_Hangman%:Add, Text, x5 y512 w195 h20 vHangman_Stat, Wrong: 0/0 Letters: 0
    Gui, %Gui_Hangman%:Add, Button, x200 y510 w75 h20 gHangman_SolveWord, Solve Word
    Gui, %Gui_Hangman%:Add, Button, x280 y510 w75 h20 gHangman_NewWord, New Word
  ;Create and show the gui
  Gui, %Gui_Hangman%:Show, w360 h535, Hangman
  Return

Hangman_NewWord:
  ;Ensure that everything's in the start state
  Hangman_Reset()
  ;Load the random word
  Hangman_LoadWord()
  Return

Hangman_SolveWord:
  InputBox, Word, Hangman - Solve Word, Enter the word:,, 300, 120
  If (Word = Word_Full) {
    ;Show the full word
    GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Full
    ;Disable all buttons
    Hangman_LetterState(0)
    ;Show "Game Won" Message
    MsgBox,, Hangman, Congratulations! You've won the game!
  } Else MsgBox,, Hangman, Sorry`, that wasn't correct!
  Return

Hangman_NewLetter:
  ;Retrieve the letter of the pressed control
  GuiControlGet, Letter,, % A_GuiControl
  ;Check if this letter is within the word
  Hangman_CheckLetter(Letter)
  ;Disable control
  GuiControl, %Gui_Hangman%:Disable, % A_GuiControl
  Return

Hangman_NewLetterByHotkey:
  ;Use the hotkey button name
  Letter := A_ThisHotkey
  ;Check if this letter is within the word
  Hangman_CheckLetter(Letter)
  ;Loop through all allowed characters
  Loop, Parse, Letters_Alpha
    ;If the current character was the pressed key
    If (A_LoopField = Letter) {
      ;Disable the control
      GuiControl, %Gui_Hangman%:Disable, % "Hangman_Letter" A_Index
      ;Break from the loop
      Break
    }
  Return

Hangman_MoveGui:
  PostMessage, 0xA1, 2,,, A
  Return

Hangman_Escape:
Hangman_Close:
  MsgBox, 64, Hangman, % App_Name " [V" App_Version "]`n`nCreated by: Banane"
  ExitApp

;===========================================================================================================================================================
;Functions
;===========================================================================================================================================================

Hangman_Reset() {
 global

  ;Reset all variables
  Word_Game  := ""
  Word_Full  := ""
  Word_Count := 0
  Word_Wrong := 0
  ;Enable letter buttons
  Hangman_LetterState(1)
  ;Restore standard values
  GuiControl, %Gui_Hangman%:, Hangman_Word, 
  GuiControl, %Gui_Hangman%:, Hangman_Stat, % "Wrong: 0/" Game_MaxWrong " Letters: 0"
  Hangman_HangmanImage()
}

Hangman_HangmanImage() {
 global
 local Image

  StringReplace, Image, Files_Hangman, {Nr}, % Word_Wrong
  GuiControl, %Gui_Hangman%:, Hangman_Pic, % Files_Pictures "\" Image
}

Hangman_LoadWordList() {
 global
 local Currword

  ;Read the file line by line
  Loop, Read, % Files_Wordlist
    ;Only create array entry for this line, if not empty
    If (A_LoopReadLine <> "")
      ;Increase array count and save current word in pseudo array
      Words0 ++,Words%Words0% := A_LoopReadLine,Currword := ""
}

Hangman_LoadWord() {
 global
 local Currword

  ;Select a random word from array
  Random, Currword, 1, % Words0
  ;Set currword to the word in Words%Currword%
  Currword := Words%Currword%
  ;Change all alphabetical letters to _
  Loop, Parse, Currword
    Word_Game .= (InStr(Letters_Alpha,A_LoopField)) ? "_" : A_LoopField
  ;Make every letter uppercase
  StringUpper, Word_Full, Currword
  ;Change the content of the word control
  GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Game
}

Hangman_CheckLetter(Input) {
 global

  ;Reset the found letter count
  Word_Count := 0
  ;Parse through every letter of the full word
  Loop, Parse, Word_Full
    ;If the current letter is equal to the specified one
    If (A_LoopField = Input)
      ;Change the _ of this position with the letter and increase count
      Word_Game := SubStr(Word_Game,1,A_Index - 1) Input SubStr(Word_Game,A_Index + 1,StrLen(Word_Game)),Word_Count ++
  ;Increase the count of wrong guessings if no letter was replaced, change control text otherwise
  If (Word_Count = 0)
    Word_Wrong ++,Hangman_HangmanImage()
  Else GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Game
  Word_AllLt := Word_AllLt + Word_Count
  ;Update the statistics
  GuiControl, %Gui_Hangman%:, Hangman_Stat, % "Wrong: " Word_Wrong "/" Game_MaxWrong " Letters: " Word_AllLt
  ;If the count is equal to the maximum count of wrong guessings (6 by default)
  If (Word_Wrong = Game_MaxWrong || Word_Game = Word_Full) {
    ;Show the full word
    GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Full
    ;Disable all buttons
    Hangman_LetterState(0)
    ;Show "Game Over" / "Game Won" Message
    MsgBox,, Hangman, % (Word_Wrong = Game_MaxWrong) ? "Game Over!" : "Congratulations! You've won the game!"
  }
}

Hangman_LetterState(Mode) {
 global

  ;Check whether the buttons should be enabled or disabled
  Mode := (Mode = 1) ? "Enable" : "Disable"
  ;Apply the state to every button
  Loop, % StrLen(Letters_Alpha) {
    ;Change the control state
    GuiControl, %Gui_Hangman%:%Mode%, Hangman_Letter%A_Index%
    ;Change the hotkey state
    Hotkey, % SubStr(Letters_Alpha,A_Index,1), % (Mode = "Enable") ? "On" : "Off"
  }
}


x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010

You've won the game!


damnit i just lost the game

health901
  • Members
  • 9 posts
  • Last active: Mar 28 2014 06:40 AM
  • Joined: 23 Apr 2010
i see nothing but "Congratulations! You've won the game!"

Eedis
  • Members
  • 1775 posts
  • Last active: Aug 14 2015 06:33 PM
  • Joined: 12 Jun 2009

damnit i just lost the game

Damn you Animal.

This is pretty cool. You should have it grab a large list from the internet or something.
AutoHotkey state, the forum, Poly, and Drainx1. The short story.
I love my wife, my life, my atomic-match; for giving me the greatest gift a man could ask for, such a perfect and beautiful little girl.
9rjbjc.png

Tuncay
  • Members
  • 1945 posts
  • Last active: Feb 08 2015 03:49 PM
  • Joined: 07 Nov 2006
Hello World! I won the game.

Simple and nice. Good work

Suggestion: Add keyboard support. Then no need for mouse clicks. That would make me more happy. :D

No signature.


Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
I keep a page in my favorites that has lists of words.
<!-- m -->http://www.artwinaut... ... l#wordlist<!-- m -->

Specificaly the 500 most common and the 100,000 word lists. It also has other language lists.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

Banane
  • Members
  • 46 posts
  • Last active: Apr 07 2012 03:58 PM
  • Joined: 25 Nov 2009
Totally forgot about this... :O

Add keyboard support.

Keyboard support is now in.

randomguy
  • Members
  • 94 posts
  • Last active: Oct 20 2017 11:11 PM
  • Joined: 30 Oct 2011

does anyone still have the link? the images are missing in the script



RickC
  • Members
  • 123 posts
  • Last active: Nov 08 2016 05:19 AM
  • Joined: 13 Nov 2005

Here you go. (This is just the images.)

 

Hope this helps...



iPhilip
  • Members
  • 138 posts
  • Last active: Sep 12 2015 06:27 PM
  • Joined: 03 Jun 2010

Here is a list of 2439 words from this website that are answers to Hangman Hijinks puzzles and can be used for the Hangman_Words.txt file required to run the script:

Aardvark
Abbey
Abdominals
Abductor
Abhorrence
Acacia
Accordion
Acne
Acorn
Adductor
Admiration
Adoration
Affection
Agave
Aggression
Agony
Airbrush
Aircraft
Airliner
Airplane
Albacore
Albatross
Album
Alder
Alehouse
Algae
Alley
Alligator
Allspice
Almond
Aloe
Alternator
Altimeter
Alto
Amber
Ambrosia
Amethyst
Ammunition
Amoeba
Amphibian
Amplifier
Anaconda
Analyzer
Andromeda
Aneurysm
Angelfish
Anger
Angina
Angora
Angst
Animal
Animosity
Anise
Ankle
Anklebone
Annoyance
Anteater
Antelope
Anthem
Antifreeze
Antipasto
Aorta
Apathy
Aperitif
Aphid
Appetizer
Apple
Applesauce
Aqua
Aquamarine
Aquanaut
Arachnid
Arboretum
Arcade
Archer
Ardor
Arena
Aria
Armada
Armadillo
Armor
Armory
Armpit
Army
Arpeggio
Arrow
Arrowroot
Artery
Arthritis
Artichoke
Artillery
Asbestos
Ashcan
Asparagus
Aspen
Aspirator
Asteroid
Astronaut
Atlas
Atmosphere
Atrium
Attire
Auditorium
Aurora
Automobile
Aversion
Aviary
Azalea
Azure
Baby
Backhand
Backpack
Backstroke
Ball
Bamboo
Banana
Banjo
Baritone
Barnacle
Barracuda
Base
Basil
Bass
Batboy
Batter
Bean
Bedbug
Beet
Beetle
Beige
Bell
Bird
Birdhouse
Birdie
Birthmark
Bison
Bisque
Bistro
Bitterroot
Black
Blackberry
Blackbird
Blackhead
Blackjack
Blade
Blazer
Bleach
Blimp
Blindfold
Blintz
Bliss
Blitz
Block
Blood
Bloodhound
Bloodworm
Bloom
Bloomers
Blouse
Blower
Blowfish
Blowtorch
Blue
Blueberry
Bluebird
Bluebonnet
Bluegrass
Blues
Blush
Boar
Boat
Bobbin
Bobcat
Body
Bogey
Bolt
Bomb
Bomber
Bombshell
Bonbon
Bone
Bonefish
Bongo
Bonmus
Bonnet
Bonsai
Boogie
Book
Bookshelf
Bookshop
Boom
Boomerang
Boot
Bosom
Bottle
Bouillon
Boutique
Bowels
Bowl
Bowler
Boxer
Brace
Bracelet
Brain
Brake
Brass
Brassiere
Bratwurst
Bread
Breadboard
Breakfast
Breast
Breeches
Briar
Brick
Briefs
Broadsword
Broccoli
Brochette
Bronco
Bronze
Broom
Broth
Brow
Brown
Bruin
Bruise
Brunch
Brush
Buck
Bucket
Buckle
Bucktooth
Buckwheat
Buffet
Buggy
Bugle
Bulb
Bull
Bulldozer
Bullet
Bullfrog
Bumblebee
Bumper
Bunchberry
Bungalow
Bunion
Bunker
Bunny
Bunt
Burgundy
Burner
Burro
Bursitis
Bust
Butter
Buttercup
Butterfly
Butternut
Button
Cabana
Cabin
Cacao
Cactus
Caddie
Café
Cafeteria
Cake
Calculator
Calendar
Calf
Calliope
Calm
Camcorder
Camel
Camera
Camisole
Camouflage
Camshaft
Canape
Canary
Cancer
Candle
Candy
Canine
Canister
Cannelloni
Cannon
Cannonball
Canopy
Cantaloupe
Caper
Capillary
Cappuccino
Capsicum
Carafe
Carambola
Carburetor
Carcinoma
Cardamom
Cardinal
Carnation
Carol
Carousel
Carp
Carrot
Cartilage
Carton
Cashmere
Casino
Casserole
Castle
Catapult
Cataract
Catch
Catsup
Cavalryman
Cave
Caviar
Cavity
Celery
Cellar
Cello
Cellulite
Center
Centipede
Centrifuge
Centurion
Cereal
Cerebellum
Cerebrum
Cerise
Cerulean
Cervix
Chair
Chairlift
Chalet
Chameleon
Chamomile
Chandelier
Chant
Chapel
Charcoal
Chard
Chartreuse
Check
Checklist
Cheek
Cheekbone
Cheery
Cheese
Cheesecake
Chenille
Cherry
Chessboard
Chest
Chestnut
Chick
Chickpea
Chickweed
Child
Chili
Chime
Chimpanzee
Chin
China
Chinchilla
Chino
Chipmunk
Chive
Chives
Chocolate
Choir
Choke
Choker
Chorus
Chrome
Chromosome
Chub
Church
Cicada
Cilantro
Cinema
Cinnabar
Cinnamon
Cirrhosis
Cirrhossis
Citrus
Clam
Claret
Clarinet
Clavicle
Claymore
Cleats
Cleavage
Clef
Clipboard
Cloak
Clock
Clog
Clot
Clothespin
Cloud
Clover
Club
Clubhouse
Clutch
Coatrack
Coattail
Cobalt
Cobra
Cockatoo
Cockle
Cocklebur
Cockroach
Coffee
Coffeecake
Coffeepot
Coil
Colander
Cold
Coleslaw
Collagen
Collards
Collider
Colon
Colt
Comb
Combat
Comet
Comfit
Comforter
Commander
Commando
Commissary
Commodore
Compassion
Complex
Compressor
Computer
Concerto
Conch
Concussion
Condenser
Condor
Cone
Confection
Confidence
Confusion
Conga
Consomme
Contempt
Contusion
Converter
Conveyor
Convulsion
Cookbook
Cooker
Cookie
Cooler
Coon
Copperhead
Coral
Cordgrass
Corduroy
Corgi
Coriander
Corkboard
Corkscrew
Corn
Cornbread
Cornea
Cornerback
Cornet
Cornflower
Corporal
Corps
Corset
Cotton
Cottonweed
Couch
Cougar
Counterspy
Countertop
Coupon
Court
Couscous
Coverall
Cowl
Coyote
Crab
Crabgrass
Cradle
Cramp
Cranberry
Crane
Crankcase
Crankiness
Crankshaft
Crate
Crawfish
Crayfish
Credenza
Crepe
Crescendo
Cress
Crib
Crock
Crocodile
Croquette
Crossbow
Crossfire
Crotch
Crow
Crown
Crumb
Crust
Crustacean
Crypt
Cubbyhole
Cuckoo
Cucumber
Cudgel
Cumin
Cummerbund
Cupboard
Curio
Curler
Curry
Cutlet
Cutter
Cuttlefish
Cyan
Cylinder
Cymbal
Cynicism
Dachshund
Daffodil
Dagger
Dahlia
Daikon
Daisy
Dalmatian
Damselfish
Dandelion
Dandruff
Dartboard
Dashboard
Date
Daybed
Deck
Deer
Defiance
Defroster
Dejection
Delicacy
Denim
Dent
Depot
Depression
Dermatitis
Derringer
Desire
Desk
Destroyer
Detector
Detergent
Detonator
Deuce
Diabetes
Diaper
Diaphragm
Diary
Dictionary
Diet
Diffuser
Digest
Digit
Digitizer
Dill
Dimmer
Dimple
Diner
Dingo
Dinner
Dinnerware
Dinosaur
Dipstick
Directory
Dirk
Disco
Discus
Disguise
Dish
Dishtowel
Dishwasher
Dispenser
Disposal
Dissonance
Ditty
Diver
Diving
Divinity
Dogfight
Doghouse
Doll
Dollhouse
Dome
Domicile
Donkey
Doodlebug
Doom
Door
Doorbell
Doorknob
Doorstop
Dormitory
Dormouse
Double
Dough
Doughnut
Dove
Down
Downbeat
Dragon
Dragonfly
Drain
Drape
Drawer
Dread
Dress
Drill
Driver
Driveshaft
Driveway
Drone
Drugstore
Drum
Drumbeat
Drumstick
Dryer
Duck
Duct
Duet
Duff
Dugout
Dulcimer
Dumbbell
Dumbwaiter
Dumpling
Dunk
Duodenum
Duplex
Duplicator
Durum
Dust
Duster
Dynamo
Dyslexia
Dystrophy
Eagle
Earthworm
Earwig
Easel
Eaten
Eclair
Éclair
Eczema
Edible
Eggbeater
Eggplant
Egret
Elbow
Elderberry
Elephant
Elevator
Embolism
Embryo
Emphysema
Emptiness
Enamel
Enchilada
Encore
Endive
Endorphin
Engine
Ensemble
Envelope
Envy
Enzyme
Epicardia
Epidermis
Epilepsy
Equalizer
Eraser
Escalator
Escargot
Esophagus
Espionage
Estrogen
Eucalyptus
Euphoria
Evergreen
Explosive
Eyelid
Eyeliner
Face
Facsimile
Fade
Fadeaway
Fairy
Falchion
Falcon
Fallow
Falsetto
Fandango
Farmhouse
Fashion
Fastball
Fatigues
Faucet
Fault
Fawn
Fear
Feast
Fedora
Feedback
Feline
Femur
Fence
Fencer
Fender
Fennel
Fern
Ferocity
Ferret
Fettuccine
Fetus
Fiberglass
Fibula
Ficus
Fiddle
Field
Fife
Fighting
Figurine
Fillet
Filter
Finch
Finery
Finger
Fingernail
Fingertip
Fire
Fireplace
Firewood
Fireworks
Fish
Fist
Flab
Flag
Flail
Flamenco
Flamingo
Flan
Flank
Flashlight
Flask
Flat
Flatfish
Flatulence
Flatware
Flatworm
Flax
Flea
Fleet
Flesh
Flier
Floor
Floorboard
Flophouse
Floss
Flotilla
Flounder
Flour
Flower
Flugelhorn
Fluke
Flute
Flypaper
Flywheel
Foal
Foil
Folder
Follicle
Fondness
Fondue
Foot
Football
Footstool
Footwear
For
Forehand
Forest
Fork
Forklift
Fort
Fortress
Foul
Foulness
Foundation
Fountain
Foxhound
Fracture
Frame
Frappe
Freestyle
Freewheel
Freshener
Fret
Friedcake
Frittata
Frock
Frog
Frostiness
Fruit
Fruitcake
Fryer
Fudge
Fugue
Fullback
Fumble
Fungus
Funk
Funnel
Furniture
Fury
Fuse
Fusion
Futon
Gaiety
Gallstone
Galoshes
Game
Gander
Gangrene
Garage
Garbanzo
Garden
Gardenia
Garlic
Garnet
Garter
Gasket
Gate
Gatehouse
Gauge
Gazebo
Gazpacho
Gearshift
Gecko
Gene
Generator
Genitalia
Genome
Geranium
Gerbil
Germ
Ghost
Gibbon
Gigantism
Ginger
Gingersnap
Gingivitis
Ginkgo
Girdle
Gland
Glass
Glassware
Glaucoma
Glaze
Glider
Globe
Globulin
Gloom
Glove
Glowworm
Glue
Glycogen
Gnat
Goal
Goalkeeper
Goalpost
Goat
Goatee
Gold
Goldenrod
Goldfish
Golf
Gong
Gonorrhea
Goose
Gooseberry
Gopher
Gospel
Gourd
Gout
Governor
Gown
Grape
Grapefruit
Grapevine
Grass
Grate
Gratitude
Gravel
Gravy
Gray
Green
Greenhouse
Greyhound
Grief
Grill
Grits
Groin
Groove
Grounder
Groundhog
Grouse
Grout
Grow
Growth
Grub
Grubby
Gruel
Guacamole
Guard
Guardhouse
Guardsman
Guava
Guerrilla
Guesthouse
Guillotine
Guilt
Guitar
Gull
Gumbo
Gunfight
Gunmetal
Gunpowder
Guppy
Gutter
Gymnasium
Gymnastics
Gyro
Gyroscope
Haggis
Hair
Hairbrush
Hairline
Half
Halftime
Hall
Halo
Hamburger
Hammer
Hammerhead
Hammerlock
Hamper
Hand
Handball
Handcart
Handicap
Handle
Hanger
Hangnail
Happiness
Hardware
Hare
Harmonica
Harp
Hash
Hatchback
Hate
Hawk
Haymaker
Hazel
Head
Headband
Headboard
Headcheese
Headdress
Headlight
Headrest
Heart
Heartbeat
Heartburn
Hearth
Heater
Hedge
Hedgehog
Heel
Heifer
Heirloom
Helicopter
Helmet
Hematoma
Hemoglobin
Hemophilia
Hemorrhoid
Hemp
Henna
Hepatitis
Herb
Hernia
Heron
Herpes
Hibiscus
Hiccup
Highchair
Hinge
Hippo
Hitch
Hole
Home
Homework
Hominy
Honey
Honeybee
Honeycomb
Honeydew
Hood
Hook
Hoopskirt
Hoosegow
Hope
Hopscotch
Horehound
Horn
Hornet
Horror
Horse
Horsefly
Horsepower
Hose
Hospital
Hostel
Hostility
Hotel
Hound
House
Hovel
Hovercraft
Howitzer
Hubcap
Humility
Hummus
Humpback
Hurt
Hutch
Hyacinth
Hydrangea
Hydrofoil
Hyena
Hymn
Igloo
Ignition
Impatience
Incubator
Indigo
Infantry
Infection
Infielder
Influenza
Injector
Inning
Instep
Insulation
Intake
Interferon
Interlude
Intestine
Invasion
Inverter
Iris
Iron
It
Ivory
Jack
Jackal
Jacket
Jackfruit
Jackrabbit
Jacks
Jaguar
Jail
Jalapeno
Jambalaya
Jaundice
Jazz
Jealousy
Jeans
Jeep
Jello
Jelly
Jellyfish
Jerky
Jetliner
Jewel
Jicama
Jigsaw
Jimsonweed
Jitterbug
Jockey
Joint
Joust
Jowl
Judo
Junk
Kabob
Kale
Kangaroo
Karate
Katana
Kazoo
Keep
Keepsake
Kelp
Kerchief
Kettle
Keyboard
Khaki
Khakis
Kicker
Kidney
Kiln
Kilt
Kimono
Kingdom
Kingfish
Kinkajou
Kite
Kitten
Kiwi
Knee
Knife
Knight
Knob
Knockout
Koala
Kohlrabi
Kookaburra
Kookburra
Labrador
Lace
Lacrosse
Lactation
Ladder
Ladle
Ladyfinger
Lamb
Lamp
Lance
Laptop
Lard
Larder
Largemouth
Lark
Larkspur
Larva
Laryngitis
Larynx
Laser
Lash
Lathe
Lavender
Lawn
Lawnmower
Leaf
League
Leash
Lederhosen
Leech
Leek
Leftovers
Legume
Lemon
Lemongrass
Lemur
Lens
Lentil
Letter
Leukemia
Lichen
Lick
Licorice
Lieutenant
Life
Lift
Light
Lighthouse
Lilac
Limb
Lime
Limpet
Linebacker
Linen
Linesman
Lingerie
Linguine
Links
Linoleum
Lint
Lion
Lipstick
Liquor
Liver
Lizard
Llama
Loafer
Lobe
Lock
Locomotive
Locust
Lodge
Loft
Loganberry
Logo
Loin
Lollipop
Loneliness
Loofah
Loom
Loon
Lorikeet
Lotion
Lotus
Lounge
Louse
Love
Lovebird
Lubricant
Luge
Lunch
Lung
Lungfish
Lupus
Lust
Lute
Lychee
Lymphoma
Lynx
Lyre
Lyric
Macadamia
Macaroni
Macaroon
Macaw
Mace
Machismo
Macho
Mackerel
Magazine
Maggot
Magnet
Magpie
Mahogany
Mail
Mainframe
Major
Makeup
Malamute
Malice
Mallet
Malted
Mambo
Mandolin
Mandrake
Mandrill
Mango
Mangosteen
Manicotti
Manifold
Manor
Manta
Mantel
Mantis
Manzanita
Maple
Maraschino
Marathon
Marble
March
Mare
Margarine
Mariachi
Marigold
Marinade
Marinara
Mariposa
Marker
Marksman
Marlin
Marmalade
Marmoset
Maroon
Marrow
Marvels
Marzipan
Mascarpone
Mascot
Mask
Match
Matchbook
Matchbox
Mattress
Matzo
Maul
Mausoleum
Mauve
Mayonnaise
Meadowlark
Meal
Mealworm
Meat
Meatball
Medicine
Medley
Melancholy
Melanoma
Melatonin
Melody
Melon
Meningitis
Meniscus
Menopause
Menu
Mercenary
Meringue
Mesquite
Metabolism
Meteor
Metronome
Microphone
Microscope
Microwave
Midfield
Midge
Migraine
Mildew
Military
Militiaman
Milkshake
Milkweed
Millipede
Mimeograph
Mimosa
Mincemeat
Mine
Minefield
Miniskirt
Mink
Minnow
Mint
Minuet
Minuteman
Mirror
Misery
Mistletoe
Mite
Mitten
Mixer
Moccasin
Mocha
Modem
Modern
Molar
Molasses
Mold
Mole
Monastery
Money
Mongoose
Monkey
Monkfish
Monoplane
Monorail
Moon
Moonflower
Moped
Moray
Morgue
Morsel
Mosque
Mosquito
Moss
Motel
Moth
Mothball
Motocross
Motor
Motorboat
Motorcycle
Mouse
Mousetrap
Mousse
Mouth
Mouthpiece
Mozzarella
Mucus
Mudpuppy
Mudskipper
Muenster
Muff
Muffin
Mulberry
Mule
Mullet
Mulligan
Mumps
Munitions
Muscle
Museum
Mushroom
Musket
Mussel
Mustache
Mute
Mutiny
Muumuu
Myrtle
Nachos
Nail
Nape
Napkin
Napoleon
Narcissus
Nastiness
Nasturtium
Nautilus
Navel
Navy
Nebulizer
Neck
Necklace
Necrosis
Nectarine
Needle
Needlefish
Needlework
Negligee
Nerve
Nettle
Newspaper
Newt
Nightclub
Nightgown
Nighthawk
Nightshade
Nightshirt
Nipple
Nonpareil
Noodle
Nose
Note
Notebook
Nougat
Novel
Nutmeg
Nylons
Oboe
Ochre
Octave
Odometer
Of
Office
Official
Ohmmeter
Okra
Oleander
Olive
Omelet
Onion
Onslaught
Opener
Opera
Orange
Orangutan
Orchestra
Orchid
Organ
Oscillator
Osprey
Otter
Outfield
Outfit
Outhouse
Ovary
Oven
Over
Overbite
Overcoat
Overhead
Overlord
Overture
Overturn
Ovulation
Ovum
Oxygen
Oyster
Ozone
Pacemaker
Pacer
Pachyderm
Paddle
Paella
Pagoda
Pail
Pain
Paint
Paintbrush
Pajama
Palace
Palate
Palm
Palomino
Pancetta
Pancreas
Pandowdy
Panel
Panic
Pansy
Pantry
Pantyhose
Papaya
Paper
Papillon
Parakeet
Paralysis
Paranoia
Parasite
Paratroops
Parka
Parlor
Parrot
Parry
Partition
Partridge
Passivity
Pasta
Paste
Pastrami
Pastry
Pasty
Patchouli
Pate
Patio
Patty
Pavilion
Pavillion
Peace
Peach
Peanut
Pear
Pearl
Pectoral
Pedal
Pedometer
Peephole
Pegboard
Pelvis
Pencil
Pentathlon
Penthouse
Pepper
Peppermint
Pepperoni
Percolator
Percussion
Perennial
Period
Periscope
Periwinkle
Persimmon
Pessimism
Pesto
Petticoat
Pheasant
Phone
Phrase
Physique
Piano
Piccalilli
Pick
Pickle
Picnic
Pigeon
Piglet
Pike
Pilaf
Pill
Pillow
Pilot
Pimpernel
Pimpernell
Pimple
Pincushion
Pine
Pineapple
Pinecone
Pinion
Pink
Pinscher
Pinstripe
Pinto
Pipe
Pirogi
Pistachio
Pistol
Piston
Pita
Pitch
Pituitary
Pity
Pizza
Placenta
Plain
Plane
Plankton
Plantain
Plaque
Plasma
Plate
Platelet
Platinum
Platypus
Play
Playhouse
Playmaker
Pleasure
Pliers
Pluck
Plum
Plumeria
Plutonium
Pocket
Pocketbook
Pockmark
Poinsettia
Point
Poison
Poker
Poleax
Polish
Polka
Pollution
Polygraph
Pomade
Poncho
Ponderosa
Pony
Ponytail
Poodle
Poppy
Porch
Porcupine
Pore
Porpoise
Porridge
Port
Portrait
Positivity
Postcard
Poster
Potato
Potholder
Potpourri
Prawn
Prefecture
Pregnancy
Preserves
Pride
Primrose
Prison
Prisoner
Prizefight
Processor
Projectile
Projector
Propeller
Protoplasm
Prune
Psoriasis
Puce
Puff
Puffer
Puffin
Pullover
Pulse
Pump
Punk
Punt
Pupa
Puree
Purifier
Purple
Purse
Puss
Pussycat
Putout
Putt
Putter
Puzzle
Python
Quadriceps
Quail
Queasiness
Quiche
Quilt
Quince
Rabbit
Race
Racehorse
Racer
Racetrack
Rack
Radar
Radial
Radiator
Radicchia
Radio
Radish
Radius
Rage
Ragout
Rain
Rainbow
Raincoat
Raisin
Rake
Range
Rapier
Rash
Raspberry
Rattan
Raven
Razor
Razorback
Receiver
Reciever
Recipe
Recliner
Record
Recorder
Rectum
Reef
Refectory
Reflex
Reggae
Regulator
Relief
Reliever
Relish
Replay
Repugnance
Repulsion
Reservist
Residence
Resistance
Resort
Respirator
Restaurant
Retina
Retriever
Reverence
Reversible
Revolver
Rhapsody
Rheumatism
Rhinoceros
Rhythm
Ribbon
Rice
Rife
Riff
Rifle
Rifleman
Rigatoni
Rink
Riverbed
Roach
Roadrunner
Roast
Robe
Robin
Robot
Rock
Rocker
Rocket
Rodent
Rodeo
Roof
Rook
Room
Roommate
Rose
Rosemary
Rotisserie
Rotor
Rottweiler
Rouge
Ruby
Rugby
Ruler
Runner
Rush
Russet
Rust
Rutabaga
Saber
Sable
Sachet
Safe
Safety
Safflower
Sage
Sagebrush
Salad
Salamander
Salami
Saliva
Salivation
Salmon
Salon
Saloon
Salsa
Salt
Saltshaker
Salvo
Samba
Sandal
Sandpiper
Sanguine
Sapphire
Sari
Sarong
Sassafras
Sassafrass
Satellite
Satin
Sauce
Saucepan
Sauerkraut
Sauna
Saute
Saxophone
Scab
Scale
Scalp
Scampi
Scar
Scarab
Scarf
Scat
Schipperke
Schnauzer
Schnitzel
School
Schoolbag
Sciatica
Scimitar
Scissors
Sclerosis
Scoliosis
Sconce
Scone
Score
Scoreboard
Scorpion
Scrapbook
Scrapple
Screen
Screw
Scurvy
Seahorse
Seal
Seashell
Seat
Secondary
Sedge
Seedcake
Semitone
Sensitive
Sepia
Septum
Sequencer
Sequin
Serape
Serenade
Sergeant
Serotonin
Serve
Serviceman
Sesame
Setter
Sextet
Shad
Shame
Shank
Shark
Shaver
Shawl
Shed
Sheep
Shelf
Shellfire
Shellfish
Sheltered
Sherbert
Shiitake
Shillelagh
Shin
Ship
Shipwreck
Shirt
Shock
Shoe
Shoetree
Shogun
Shop
Shortbread
Shortcake
Shortstop
Shot
Shoulder
Shovel
Show
Shower
Showerhead
Shrapnel
Shredder
Shrew
Shrimp
Shrub
Shuriken
Side
Siege
Sienna
Signal
Silencer
Silks
Silkworm
Silo
Silver
Silverfish
Silverware
Simulator
Sincerity
Single
Sink
Sinus
Sinusitis
Siren
Sisal
Sitar
Skate
Skateboard
Skater
Skeet
Skeleton
Skin
Skink
Skirt
Skull
Skullcap
Skunk
Skydiver
Skyscraper
Slapshot
Slate
Slice
Slicer
Slide
Slingshot
Slipcover
Sloe
Sloth
Slow
Slug
Smallmouth
Smallpox
Smash
Smell
Smelt
Smog
Smoke
Snail
Snake
Snapdragon
Snare
Snatch
Sniper
Snot
Snowboard
Snowflake
Snowmobile
Snowplow
Snowshoe
Snowsuit
Snuffbox
Soap
Soccer
Sock
Socket
Sofa
Softball
Sole
Solo
Somberness
Sombrero
Somersault
Sonar
Sonata
Song
Songbird
Sonic
Sore
Sorrow
Sortie
Soundtrack
Soup
Sourdough
Spacecraft
Spaghetti
Spare
Spareribs
Speakeasy
Spear
Spearmint
Sphincter
Spice
Spider
Spike
Spin
Spine
Spirogyra
Spitball
Spleen
Split
Sponge
Spoon
Sprinkler
Sprint
Squab
Squad
Squadron
Squash
Squid
Stable
Staff
Stag
Stairs
Stairway
Stallion
Stamp
Stanza
Star
Starch
Starfish
Starflower
Stationery
Steak
Steal
Steam
Steamboat
Stereo
Stew
Stewardess
Stickball
Stickpin
Stiletto
Stingray
Stinkbug
Stole
Stool
Stopwatch
Stork
Storybook
Stove
Strainer
Strategy
Strawberry
Strike
Strikeout
Stroke
Strongbox
Strum
Stucco
Studio
Study
Sturgeon
Stylus
Submarine
Sub-Marine
Substitute
Succotash
Succulent
Sugar
Sugarcane
Sugarplum
Suite
Sukiyaki
Summit
Sunbonnet
Sundress
Sunflower
Sunglasses
Sunscreen
Sunset
Supper
Surfboard
Surfer
Surrender
Sushi
Suspense
Suspicion
Swan
Swarm
Sweat
Sweatband
Sweatshirt
Sweet
Sweetbread
Sweetmeat
Swimsuit
Sword
Swordfish
Sycamore
Syllabub
Sympathy
Symphony
Synagogue
Synapsis
Syphilis
Syrup
Tabbouleh
Tabby
Tabernacle
Table
Tablecloth
Tack
Tackle
Taco
Tactic
Tailback
Tailgate
Taillight
Tailpipe
Takedown
Tamale
Tamarind
Tambourine
Tangerine
Tango
Tank
Tape
Tapestry
Tapeworm
Tarantula
Target
Tarragon
Tart
Tattoo
Taupe
Tavern
Teacup
Teak
Teal
Teapot
Teaspoon
Telephone
Television
Tempo
Tenderloin
Tenderness
Tendon
Tendonitis
Tennis
Tenor
Tent
Tepee
Teriyaki
Terrapin
Terrarium
Tetherball
Tetra
Thalamus
The
Thermostat
Thesaurus
Thigh
Thorax
Thread
Thresher
Throat
Thrombosis
Thrush
Thruster
Thug
Thumb
Thumbnail
Thumbtack
Thyme
Tiara
Tibia
Tick
Tiebreaker
Tiger
Tights
Tile
Tilefish
Timer
Timidity
Tiramisu
Tire
Tissue
Titmouse
Toad
Toadstool
Toast
Toboggan
Toga
Toilet
Tomahawk
Tomatillo
Tomato
Tone
Tongs
Tongue
Tonsil
Toolshed
Tooth
Toothache
Toothbrush
Toothpaste
Toothpick
Topaz
Torso
Torte
Tortellini
Tortilla
Tortoise
Toucan
Touchback
Touchdown
Toupee
Towel
Tower
Track
Train
Trampoline
Transpose
Trapezius
Trash
Tray
Treadmill
Treehouse
Triangle
Trifle
Trio
Tripe
Triple
Trombone
Trophy
Trout
Truck
Trunk
Tuba
Tuber
Tulip
Tumblebug
Tumbleweed
Tumor
Tuna
Tune
Tuner
Turban
Turkey
Turmeric
Turnip
Turnover
Turntable
Turquoise
Turtle
Turtledove
Turtleneck
Twang
Tweed
Typewriter
Ulcer
Ultrasound
Umber
Umbrella
Umpire
Underpants
Underwear
Upholstery
Uppercut
Upset
Urchin
Urine
Uterus
Uvula
Vacuum
Valve
Vanity
Vaporizer
Vase
Veal
Vegetable
Vein
Veneration
Vent
Ventilator
Ventricle
Vermicelli
Vermin
Verse
Vertebra
Vest
Vine
Viola
Violet
Violin
Viper
Virus
Visor
Volley
Volleyball
Vomit
Wafer
Waffle
Waist
Wall
Wallet
Wallpaper
Walnut
Walrus
Waltz
Wardrobe
Warehouse
Warhorse
Warmth
Warplane
Wart
Washcloth
Washer
Wasp
Watch
Watchtower
Watercress
Waterdog
Watermelon
Weasel
Wedge
Weed
Weeder
Weevil
Whale
Wheat
Wheel
Wheelbase
Wheelchair
Whelk
Whiff
Whip
Whirlpool
Whisk
White
Whitefish
Wigwam
Wild
Wildflower
Willow
Winch
Wind
Window
Windshield
Windsock
Winepress
Wing
Wiper
Wishbone
Wisteria
Wolf
Wolverine
Wombat
Wood
Woodpecker
Woodshed
Woodwind
Woofer
Words
Workhouse
Workshop
Worm
Wormwood
Wraparound
Wrasse
Wrath
Wreath
Wren
Wrench
Wrestler
Wrist
Wristband
Wristlet
Wristwatch
Yard
Yardstick
Yearbook
Yeast
Yellow
Yellowtail
Yodel
Yogurt
Yolk
Your
Yucca
Zabaglione
Zapper
Zeal
Zebra
Zenith
Zeppelin
Zinnia
Zither
Zone
Zucchini

Windows 7 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)


iPhilip
  • Members
  • 138 posts
  • Last active: Sep 12 2015 06:27 PM
  • Joined: 03 Jun 2010

Below is a modified version of the script (v1.0.2) with several bugs fixes and minor enhancements. All the changes are documented in the script and can be found by searching for iPhilip.
 

; Changes in v1.0.2 by iPhilip
;
; Made the Gui always on top
; Fixed a bug associated with the InputBox statement
; Fixed a bug so that the number of wrong words is not incremented after the first press
; Fixed a bug associated with the letters count when the New Word button is pressed
; Added 3 hotkeys:
;    ^n - New Word
;    ^s - Solve Word (active only during the game)
;    ^q - Quit Hangman
; Rearranged how the statistics are shown and added the total number of letters in the word
; Changed the InputBox statement so that the current word is shown as the default value

;===========================================================================================================================================================
;Directives
;===========================================================================================================================================================

#SingleInstance, Force
#NoTrayIcon
#NoEnv

;===========================================================================================================================================================
;Setup base variables
;===========================================================================================================================================================

;Application Info
App_Name    := "Hangman"
App_Version := "1.0.2"

;Gui Numbers
Gui_Hangman := 1

;File Paths
Files_Pictures := "Images"
Files_Hangman  := "Hangman_{Nr}.png" ;{Nr} will be replaced by count of wrong answers
Files_Wordlist := "Hangman_Words.txt"

;Letters
Letters_Alpha := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;Letters the player has to guess

;Word specific
Words0     := 0  ;Count of Array Entries
Word_Game  := "" ;Word as visible in game
Word_Full  := "" ;Word as loaded from file
Word_Count := 0  ;Last replacement count of a letter
Word_AllLt := 0  ;Count of all revealed letters
Word_Wrong := 0  ;Count of wrong guessings

;Gameplay
Game_MaxWrong := 6 ;Count of wrong answers for gameover

;===========================================================================================================================================================
;Setup the program
;===========================================================================================================================================================

Main:
  ;Load all words into memory
  Hangman_LoadWordList()
  ;Create all windows
  GoSub, Hangman_CreateGui
  ;Load the first random word
  GoSub, Hangman_NewWord
  Return

;===========================================================================================================================================================
;Hangman Labels
;===========================================================================================================================================================

Hangman_CreateGui:
  ;Setup the gui options
  Gui, %Gui_Hangman%:+AlwaysOnTop -Border +ToolWindow +LastFound +LabelHangman_ -Theme   ;iPhilip: added +AlwaysOnTop
    ;Setup the font setting
    Gui, %Gui_Hangman%:Font, Bold, Arial
    ;Create the titlebar
    Gui, %Gui_Hangman%:Add, Text, x5 y5 w350 h20 +0x1000, % "  " App_Name " [V" App_Version "] - " Words0 " Words loaded"
    Gui, %Gui_Hangman%:Add, Text, x5 y5 w330 h20 +BackgroundTrans gHangman_MoveGui
    Gui, %Gui_Hangman%:Add, Button, x335 y8 w15 h15 gHangman_Close, X
    ;Create hangman picture
    Gui, %Gui_Hangman%:Add, Picture, x5 y30 w350 h350 +0x1000 vHangman_Pic
    ;Create the word container
    Gui, %Gui_Hangman%:Add, Text, x5 y395 w350 h40 +0x1000 vHangman_Word
    Gui, %Gui_Hangman%:Add, Text, x5 y440 w350 h65 +0x1000
    ;Only use hotkeys on this window
    Hotkey, IfWinActive, Hangman ahk_class AutoHotkeyGUI
    ;iPhilip: added ahk_class AutoHotkeyGUI to make the InputBox statement in Hangman_SolvedWord work properly
    ;Create the alphabetical buttons
    Loop, Parse, Letters_Alpha
    {
      ;If it's first button, or first button of second line, use 40
      If (A_Index = 1 || A_Index = 14)
        XPos := 40
      ;Increment the horizontal position by 22 otherwise
      Else XPos := "p+22"
      ;Use vertical position 40 on first line, on second line 65
      YPos := (A_Index < 14) ? 450 : 475
      Gui, %Gui_Hangman%:Add, Button, x%XPos% y%YPos% w20 h20 vHangman_Letter%A_Index% gHangman_NewLetter, % A_LoopField
      ;Create a hotkey as well
      Hotkey, % A_LoopField, Hangman_NewLetterByHotkey, On
    }
    Hotkey, ^n, Hangman_NewWord   ;iPhilip: hotkey for New Word button
    Hotkey, ^q, Hangman_Close     ;iPhilip: hotkey for quitting Hangman
    ;Create gameplay specific controls
    Gui, %Gui_Hangman%:Add, Text, x5 y512 w195 h20 vHangman_Stat, Letters: 0/0   Wrong: 0/0
    ;iPhilip: changed Wrong: 0/0 Letters: 0 to Letters: 0/0   Wrong: 0/0
    Gui, %Gui_Hangman%:Add, Button, x200 y510 w75 h20 gHangman_SolveWord, Solve Word
    Gui, %Gui_Hangman%:Add, Button, x280 y510 w75 h20 gHangman_NewWord, New Word
  ;Create and show the gui
  Gui, %Gui_Hangman%:Show, w360 h535, Hangman
  Return

Hangman_NewWord:
  ;Ensure that everything's in the start state
  Hangman_Reset()
  ;Load the random word
  Hangman_LoadWord()
  Return

Hangman_SolveWord:
Gui, %Gui_Hangman%:+OwnDialogs   ;iPhilip: added statement to make sure input box shows up on top of Gui window
  InputBox, Word, Hangman - Solve Word, Enter the word:,, 300, 120,,,,, %Word_Game%   ;iPhilip: changed 120 to 120,,,,, %Word_Game%
  If (Word = Word_Full) {
    ;Show the full word
    GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Full
    ;Disable all buttons
    Hangman_LetterState(0)
    ;Show "Game Won" Message
    MsgBox,, Hangman, Congratulations! You've won the game!
  } Else MsgBox,, Hangman, Sorry`, that wasn't correct!
  Return

Hangman_NewLetter:
  ;Retrieve the letter of the pressed control
  GuiControlGet, Letter,, % A_GuiControl
  ;Check if this letter is within the word
  Hangman_CheckLetter(Letter)
  ;Disable control
  GuiControl, %Gui_Hangman%:Disable, % A_GuiControl
  Return

Hangman_NewLetterByHotkey:
  ;Use the hotkey button name
  Letter := A_ThisHotkey
  ;Check if this letter is within the word
  Hangman_CheckLetter(Letter)
  ;Loop through all allowed characters
  Loop, Parse, Letters_Alpha
    ;If the current character was the pressed key
    If (A_LoopField = Letter) {
      ;Disable the control
      GuiControl, %Gui_Hangman%:Disable, % "Hangman_Letter" A_Index
      ;Change the hotkey state   ;iPhilip: added to avoid incrementing the number of wrong words after the first press
      Hotkey, %Letter%, Off      ;iPhilip: added to avoid incrementing the number of wrong words after the first press
      ;Break from the loop
      Break
    }
  Return

Hangman_MoveGui:
  PostMessage, 0xA1, 2,,, A
  Return

Hangman_Escape:
Hangman_Close:
Gui, %Gui_Hangman%:+OwnDialogs   ;iPhilip: added statement to make sure MsgBox shows up on top of Gui window
  MsgBox, 64, Hangman, % App_Name " [V" App_Version "]`n`nCreated by: Banane`nModified by: iPhilip"   ;iPhilip: added `nModified by: iPhilip
  ExitApp

;===========================================================================================================================================================
;Functions
;===========================================================================================================================================================

Hangman_Reset() {
 global

  ;Reset all variables
  Word_Game  := ""
  Word_Full  := ""
  Word_Count := 0
  Word_AllLt := 0   ;iPhilip: necessary to reset count when pressing New Word button
  Word_Wrong := 0
  ;Enable letter buttons
  Hangman_LetterState(1)
  ;Restore standard values
;  GuiControl, %Gui_Hangman%:, Hangman_Word,                                               ;iPhilip: deleted
;  GuiControl, %Gui_Hangman%:, Hangman_Stat, % "Wrong: 0/" Game_MaxWrong " Letters: 0/0"   ;iPhilip: moved to Hangman_LoadWord()
  Hangman_HangmanImage()
}

Hangman_HangmanImage() {
 global
 local Image

  StringReplace, Image, Files_Hangman, {Nr}, % Word_Wrong
  GuiControl, %Gui_Hangman%:, Hangman_Pic, % Files_Pictures "\" Image
}

Hangman_LoadWordList() {
 global
 local Currword

  ;Read the file line by line
  Loop, Read, % Files_Wordlist
    ;Only create array entry for this line, if not empty
    If (A_LoopReadLine <> "")
      ;Increase array count and save current word in pseudo array
      Words0 ++,Words%Words0% := A_LoopReadLine,Currword := ""
}

Hangman_LoadWord() {
 global
 local Currword

  ;Select a random word from array
  Random, Currword, 1, % Words0
  ;Set currword to the word in Words%Currword%
  Currword := Words%Currword%
  ;Change all alphabetical letters to _
  Loop, Parse, Currword
    Word_Game .= (InStr(Letters_Alpha,A_LoopField)) ? "_" : A_LoopField
  ;Make every letter uppercase
  StringUpper, Word_Full, Currword
  ;Change the content of the word control
  GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Game
  GuiControl, %Gui_Hangman%:, Hangman_Stat, % "Letters: 0/" StrLen(Word_Full) "   Wrong: 0/" Game_MaxWrong
  ;iPhilip: changed "Wrong: 0/" Game_MaxWrong " Letters: 0" to "Letters: 0/ ...
}

Hangman_CheckLetter(Input) {
 global

 Gui, %Gui_Hangman%:+OwnDialogs   ;iPhilip: added statement to make sure MsgBox shows up on top of Gui window
  ;Reset the found letter count
  Word_Count := 0
  ;Parse through every letter of the full word
  Loop, Parse, Word_Full
    ;If the current letter is equal to the specified one
    If (A_LoopField = Input)
      ;Change the _ of this position with the letter and increase count
      Word_Game := SubStr(Word_Game,1,A_Index - 1) Input SubStr(Word_Game,A_Index + 1,StrLen(Word_Game)),Word_Count ++
  ;Increase the count of wrong guessings if no letter was replaced, change control text otherwise
  If (Word_Count = 0)
    Word_Wrong ++,Hangman_HangmanImage()
  Else GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Game
  Word_AllLt := Word_AllLt + Word_Count
  ;Update the statistics
  GuiControl, %Gui_Hangman%:, Hangman_Stat, % "Letters: " Word_AllLt "/" StrLen(Word_Full) "   Wrong: " Word_Wrong "/" Game_MaxWrong
  ;iPhilip: changed "Wrong: " Word_Wrong "/" Game_MaxWrong " Letters: " Word_AllLt to "Letters: ...
  ;If the count is equal to the maximum count of wrong guessings (6 by default)
  If (Word_Wrong = Game_MaxWrong || Word_Game = Word_Full) {
    ;Show the full word
    GuiControl, %Gui_Hangman%:, Hangman_Word, % Word_Full
    ;Disable all buttons
    Hangman_LetterState(0)
    ;Show "Game Over" / "Game Won" Message
    MsgBox,, Hangman, % (Word_Wrong = Game_MaxWrong) ? "Game Over!" : "Congratulations! You've won the game!"
  }
}

Hangman_LetterState(Mode) {
 global

  ;Check whether the buttons should be enabled or disabled
  Mode := (Mode = 1) ? "Enable" : "Disable"
  ;Apply the state to every button
  Loop, % StrLen(Letters_Alpha) {
    ;Change the control state
    GuiControl, %Gui_Hangman%:%Mode%, Hangman_Letter%A_Index%
    ;Change the hotkey state
    Hotkey, % SubStr(Letters_Alpha,A_Index,1), % (Mode = "Enable") ? "On" : "Off"
  }
  Hotkey, ^s, Hangman_SolveWord, % (Mode = "Enable") ? "On" : "Off"   ;iPhilip: hotkey for Solve Word button
}


Windows 7 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)