aa2zz6 Posted January 12, 2016 Share Posted January 12, 2016 (edited) I created a simple GUI with an embedded browser, two input boxes and a button to initialize the program. When the user writes the email and password in the two input boxes and then presses the button it'll then translate that information to the Facebook login. But for some reason it's skipping over the email and putting both information inside the password.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <GDIPlus.au3> ;#Escape program HotKeySet("{ESC}", "Terminate") Local $iWidthCell = 70 ;#GUI Create $width = 800 ;#GUI Create $height = 625 ;#GUI Create Global $x ;#Func Email Global $y ;#Func Password _IEErrorHandlerRegister() #Region ### START Koda GUI section ### Form= $hMain = GUICreate("COK", 1015, 585, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $wPos = WinGetPos($hMain) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;#Input Email GUICtrlCreateLabel("Email:", 880, 65, $iWidthCell) $hInput1 = GUICtrlCreateInput("", 880, 90, 85, 20) ;#Input Password GUICtrlCreateLabel("Password:", 880, 115, $iWidthCell) $hInput2 = GUICtrlCreateInput("", 880, 140, 85, 20) ;#Initializes the IE Explore Local $RunProgram = GUICtrlCreateButton("Run Program", 880, 170, 85, 25) ;#IE Create Func internet() Local $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 0, 0, $width + 0, $height + 0) _IENavigate($oIE, "https://www.facebook.com/?_rdr=p") Local $username = _IEGetObjByName($oIE, "email") Local $password = _IEGetObjByName($oIE, "pass") Local $button = _IEGetObjByName($oIE, "u_0_x") _IEFormElementSetValue($username, $x) _IEFormElementSetValue($password, $y) ;$oBtn = _IEGetObjById($oIE, "u_0_x") ; works on the main login page ;$oBtn = _IEGetObjById($oIE, "u_0_2") ; works on the second login page ; _IEAction($oBtn, "click") EndFunc ;==>internet While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $RunProgram internet() sleep(500) Email(GUICtrlRead($hInput1)) sleep(500) Password(GUICtrlRead($hInput2)) EndSwitch WEnd Func Email($x) Send($x) EndFunc ;==>Email Func Password($y) Send($y) EndFunc ;==>Password Func Terminate() Exit EndFunc ;==>Terminate Edited January 12, 2016 by aa2zz6 Link to comment Share on other sites More sharing options...
jdelaney Posted January 12, 2016 Share Posted January 12, 2016 (edited) Don't use send...use ControlGetText, and read in the value of the GuiCtrlRead into $x and $y...but BEFORE you call the internet function.Stick with the _IEFormElementSetValue to actually set the input data...send is unreliable. If you are properly getting the inputs from the website, then this will work:While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $RunProgram $x = GUICtrlRead($hInput1) $y = GUICtrlRead($hInput2) internet() EndSwitch WEndYours is sending the text from BOTH inputs into whatever element is in focus, on what ever window is active. Edited January 12, 2016 by jdelaney aa2zz6 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
aa2zz6 Posted January 12, 2016 Author Share Posted January 12, 2016 (edited) Thank you, jdelaney. I will re post the the working code below.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <GDIPlus.au3> ;#Escape program HotKeySet("{ESC}", "Terminate") Local $iWidthCell = 70 ;#GUI Create $width = 800 ;#GUI Create $height = 625 ;#GUI Create Global $x ;#Func Email Global $y ;#Func Password _IEErrorHandlerRegister() #Region ### START Koda GUI section ### Form= $hMain = GUICreate("Test", 1015, 585, @DesktopWidth / 2 - $width / 2, @DesktopHeight / 2 - $height / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $wPos = WinGetPos($hMain) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;#Input Email GUICtrlCreateLabel("Email:", 880, 65, $iWidthCell) $hInput1 = GUICtrlCreateInput("", 880, 90, 85, 20) ;#Input Password GUICtrlCreateLabel("Password:", 880, 115, $iWidthCell) $hInput2 = GUICtrlCreateInput("", 880, 140, 85, 20) ;#Initializes the IE Explore Local $RunProgram = GUICtrlCreateButton("Run Program", 880, 170, 85, 25) ;#IE Create Func internet() Local $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 0, 0, $width + 0, $height + 0) _IENavigate($oIE, "https://www.facebook.com/?_rdr=p") Local $username = _IEGetObjByName($oIE, "email") Local $password = _IEGetObjByName($oIE, "pass") Local $button = _IEGetObjByName($oIE, "u_0_x") _IEFormElementSetValue($username, $x) _IEFormElementSetValue($password, $y) ;$oBtn = _IEGetObjById($oIE, "u_0_x") ; works on the main login page ;$oBtn = _IEGetObjById($oIE, "u_0_2") ; works on the second login page ; _IEAction($oBtn, "click") EndFunc ;==>internet While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $RunProgram $x = GUICtrlRead($hInput1) $y = GUICtrlRead($hInput2) internet() EndSwitch WEnd Func Email($x) $x = ControlGetText(WinGetTitle("[AutoIt v3 GUI]"), "", "[CLASS:Edit; INSTANCE:1]") EndFunc ;==>Email Func Password($y) $y = ControlGetText(WinGetTitle("[AutoIt v3 GUI]"), "", "[CLASS:Edit; INSTANCE:2]") EndFunc ;==>Password Func Terminate() Exit EndFunc ;==>Terminate Edited January 12, 2016 by aa2zz6 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