Sign in to follow this  
Followers 0
ThaGob

Faulty menu..

2 posts in this topic

Hi

I have created this little menu script with multible choices in multible levels, my problem is that the last level does not execute the command i type.(like the Send() i've typed in)

Below is the code in a shorted-down-version,

any advise would be most welcome

//Jais

---------------------------------------------

#include <GUIConstantsEx.au3>

Global $Paused

HotKeySet("^{PAUSE}", "Terminate")

HotKeySet("^½", "ShowMessage")

While 1

Sleep(100)

WEnd

Func Terminate()

Exit 0

EndFunc

Func ShowMessage()

Opt('MustDeclareVars', 1)

MenuA()

EndFunc

Func MenuA2()

Local $radio1, $radio2, $msg

GUICreate("Assign") ; will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio("&1. Radio1", 10, 10, 120, 20)

$radio2 = GUICtrlCreateRadio("&2. Radio2", 10, 40, 120, 20)

GUISetState() ; will display an dialog box with above checkboxes

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

ExitLoop

ElseIf $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then

Send ("^+{tab}^+{tab}^+{tab}initial{tab}{tab}{tab}>>>AAAAA ^{tab} ^{tab} ^{tab}1^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}qwerty{tab}{tab}{del}")

ExitLoop

ElseIf $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then

Send ("^+{tab}^+{tab}^+{tab}initial{tab}{tab}{tab}>>>BBBBBB ^{tab} ^{tab} ^{tab}1^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}^+{tab}ytrewq{tab}{tab}{del}")

ExitLoop

EndIf

WEnd

GUIDelete()

EndFunc ;==>MenuA2

Func MenuA1()

Local $radio1, $radio2, $msg

GUICreate("Login") ; will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio("&1. Login etellerandersted", 10, 10, 120, 20)

$radio2 = GUICtrlCreateRadio("&2. tekstskriv", 10, 30, 120, 20)

GUISetState() ; will display an dialog box with above checkboxes

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

ExitLoop

ElseIf $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then

Send ("et-eller-andet-brugernavn{tab}password{ASC 043}del2{tab}loebetal")

ExitLoop

ElseIf $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then

Send ("nummer 2 er valgt")

ExitLoop

EndIf

WEnd

GUIDelete()

EndFunc ;==>MenuA1

Func MenuA()

Local $radio1, $radio2, $radio3, $radio4, $radio5, $radio6, $radio7, $radio8, $radio9, $msg

GUICreate("Menu List") ; will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio("&1. Login", 10, 10, 120, 20)

$radio2 = GUICtrlCreateRadio("&2. Assign", 10, 30, 120, 20)

; GUICtrlSetState($radioX, $GUI_CHECKED) ; sets radioX checked as default

GUISetState() ; will display a dialog box

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

ExitLoop

ElseIf $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then

MenuA1()

ExitLoop

ElseIf $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then

MenuA2()

EndIf

WEnd

GUIDelete()

EndFunc ;==>MenuA

--------------------------------

Share this post


Link to post
Share on other sites



You may want to consider restructuring your while loops into 1 loop to make it easier.

This is the general format I use on all my programs - especially with multiple GUI's:

; this is the main while loop that runs the program
; each gui is called into a specific case statement
; below is the structure that it follows
; switch $hwndGUIform     <-- main handle
  ; case $frmTheGui   <-- form the call came from
   ; switch $intGUImsg   <-- switch statement for that form
    ; case $thebuttonpushed   <-- button or item pressed or event, etc
   ;endswitch      <-- close the form switch
  ; case $frmTheNextGUI
   ; switch $intGUImsg
    ; case $thebuttonpushed
   ;endswitch
  ; case $anotherFrm
   ; switch $intGUImsg
    ; case $thebuttonpushed
   ;endswitch
;endswitch       <-- close the main switch

Then dump this into your while loop:

$arrGUIEvents = GUIGetMsg(1)
  $intGUImsg = $arrGUIEvents[0]
  $hwndGUIform = HWnd($arrGUIEvents[1])

then start your switch/ case statements as noted above.

Share this post


Link to post
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
Sign in to follow this  
Followers 0