markky Posted July 29, 2013 Share Posted July 29, 2013 Hello all, I am a first time coder, started about a week ago I have put together a little script from resources around here. I need help with a simple desktop script which will make my life a little easier. I have a few blogs and I need to be able to login to them in a couple clicks. The code i'm using doesn't work. I would at some point like to make the URL input a dropdown but for now this is what I have..pheeew expandcollapse popup; TEMPLATE ; ; My Wordpress Blog Control ;=========================================================================== #include-once ;=========================================================================== ;Constants ;=========================================================================== ;=========================================================================== ;Include Files ;=========================================================================== #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiButton.au3> #include<EditConstants.au3> #include <IE.au3> ;=========================================================================== ;Global variables ;=========================================================================== Global $file, $Button2, $msg ;=========================================================================== ;Functions ;=========================================================================== $oIE = _IECreate("") ;==>How can I get this value from the URL input box Func Submit($InputID) $oForm = _IEFormGetObjByName($oIE, "loginform") $ologin = _IEFormElementGetObjByName($oForm, "log") $password = _IEFormElementGetObjByName($oForm, "pwd") _IEFormElementSetValue($ologin, GUICtrlRead($InputID)) _IEFormElementSetValue($password, GUICtrlRead($InputID + 1)) _IEFormSubmit($oForm) EndFunc ;==>Submit ;=========================================================================== ;Main entry ;=========================================================================== ;Create all GUI windows and controls GUICreate("Wordpress Blogs", 497, 183, 276, 147) GUICtrlCreateLabel("URL:", 68, 24, 64, 20) GUICtrlCreateLabel("UserName:", 40, 54, 67, 28) GUICtrlCreateLabel("Password:", 45, 86, 64, 20) Global $Input = GUICtrlCreateInput("", 96, 48, 345, 24) GUICtrlCreateInput("", 96, 80, 345, 24, $ES_PASSWORD) $file = GUICtrlCreateInput("", 96, 18, 345, 24) ;==>URL Input Global $Button1 = GUICtrlCreateButton("Login", 96, 128, 121, 25) Global $Button2 = GUICtrlCreateButton("Connect", 222, 128, 121, 25) ;==>Button to connect to URL GUISetState(@SW_SHOW) $msg = 1 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $Button2 _IENavigate($oIE, GUICtrlRead($file)) ExitLoop EndSelect WEnd Login() ;Windows message pump Func Login() While True $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit Case $Button1 For $i = $Input To $Input + 2 If GUICtrlRead($i) = '' Then GUICtrlSetState($i, 256) ContinueLoop 2 ;256 = GUI_FOCUS EndIf Next Submit($Input) EndSwitch WEnd EndFunc ;==>Login ;Cleanup Link to comment Share on other sites More sharing options...
MarkRobbins Posted July 30, 2013 Share Posted July 30, 2013 Hmmm, Like this? expandcollapse popup; TEMPLATE ; ; My Wordpress Blog Control ;=========================================================================== #include-once ;=========================================================================== ;Constants ;=========================================================================== ;=========================================================================== ;Include Files ;=========================================================================== #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiButton.au3> #include<EditConstants.au3> #include <IE.au3> ;=========================================================================== ;Global variables ;=========================================================================== Global $file, $Button2, $msg ;;NEW NEW NEW Global $oIE ;=========================================================================== ;Functions ;=========================================================================== ;;OLD OLD OLD ;$oIE = _IECreate("") ;==>How can I get this value from the URL input box Func Submit($InputID) $oForm = _IEFormGetObjByName($oIE, "loginform") $ologin = _IEFormElementGetObjByName($oForm, "log") $password = _IEFormElementGetObjByName($oForm, "pwd") _IEFormElementSetValue($ologin, GUICtrlRead($InputID)) _IEFormElementSetValue($password, GUICtrlRead($InputID + 1)) _IEFormSubmit($oForm) EndFunc ;==>Submit ;=========================================================================== ;Main entry ;=========================================================================== ;Create all GUI windows and controls GUICreate("Wordpress Blogs", 497, 183, 276, 147) GUICtrlCreateLabel("URL:", 68, 24, 64, 20) GUICtrlCreateLabel("UserName:", 40, 54, 67, 28) GUICtrlCreateLabel("Password:", 45, 86, 64, 20) Global $Input = GUICtrlCreateInput("", 96, 48, 345, 24) GUICtrlCreateInput("", 96, 80, 345, 24, $ES_PASSWORD) $file = GUICtrlCreateInput("", 96, 18, 345, 24) ;==>URL Input Global $Button1 = GUICtrlCreateButton("Login", 96, 128, 121, 25) Global $Button2 = GUICtrlCreateButton("Connect", 222, 128, 121, 25) ;==>Button to connect to URL GUISetState(@SW_SHOW) $msg = 1 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $Button2 ;; NEW NEW NEW If Not IsObj($oIE) Then $oIE = _IECreate(GUICtrlRead($file)) Else _IENavigate($oIE, GUICtrlRead($file)) EndIf ;;;;;;;;;;;;;;;;; ;; OLD OLD OLD ;_IENavigate($oIE, GUICtrlRead($file)) ExitLoop EndSelect WEnd Login() ;Windows message pump Func Login() While True $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit Case $Button1 For $i = $Input To $Input + 2 If GUICtrlRead($i) = '' Then GUICtrlSetState($i, 256) ContinueLoop 2 ;256 = GUI_FOCUS EndIf Next Submit($Input) EndSwitch WEnd EndFunc ;==>Login ;Cleanup Link to comment Share on other sites More sharing options...
markky Posted July 30, 2013 Author Share Posted July 30, 2013 Thanks Mark, That helped me alot. It sent me in a little different direction than I was going which solved my problem...this actually works, on my computer..lol expandcollapse popup; TEMPLATE ; ; My Wordpress Blog Control ;=========================================================================== ;Autoit Debug ;=========================================================================== Opt("TrayIconDebug", 1) ;=========================================================================== #include-once ;=========================================================================== ;Constants ;=========================================================================== ;=========================================================================== ;Include Files ;=========================================================================== #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiButton.au3> #include<EditConstants.au3> #include <IE.au3> ;=========================================================================== ;Global variables ;=========================================================================== Global $file, $Button1, $Button2, $msg ;=========================================================================== ;Functions ;=========================================================================== $oIE = _IECreate ("", 0, 1) ;==>Create an Internet Explorer Browser Window Func Submit($InputID) ;==>Wordpress wp-login values $oForm = _IEFormGetObjByName($oIE, "loginform") $ologin = _IEFormElementGetObjByName($oForm, "log") $password = _IEFormElementGetObjByName($oForm, "pwd") _IEFormElementSetValue($ologin, GUICtrlRead($InputID)) _IEFormElementSetValue($password, GUICtrlRead($InputID + 1)) _IEFormSubmit($oForm) EndFunc ;==>Submit ;=========================================================================== ;Main entry ;=========================================================================== ;Create all GUI windows and controls GUICreate("Wordpress Blogs", 497, 183, 276, 147) GUICtrlCreateLabel("URL:", 68, 24, 64, 20) GUICtrlCreateLabel("UserName:", 40, 54, 67, 28) GUICtrlCreateLabel("Password:", 45, 86, 64, 20) Global $Input = GUICtrlCreateInput("", 96, 48, 345, 24) GUICtrlCreateInput("", 96, 80, 345, 24, $ES_PASSWORD) ;$file = GUICtrlCreateInput("", 96, 18, 345, 24) ;==>Single text box URL input $file = GUICtrlCreateCombo("", 96, 18, 345, 24) ;==>Combobox URL input GUICtrlSetData(-1, "http://www.autoitscript.com/forum|http://www.google.com|http://www.yahoo.com|http://www.msn.com", "http://www.google.com") ; Combo box add other item snd set a new default Global $Button1 = GUICtrlCreateButton("Login", 96, 128, 121, 25) ;==>Button to Login Global $Button2 = GUICtrlCreateButton("Connect", 222, 128, 121, 25) ;==>Button to connect to URL GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $Button1 For $i = $Input To $Input + 2 If GUICtrlRead($i) = '' Then GUICtrlSetState($i, 256) EndIf Next Submit($Input) Case $Button2 _IENavigate ( $oIE, GUICtrlRead($file)) EndSwitch WEnd 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