ileandros Posted February 18, 2012 Share Posted February 18, 2012 (edited) Hello there, I want to make this thing while 1 Case $Button1 if $Button2 ;Is not pressed Then MsgBox(0,"Error", "$Button2 is not pressed") WEnd $Button2 is disabled when pressed! GUICtrlSetState($Button2, $GUI_DISABLE) What i mean is that i want to create a MsgBox while pressing $Button1 in Case $Button2 is not pressed! Edited February 18, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
JohnOne Posted February 18, 2012 Share Posted February 18, 2012 Case needs a Switch or Select AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 Yes i know i just wrote it as an example. The problem is that i get confused and j dont know how it should be build right. I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Xandy Posted February 18, 2012 Share Posted February 18, 2012 switch $imaswitchvariable case $a ;statements excuted on $imaswitchvariable= $a ;... case $bee ;statements excuted on $imaswitchvariable= $bee ;... case "liquor store guy" ;statements excuted on $imaswitchvariable= "liquor store guy" ;... endswitch;end switch $imaswitchvariable Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 Xandy i have created to case statement. The problem is that i dont know excactly how to give the order to create msgbox if $Button2 is not pressed in case i press $Button1... I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 18, 2012 Moderators Share Posted February 18, 2012 ileandros, If I understand you correctly then this should show you how to do what you want: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton_1 = GUICtrlCreateButton("Button 1", 10, 10, 80, 30) $cButton_2 = GUICtrlCreateButton("Button 2", 10, 90, 80, 30) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_1 ; Check if button is disabled If BitAnd(GUICtrlGetState($cButton_2), $GUI_DISABLE) Then MsgBox(0, "Hi", "Button 2 is disabled") Else MsgBox(0, "Hi", "Button 2 is enabled") EndIf Case $cButton_2 ; Disable button GUICtrlSetState($cButton_2, $GUI_DISABLE) EndSwitch WEnd If I have got it wrong then please explain further. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 This was some kind of help but... Here is the situatuation. $Button2 creates another gui web browser (gui2) in case it is pressed. $Button1 navigates the web browser gui2 created. (url is picked from the list) I have also added $obj = _IEGetObjById($oIE,"test") $obj.ScrollIntoView() to the navigate. In case i press $Button1 while $Button2 is not pressed i get this error C:UsersdolfiDesktoptestsqd - Copy.au3 (51) : ==> Variable must be of type "Object".: $obj.ScrollIntoView() $obj^ ERROR I want to avoid this error and to create a MsgBox saying that u have to press $Button2 first!!!! Voila! I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 GOTHCA!!!!!!!!!!!!! Solved!!!!!!! I added _IEErrorHandlerRegister() and solved. Thank you all I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 (edited) It was my bad because i was focusing on creating the MsgBox and not handeling the error Edited February 18, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 ileandros, If I understand you correctly then this should show you how to do what you want: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton_1 = GUICtrlCreateButton("Button 1", 10, 10, 80, 30) $cButton_2 = GUICtrlCreateButton("Button 2", 10, 90, 80, 30) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_1 ; Check if button is disabled If BitAnd(GUICtrlGetState($cButton_2), $GUI_DISABLE) Then MsgBox(0, "Hi", "Button 2 is disabled") Else MsgBox(0, "Hi", "Button 2 is enabled") EndIf Case $cButton_2 ; Disable button GUICtrlSetState($cButton_2, $GUI_DISABLE) EndSwitch WEnd If I have got it wrong then please explain further. M23 This is good but i got an issue. The MsgBox appears as i want to but the problem is it continues appearing even when $Button2 is disable. Can i make the MsgBox stop/end when $Button2 is pressed/disabled and activate them again in case $Button2 is enabled??? I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 18, 2012 Moderators Share Posted February 18, 2012 ileandros,The code already does that - just replace the relevant MsgBox with the code you want to run once the button is pressed/disabled: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton_1 = GUICtrlCreateButton("Button 1", 10, 10, 80, 30) $cButton_2 = GUICtrlCreateButton("Button 2", 10, 90, 80, 30) $cButton_3 = GUICtrlCreateButton("Re-enable 2", 10, 460, 80, 30) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_1 ; Check if button is disabled If BitAnd(GUICtrlGetState($cButton_2), $GUI_DISABLE) Then ; Here you put the code that you will run if $cButton_2 is pressed/disabled Else MsgBox(0, "Hi", "Button 2 is still enabled") EndIf Case $cButton_2 ; Disable button GUICtrlSetState($cButton_2, $GUI_DISABLE) Case $cButton_3 ; Re-enable button GUICtrlSetState($cButton_2, $GUI_ENABLE) EndSwitch WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 (edited) Ouf. I made an example. Check it out. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <IE.au3> Local $hGUI2, $oIE, $Button1, $Button2, $Button3, $Button4, $hForm1 _IEErrorHandlerRegister() $hForm1 = GUICreate("gui1", 230, 170, 230, 230) $List1 = GUICtrlCreateCombo("", 40,40,150, 100) GUICtrlSetData(-1,"test1|test2|test3") GUICtrlSetColor(-1,0x39045A) $Group1 = GUICtrlCreateGroup("Group 1", 24, 16, 180, 140) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button4 = GUICtrlCreateButton("Go!",40,70, 50, 25) $Button2 = GUICtrlCreateButton("Stop",140,70, 50, 25) $Button1 = GUICtrlCreateButton("gui2",40,110, 50, 25) $Button3 = GUICtrlCreateButton("Exit",140,110, 50, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $hForm1 Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $Button2 _IEAction($oIE,"Stop") Case $Button4 If BitAnd(GUICtrlGetState($Button1), $GUI_DISABLE) Then MsgBox(0, "Hi", "Button 1 is disabled") Else MsgBox(0, "Hi", "Button 1 is enabled") EndIf If GUICtrlRead($List1) = "" Then MsgBox(0,"Error", "Select from the List") ElseIf GUICtrlRead($List1) = "test1" Then _IENavigate($oIE,";Add your url here",1) $obj = _IEGetObjById($oIE,";Add your id object here") $obj.ScrollIntoView() Endif Case $Button1 GUICtrlSetState($Button1, $GUI_DISABLE) gui2() EndSwitch Case $hGUI2 Switch $msg[0] Case $GUI_EVENT_CLOSE GUIDelete($hGUI2) GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch EndSwitch WEnd Func gui2() $hGUI2 = GUICreate("testgui2", 330, 110, 476, 230) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE,0,0,330,110) GUISetState(@SW_SHOW) EndFunc Button "Go!" navigates. I tried to swap with the MsgBox as u said but didnt make it. Edited February 18, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 Well this works fine the only problem is that when i press "Go!" it keep showing the MsgBox that "gui2" is disabled everytime i press it. This is what i want to avoid! I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 18, 2012 Moderators Share Posted February 18, 2012 ileandros,You could do it like this: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <IE.au3> Local $hGUI2, $oIE, $Button1, $Button2, $Button3, $Button4, $hForm1 _IEErrorHandlerRegister() $hForm1 = GUICreate("gui1", 230, 170, 230, 230) $List1 = GUICtrlCreateCombo("", 40, 40, 150, 100) GUICtrlSetData(-1, "test1|test2|test3") GUICtrlSetColor(-1, 0x39045A) $Group1 = GUICtrlCreateGroup("Group 1", 24, 16, 180, 140) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button4 = GUICtrlCreateButton("Go!", 40, 70, 50, 25) $Button2 = GUICtrlCreateButton("Stop", 140, 70, 50, 25) $Button1 = GUICtrlCreateButton("gui2", 40, 110, 50, 25) $Button3 = GUICtrlCreateButton("Exit", 140, 110, 50, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $hForm1 Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $Button2 _IEAction($oIE, "Stop") Case $Button4 ; Is button enabled? If BitAND(GUICtrlGetState($Button1), $GUI_ENABLE) Then ; Yes, so tell user MsgBox(0, "Hi", "You need to press the 'gui2' button first") ; But if it is disabled we can proceed Else ; Now we se if the combo has a selection If GUICtrlRead($List1) = "" Then ; No, so tell user MsgBox(0, "Error", "Select from the List") ElseIf GUICtrlRead($List1) = "test1" Then _IENavigate($oIE, ";Add your url here", 1) $obj = _IEGetObjById($oIE, ";Add your id object here") $obj.ScrollIntoView() EndIf EndIf Case $Button1 GUICtrlSetState($Button1, $GUI_DISABLE) gui2() EndSwitch Case $hGUI2 Switch $msg[0] Case $GUI_EVENT_CLOSE GUIDelete($hGUI2) GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch EndSwitch WEnd Func gui2() $hGUI2 = GUICreate("testgui2", 330, 110, 476, 230) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 0, 0, 330, 110) GUISetState(@SW_SHOW) EndFunc ;==>gui2But if I may, I think you are going about this the wrong way. I would disable the "Go!" button unless $hGUI2 had been created. That way you do not have a problem. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ileandros Posted February 18, 2012 Author Share Posted February 18, 2012 I knew it was so damn simple.!!!!!!!!!!!! I'm an idiot. Yeah that would be a good idea but i need to inform others what to do. Thats why i'm making MsgBox. Thank you and plz follow a little bit more this topic in case i need some more assistance! I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now