Jump to content

Button Not working


Kiti
 Share

Recommended Posts

Here's my smallest stand alone code. Button from the second GUI are not working ($Button1). Anyone know how to solve this? :) Thanks!

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("Custom Msgbox", 210, 250)
GUICtrlCreateLabel("Please click a button!", 10, 10)
$radio1 = GUICtrlCreateRadio("Menu 1", 10, 60, 120, 20)
$Btn = GUICtrlCreateButton("Go Ahead", 50, 190, 90, 20)
GUICtrlSetOnEvent($Btn, "onPress")

GUISetState()

While 1
    Sleep(100)
WEnd


Func OnPress()
    $msg = GUIGetMsg()
    Select
        Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED

            $Form2 = GUICreate("Some Title", 378, 126, 302, 282)
            $Button1 = GUICtrlCreateButton("Button 1", 135, 80, 75, 25, 0)
            $Label1 = GUICtrlCreateLabel("Click here:", 88, 32, 200, 17)
            GUISetState(@SW_SHOW)
            ;from here it starts not to work
            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        MsgBox(48, "", "Bye!")
                        Exit
                    Case $Button1
                        MsgBox(64, "", "You pressed Button 1")
                EndSwitch
            WEnd

    EndSelect

EndFunc   ;==>OnPress
Link to comment
Share on other sites

hi!

first you dont need to ask for it 3 times.

second. you should use "OnEvent" OR "Linear" code.

remove this line:

Opt("GUIOnEventMode", 1)

GUICtrlSetOnEvent($Btn, "onPress")

You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"
Link to comment
Share on other sites

hi!

first you dont need to ask for it 3 times.

second. you should use "OnEvent" OR "Linear" code.

remove this line:

Opt("GUIOnEventMode", 1)

GUICtrlSetOnEvent($Btn, "onPress")

I didn't want to ask 3 times! If I asked once, why should I need to ask 2 more times? I just thought my post wasn't posted becouse of an error message. When you get a message saying

"404 Error!!! Our server encounterd a problem. Please contact the webmaster at webmaster@autoit.com to solve this problem",

what would you think?

"Oh cool! My topic was posted! It's on the forum! Soon someone will help me!"

I guess not. Neither I. That's why I retried posting it.

you should use "OnEvent" (...)

remove this line:

Opt("GUIOnEventMode", 1)

GUICtrlSetOnEvent($Btn, "onPress")

So, i should use onEvent, or remove the onEvent?

First: If I'm not already using onEvent, I don't know how to use it...

Second: I removed those lines, and my first button also stopped working.

Link to comment
Share on other sites

here is the linear example. i dont know how to use onEvent with 2 forms.

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
;Opt("GUIOnEventMode", 1)
$gui = GUICreate("Custom Msgbox", 210, 250)
GUICtrlCreateLabel("Please click a button!", 10, 10)
$radio1 = GUICtrlCreateRadio("Menu 1", 10, 60, 120, 20)
$Btn = GUICtrlCreateButton("Go Ahead", 50, 190, 90, 20)
;GUICtrlSetOnEvent($Btn, "onPress")
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn
            
            ;Second Gui
            Select
                Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED

                    $Form2 = GUICreate("Some Title", 378, 126, 302, 282)
                    $Button1 = GUICtrlCreateButton("Button 1", 135, 80, 75, 25, 0)
                    $Label1 = GUICtrlCreateLabel("Click here:", 88, 32, 200, 17)
                    GUISetState(@SW_SHOW)
                    ;from here it starts not to work
                    While 1
                        $nMsg = GUIGetMsg()
                        Switch $nMsg
                            Case $GUI_EVENT_CLOSE
                                MsgBox(48, "", "Bye!")
                                Exit
;If you wish to close the second gui, and not exit, replace the exit with GuiDelete + Exitloop

                            Case $Button1
                                MsgBox(64, "", "You pressed Button 1")
                        EndSwitch
                    WEnd

            EndSelect
    EndSwitch
WEnd
Edited by Linux
You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"
Link to comment
Share on other sites

raisim

I rather want a succession of windows, exactly like VBS, a tree shaped flow of the program, each box having some buttons to choose, which opens up other boxes with other choises. I never want two boxes at the same time on the screen, or a parent-child type.

Linux

Thanks a lot for your help. But when I've tryed to make to implement the changes to my full script, I found that impossible. All six loops are desorientating me.

EndSwitch
                    WEnd

            EndSelect
    EndSwitch
WEndoÝ÷ Øw«z+&Éû¥Ç+ZºÚ"µÍÚ[ÛYH    ÑÕRPÛÛÝ[Ñ^]LÉÝÂÚ[ÛYH ÑÕRPÛÛÝ[Ë]LÉÝÂÚ[ÛYH  ÑÕRPÛÛÝ[Ñ^]LÉÝÂÛØ[   ÌÍØHH    ÌÍØH ÌÍØÈHÜ
    ][ÝÓ[ÝÙPÛXÚÑ[^I][ÝË    ÌÍØÊBÜ
    ][ÝÓ[ÝÙPÛXÚÑÝÛ[^I][ÝË    ÌÍØÊBÜ
    ][ÝÑÕRSÛ][[ÙI][ÝËJBÙÐÞ
    ][ÝÒ[ÉÌÌÎÉ][ÝË ][ÝÕÈÈHÛÛÛØÜÚXÚÛÛÈZ[ÝÙY[ÛHHÙXÛÛ ÌÌÎÈÈ[ÝHØ[ÈÙYH]É][ÝÊB[ÞÝ[Q    [È ][ÝÉÌLÝÚ[Z[K^I][ÝÊBÚ[ØZ]XÝ]J  ][ÝÓZ[ÝÙY][ÝÊBÚ[Ù][J    ][ÝÓZ[ÝÙY][ÝÊBÚ[[ÝJ ][ÝÓZ[ÝÙY][ÝË ][ÝÉ][ÝËKN
ÊBÙ[
    ][ÝÞ^^ÓÒQ^ÑSTI][ÝÊBÛØ[ ÌÍÙÝZHHÕRPÜX]J    ][ÝÐÝÝÛHÙØÞ ][ÝËLL
BÕRPÝÜX]SX[
    ][ÝÔXÙHÛXÚÈH]ÛÌÌÎÉ][ÝËLL
BÛØ[  ÌÍÜY[ÌHHÕRPÝÜX]TY[Ê ][ÝÐYÚ[][ÝËL
L
BÛØ[  ÌÍÜY[ÌHÕRPÝÜX]TY[Ê  ][ÝÒ[YYX]I][ÝËLLL
BÛØ[  ÌÍÜY[ÌÈHÕRPÝÜX]TY[Ê    ][ÝÑ^ ][ÝËLLL
BÛØ[  ÌÍÜY[ÍHÕRPÝÜX]TY[Ê  ][ÝÐÝÝÛI][ÝËLMLL
BÛØ[  ÌÍÐHÕRPÝÜX]P]Û   ][ÝÑÛÈZXY   ][ÝË
LNLL
BÕRPÝÙ]Ý]J  ÌÍÜY[ÌK ÌÍÑÕRWÐÒPÒÑQ
BÕRPÝÙ]Û][
    ÌÍР ][ÝÛÛÜÉ][ÝÊBÕRTÙ]Û][
    ÌÍÑÕRWÑUSÐÓÔÑK ][ÝÓÛ^]  ][ÝÊBÕRTÙ]Ý]J
BÚ[HBTÛY
L
BÑ[ËKKKKKKKKKKKKKKH[Ý[ÛÈKKKKKKKKKKKKKKB[ÈÛÜÊ
BIÌÍÛÙÈHÕRQÙ]ÙÊ
BTÙ[XÝBPØÙH]S
ÕRPÝXY
    ÌÍÜY[ÌJK    ÌÍÑÕRWÐÒPÒÑQ
HH  ÌÍÑÕRWÐÒPÒÑQBBQÕRTÙ]Ý]JÕ×ÒQJBBBUÚ[XÝ]]J ][ÝÓZ[ÝÙY][ÝÊBBBUÚ[ØZ]XÝ]J ][ÝÓZ[ÝÙY][ÝÊBBBS[ÝÙPÛXÚÊ    ][ÝÜ[XI][ÝËLËK
BBBS[ÝÙPÛXÚÊ   ][ÝÜ[XI][ÝËLÌKK
BBBQÛØ[   ÌÍÛHHBBQÛØ[    ÌÍÛHBPØÙH]S
ÕRPÝXY
    ÌÍÜY[ÌK ÌÍÑÕRWÐÒPÒÑQ
HH  ÌÍÑÕRWÐÒPÒÑQBBQÕRTÙ]Ý]JÕ×ÒQJBBBUÚ[XÝ]]J ][ÝÓZ[ÝÙY][ÝÊBBBUÚ[ØZ]XÝ]J ][ÝÓZ[ÝÙY][ÝÊBBBS[ÝÙPÛXÚÊ    ][ÝÜ[XI][ÝËLËK
BBBS[ÝÙPÛXÚÊ   ][ÝÜ[XI][ÝËLLËK
BBBQÛØ[   ÌÍÛHHMBBBQÛØ[  ÌÍÛHMBBPØÙH]S
ÕRPÝXY
    ÌÍÜY[ÌÊK   ÌÍÑÕRWÐÒPÒÑQ
HH  ÌÍÑÕRWÐÒPÒÑQBBQÕRTÙ]Ý]JÕ×ÒQJBBBUÚ[XÝ]]J ][ÝÓZ[ÝÙY][ÝÊBBBUÚ[ØZ]XÝ]J ][ÝÓZ[ÝÙY][ÝÊBBBS[ÝÙPÛXÚÊ    ][ÝÜ[XI][ÝËLËK
BBBS[ÝÙPÛXÚÊ   ][ÝÜ[XI][ÝËLÌ
K
BBBQÛØ[   ÌÍÛHHMBBBQÛØ[  ÌÍÛHBQ[Ù[XÝSÙÐÞ
    ][ÝÑ]][ÉÌÎNÜÈÙ] ][ÝË  ][ÝÔÜÈÚÈÚ[[ÝIÌÎNÜHXYI][ÝÊBRY   ÌÍØH[BUÛÛ
    ][ÝÒ^IÌÌÎÈÝIÌÌÎÈÈ[ÝHÙYHYOÈHÛÙÈHÛÝ[ÝÛ][ÝÊBBQ[ÙHBUÛÛ
    ][ÝÒHÛÙÈHÛÝ[ÝÛ][ÝÊBQ[YYÛØ[ ÌÍØHBTÛY

BUÛÛ
    ][ÝÌÉ][ÝÊBTÛY
L
BUÛÛ
    ][ÝÌ][ÝÊBTÛY
L
BUÛÛ
    ][ÝÌI][ÝÊBTÛY
L
BUÛÛ
    ][ÝÑÛÉÌÌÎÉ][ÝÊBTÛY
L
BUÛÛ
    ][ÝÉ][ÝÊBRY ÌÍØHHH[BSÜ
    ][ÝÓ[ÝÙPÛÛÜ[ÙI][ÝËBBSÜ
    ][ÝÔ^[ÛÛÜ[ÙI][ÝËBBSØØ[    ÌÍÚÚÝÜHÚ[Ù][J   ][ÝÖÐÓTÔÎÛÜÙ×I][ÝÊBBSØØ[  ÌÍÚZ[TÝÙYHÚ[Ù][J ][ÝÖÐÓTÔÎZ[ÝÙYI][ÝÊBBUÚ[ØZ]XÝ]J    ÌÍÚZ[TÝÙY
BBSØØ[    ÌÍØUÔÜÈHÚ[Ù]ÜÊ    ÌÍÚZ[TÝÙY
BBQÜ   ÌÍÞHHÈ  ÌÍÛBBBQÜ    ÌÍÞHÈ   ÌÍÛBBBIÌÍÞÈHM
È
    ÌÍÞ
MBBBBIÌÍÞXÈH
MÈ
È
    ÌÍÞH
MBBBBT^[ÙXÚ
    ÌÍÞÈHK  ÌÍÞXË   ÌÍÞÈHK  ÌÍÞXËM  ÌÍÚZ[TÝÙY
BBBBRYÝÜ[BBBBS[ÝÙS[ÝJ  ÌÍÞË    ÌÍÞXË
JBBBBBRY
^[Ù]ÛÛÜ ÌÍÚÚÝÜ
HOHH[BBBBBS[ÝÙPÛXÚÊ    ][ÝÜ[XI][ÝË ÌÍÞË    ÌÍÞXËK
BBBBBQ[ÙBBBBBBS[ÝÙPÛXÚÊ   ][ÝÜÙXÛÛI][ÝË    ÌÍÞË    ÌÍÞXËK
BBBBBQ[YBBBQ[YBBS^BS^Q[ÙBBQÜ  ÌÍÚHHÈ  ÌÍÛBBBS[ÝÙS[ÝJLKNH
È  ÌÍÚH
M
BBBQÜ  ÌÍÚÈHÈ ÌÍÛBBBS[ÝÙS[ÝJLH
È  ÌÍÚÈ
MNH
È  ÌÍÚH
M
BBBBIÌÍÞH^[Ù]ÛÛÜ
BBBBRY  ÌÍÞHMÍÍÌMH[BBBBS[ÝÙPÛXÚÊ ][ÝÛY ][ÝÊBBBBQ[ÙBBBBBS[ÝÙPÛXÚÊ   ][ÝÜYÚ   ][ÝÊBBBBQ[YBBS^BS^Q[YUÛÛ
    ][ÝÒ^IÌÌÎÉÌÌÎÉÌÌÎÉ][ÝÊBTÛY

BUÛÛ
    ][ÝÉ][ÝÊBÌÍÑÜHHÕRPÜX]J    ][ÝÕÛÝÈ    ÌÌÎÉÌÌÎÉÌÌÎÈY[ÝHØ]È]ÈÝHÙXÛÛ ÌÌÎÉ][ÝËÍÎLÌBÕRTÙ]XÛÛ  ][ÝÑÎLÉÍÌXÛÉ][ÝÊBÌÍÐ]ÛHHÕRPÝÜX]P]Û    ][ÝÔ^HYØZ[][ÝËMK
ÍKK
BÌÍÐ]ÛHÕRPÝÜX]P]Û   ][ÝÔÛÝÈ[Ý[Û][ÝËL
K
ÍKK
BÌÍÐ]ÛÈHÕRPÝÜX]P]Û ][ÝÑYÌÎNÝÛÜÏÉ][ÝË
ÍKK
BÌÍÓX[HÕRPÝÜX]SX[
    ][ÝÉ][ÝËL


BÌÍÐ]ÛHÕRPÝÜX]P]Û   ][ÝÔÜ[[Ý[Û][ÝËNL
ÍKK
BÌÍÓX[HHÕRPÝÜX]SX[
    ][ÝÔXÙHÙ[XÝÛHÙHÛÝÚ[ÈÜ[ÛÎ][ÝËÌMÊBÕRTÙ]Ý]J
BÚ[HBBÌÍÛÙÈHÕRQÙ]ÙÊ   ÌÍÑÜJBTÝÚ]Ú  ÌÍÛÙÂBPØÙH   ÌÍÑÕRWÑUSÐÓÔÑBBBSÙÐÞ
    ][ÝÓÚË][ÝË    ][ÝÐYKHYH ÌÌÎÉÌÌÎÉÌÌÎÉ][ÝÈ  [ÈÔ   [È ][ÝÉ][ÝÈ    [ÈÔ   [È ][ÝÈYØË ][ÝÈ  [ÈÔ   [È ][ÝÈÚ]H  ][ÝÊBBBUÚ[Ú[
    ][ÝÓZ[ÝÙY][ÝÊBBPØÙH ÌÍÐ]ÛBBBBSÙÐÞ
    ][ÝÓÚÈ[[Ý[ÜYY ][ÝË  ][ÝÔXÙHÙ[XÝH][YØZ[][ÝÊBBBBQÛØ[    ÌÍØHHBPØÙH ÌÍÐ]ÛBBSÙÐÞ
    ][ÝÓÚÈ[ÛÝÈ[Ý[Û][ÝË   ][ÝÔXÙHÙ[XÝH][YØZ[][ÝÈ  [ÈÔ   [È ][ÝÕÙ[XÝYÚ[Ü]^Y[ÙIÌÌÎÉ][ÝÊBBBQÛØ[    ÌÍØHHBBBQÕRTÙ]Ý]JÕ×ÔÒÕÊBBPØÙH ÌÍÐ]ÛÂBBQÕRQ[]J   ÌÍÑÜJBBBQÕRPÜX]J  ][ÝÔÛY][ÝËL
BBBQÕRPÝÜX]SX[
    ][ÝÔÙ[XÝHÚY[ÝÙHÜYY][ÝËLL
BBBQÕRPÝÜX]SX[
    ][ÝÌ  ][ÝËMË

BBBQÕRPÝÜX]SX[
    ][ÝÌL ][ÝËNM

BBBQÕRTÙ]ÐÛÛÜPÑNQ
BBBIÌÍÜÛYHHÕRPÝÜX]TÛYLÍK
BBBQÕRPÝÙ][Z]
LKL
BBBIÌÍØ]ÛHÕRPÝÜX]P]Û    ][ÝÕ[YOÉ][ÝË
ÍK
Ì
BBBQÕRTÙ]Ý]J
BBBQÕRPÝÙ]]J ÌÍÜÛYKJBBBQÂBBBIÌÍÛÙÈHÕRQÙ]ÙÊ
BBBBRY  ÌÍÛÙÈH ÌÍØ]Û[BBBBSÙÐÞ
    ][ÝÜÛYI][ÝËÕRPÝXY
    ÌÍÜÛYJKBBBBQ[YBBU[[ ÌÍÛÙÈH ÌÍÑÕRWÑUSÐÓÔÑBBPØÙH  ÌÍÐ]ÛQ[ÝÚ]ÚÑ[[[ÈÏOIÝÓÛÜÂ[ÈÛ^]

BQ^][[ÈÏOIÝÓÛ^]

Can you rather tell me what's wrong or what should be replaced or added, instead of giving me a ready-made script, please :P. It's kinda hard for me to understand how a script works to that fine detail to which I'm able to replicate it in a much larger and complicated script.

Thanks for your help and patience! :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...