Function/Return is not returning a value

Get help with using AutoHotkey and its commands and hotkeys
noob3467

Function/Return is not returning a value

08 Apr 2014, 13:44

;for some reason this does not return any value
[code]
ButttonChoice := FirstGui()
msgbox %ButttonChoice%
ExitApp

FirstGui() {
Gui, +LastFound
GuiHWND := WinExist()
Gui, -SysMenu +Owner
Gui, Add, Button, w90 y10 gFirstB1 Default, One
Gui, Add, Button, w90 y+10 gFirstB2, Two
Gui, Add, Button, w90 y+10 gFirstB3, Three
Gui, Add, Button, w90 y+10 gFirstB4, Four
Gui, Add, Button, w90 y+10 gFirstExit, Exit
Gui, Show,, Buttontest
Return
WinWaitClose, ahk_id %GuiHWND%

FirstB1:
Gui, Destroy
Return 1
FirstB2:
Gui, Destroy
Return 2
FirstB3:
Gui, Destroy
Return 3
FirstB4:
Gui, Destroy
Return 4
FirstExit:
ExitApp
}
[/code]
User avatar
uname
Posts: 18
Joined: 25 Oct 2013, 12:50

Re: Function/Return is not returning a value

08 Apr 2014, 14:21

Code: Select all

ButttonChoice := FirstGui()
msgbox %ButttonChoice%
ExitApp

FirstGui() {
    static firsGuiButton

    Gui New, -SysMenu +Owner
    Gui Add, Button, w90 y10 gButtonEventHandler Default, One
    Gui Add, Button, w90 y+10 gButtonEventHandler, Two
    Gui Add, Button, w90 y+10 gButtonEventHandler, Three
    Gui Add, Button, w90 y+10 gButtonEventHandler, Four
    Gui Add, Button, w90 y+10 gButtonEventHandler, Exit
    Gui Show,, Buttontest
    
    loop
        Sleep 100
    until firsGuiButton

    Gui Destroy
    return {One: 1, Two: 2, Three: 3, Four: 4, Exit: -1}[firsGuiButton], firsGuiButton := ""

ButtonEventHandler:
    firsGuiButton := A_GuiControl
    return
}

Return to “Ask For Help”

Who is online

Users browsing this forum: andylysm, Billykid, carno, Dysphoria, Google [Bot], vsub and 156 guests