NathanG
NathanG

Reputation: 1645

Can't figure out why this AutoIt code isn't working

the problem is that after you hit ok on this GUI, it doesn't start the function I have.

Func BeginningGUI()
   #Region ### START Koda GUI section ### Form=
   $Form1 = GUICreate("Stronghold Kingdoms", 248, 95, -1, -1)
   $Password = GUICtrlCreateInput("Password", 8, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
   $ButtonOk = GUICtrlCreateButton("OK", 86, 64, 75, 25, $BS_NOTIFY)
   $ButtonCancel = GUICtrlCreateButton("Cancel", 167, 64, 75, 25, $BS_NOTIFY)
   $EnterPassLabel = GUICtrlCreateLabel("Please Enter Your Stronghold Kingdoms Password", 0, 12, 241, 17, 0)
   GUISetState(@SW_SHOW)
   #EndRegion ### END Koda GUI section ###

   While 1
  $nMsg = GUIGetMsg()
  Switch $nMsg
     Case $GUI_EVENT_CLOSE
        Exit
     Case $ButtonCancel
        Exit
     Case $ButtonOk
        Exit
        OpenSHK()
  EndSwitch
   WEnd
EndFunc

I want it to obtain the input word, then save that as a variable and enter it into the later function OpenSHK()

Also when I run OpenSHK() Alone it works fine so it's not that.

Upvotes: 0

Views: 302

Answers (1)

Ken White
Ken White

Reputation: 125757

You're exiting before the call to OpenSHK() is made, causing it to never be called.

   Case $ButtonOk
      Exit
      OpenSHK()
EndSwitch

Exit after that call is made instead:

   Case $ButtonOk
      OpenSHK()
      Exit
EndSwitch

The second problem is that $Password is not the password the user entered; it's a control ID. You need to use GuiCtrlRead to retrieve the value the user entered after the Ok button has been clicked.

Upvotes: 2

Related Questions