lostowl Posted July 17, 2010 Share Posted July 17, 2010 (edited) i been trying more if endif while wend or else elseif i dont know why the button1 works but button2 dont. what am i doing wrong expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 616, 552, 202, 132) $Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 0, 24, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $nmsg = $Button1 Then #include <IE.au3> $user = "xxxxxxxx" $pass = "xxxxxxx" $oIE = _IECreate ("https://xxxxxxxxx") $oIE2 = _IECreate ("http://xxxxxxxxxxxxx") _IELoadWait ($oIE) $uForm = _IEFormGetObjByName ($oIE, "login_form") $uText = _IEFormElementGetObjByName ($uForm, "email") _IEFormElementSetValue ($uText,$user) $pText = _IEFormElementGetObjByName ($uForm, "pass") _IEFormElementSetValue ($pText,$pass) _IEFormSubmit ($uForm) Sleep ( 1500) _IENavigate ($oIE2, "xxxxxxxxxxxxxx") Or $nmsg = $Button2 Then #include <IE.au3> $user = "xxxxxxxx" $pass = "xxxxxxxxxxxxxx" $oIE = _IECreate ("https://") $oIE2 = _IECreate ("http://") _IELoadWait ($oIE) $uForm = _IEFormGetObjByName ($oIE, "login_form") $uText = _IEFormElementGetObjByName ($uForm, "email") _IEFormElementSetValue ($uText,$user) $pText = _IEFormElementGetObjByName ($uForm, "pass") _IEFormElementSetValue ($pText,$pass) _IEFormSubmit ($uForm) Sleep (1500) _IENavigate ($oIE2, "http://xxxxxxxxxxxxxxxxxx") EndIf WEnd #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 616, 552, 202, 132) $Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 0, 24, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $nmsg = $Button1 Then #include <IE.au3> $user = "xxxxxxxx" $pass = "xxxxxxx" $oIE = _IECreate ("https://xxxxxxxxx") $oIE2 = _IECreate ("http://xxxxxxxxxxxxx") _IELoadWait ($oIE) $uForm = _IEFormGetObjByName ($oIE, "login_form") $uText = _IEFormElementGetObjByName ($uForm, "email") _IEFormElementSetValue ($uText,$user) $pText = _IEFormElementGetObjByName ($uForm, "pass") _IEFormElementSetValue ($pText,$pass) _IEFormSubmit ($uForm) Sleep ( 1500) _IENavigate ($oIE2, "xxxxxxxxxxxxxx") ElseIf $nmsg = $Button2 Then #include <IE.au3> $user = "xxxxxxxx" $pass = "xxxxxxxxxxxxxx" $oIE = _IECreate ("https://") $oIE2 = _IECreate ("http://") _IELoadWait ($oIE) $uForm = _IEFormGetObjByName ($oIE, "login_form") $uText = _IEFormElementGetObjByName ($uForm, "email") _IEFormElementSetValue ($uText,$user) $pText = _IEFormElementGetObjByName ($uForm, "pass") _IEFormElementSetValue ($pText,$pass) _IEFormSubmit ($uForm) Sleep (1500) _IENavigate ($oIE2, "http://xxxxxxxxxxxxxxxxxx") EndIf WEnd thankyou for your time Edited July 17, 2010 by lostowl Link to comment Share on other sites More sharing options...
JohnOne Posted July 17, 2010 Share Posted July 17, 2010 I dont know if you can include a udf in an if condition, but nonetheless it certainly isnt a good idea to do so in a while loop. Also this is wrong "Or $nmsg = $Button2 Then" And one more thing, the button dosent work because the code is badly flawed and dosent even run. 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...
taietel Posted July 17, 2010 Share Posted July 17, 2010 lostowl, your code is wrong. You should try something like this: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> $Form2 = GUICreate("Form2", 616, 552, 202, 132) $Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 0, 24, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Login1() Case $Button2 _Login2() EndSwitch WEnd Func _Login1() ;put your code for button1 EndFunc Func _Login2() ;put your code for button2 EndFunc Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
lostowl Posted July 17, 2010 Author Share Posted July 17, 2010 (edited) lostowl, your code is wrong. You should try something like this: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> $Form2 = GUICreate("Form2", 616, 552, 202, 132) $Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 0, 24, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Login1() Case $Button2 _Login2() EndSwitch WEnd Func _Login1() ;put your code for button1 EndFunc Func _Login2() ;put your code for button2 EndFunc thanks works well now my only problem is how to set it so the red x in top right will close window and how to make it so once i press button 1 i can press it agian or press button 2 without having to reopen the gui Edited July 17, 2010 by lostowl Link to comment Share on other sites More sharing options...
taietel Posted July 17, 2010 Share Posted July 17, 2010 lostowl, have you read the help file? It's located under %programfiles%\Autoit. This is the first thing you should do before using AutoIt. ... now my only problem is how to set it so the red x in top right will close window and how to make it so once i press button 1 i can press it agian or press button 2 without having to reopen the gui The code below does what you've just said above. I don't see any problem! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 600, 500) $Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 0, 24, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Login1() Case $Button2 _Login2() EndSwitch WEnd Func _Login1() ;put your code for button1 MsgBox(0,"Congrats!","You've pressed button 1") EndFunc Func _Login2() ;put your code for button2 MsgBox(0,"Congrats!","You've pressed button 2") EndFunc Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
lostowl Posted July 17, 2010 Author Share Posted July 17, 2010 (edited) lostowl, have you read the help file? It's located under %programfiles%\Autoit. This is the first thing you should do before using AutoIt. The code below does what you've just said above. I don't see any problem! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 600, 500) $Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 0, 24, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Login1() Case $Button2 _Login2() EndSwitch WEnd Func _Login1() ;put your code for button1 MsgBox(0,"Congrats!","You've pressed button 1") EndFunc Func _Login2() ;put your code for button2 MsgBox(0,"Congrats!","You've pressed button 2") EndFunc yea it works bud i took out the MsgBox(0,"Congrats!","You've pressed button 2") line when i put in my code and it i cant click button 1 agian until message ok button is there anyway to take that option out so i dont need a popup? thank you for your time Edited July 17, 2010 by lostowl 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