NELyon Posted June 28, 2006 Share Posted June 28, 2006 (edited) Ok, i tried to make a GUI for goflago's gaia forum poster. However, i am getting an error, Variable used without being declared. Anyone know whats wrong? expandcollapse popup#include <IE.au3> #include <GUIConstants.au3> $Username = GUICtrlRead($Euser) $Password = GUICtrlRead($Epass) $Message = GUICtrlRead($Emsg) $TopicNumber = "13179136" $PostNumber = "" $sid = "" $sid2 = "" Dim $Thread[4] = ["http://gaiaonline.com/forum/viewtopic.php?t=" & $TopicNumber,"http://www.gaiaonline.com/forum/posting.php?mode=edit&p=" & $PostNumber,"http://www.gaiaonline.com/forum/posting.php?mode=reply&tc=1&t=" & $TopicNumber,"http://www.gaiaonline.com/forum/posting.php?mode=reply&tc=561&t=" & $TopicNumber] $Forum = "http://gaiaonline.com/forum/viewforum.php?f=23" $Main = "http://gaiaonline.com" $Exit = 1 ;Hotkeys HotKeySet("^s", "Begin") HotKeySet("^e", "Stop") GUICreate("Gaia forum poster", 357, 419, 192, 125) $Euser = GUICtrlCreateInput("Username", 64, 96, 233, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Gaia Forum Poster. Uses the poster made by", 80, 40, 214, 17) GUICtrlCreateLabel("GoFlago", 152, 56, 44, 17) $Epass = GUICtrlCreateInput("Password", 64, 152, 233, 21, -1, $WS_EX_CLIENTEDGE) $Emsg = GUICtrlCreateEdit("", 48, 224, 257, 169, -1, $WS_EX_CLIENTEDGE) GUICtrlSetData($Edit1, "Message") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit While $Exit = 1 Sleep(100) WEnd Func Begin() If $Exit = 1 Then $Exit = 0 Global $IE = _IECreate("") Call("Prog") EndIf EndFunc Func Stop() $Exit = 1 Endfunc Func Prog() Call("Login") Call("Post") EndFunc Func Login() _IENavigate($IE,"http://www.gaiaonline.com/gaia/login.php?") $Login = _IEFormGetObjByName($IE,"loginForm") $User = _IEFormElementGetObjByName($Login,"username") $Pass = _IEFormElementGetObjByName($Login,"password") _IEFormElementSetValue($User,$Username) _IEFormElementSetValue($Pass,$Password) _IEFormSubmit($Login) $sid2 = _IEPropertyGet($IE,"locationurl") $sid = "&" & StringMid($sid2,37, 9999) EndFunc Func Logout() _IENavigate($IE,$Main) _IELinkClickByText($IE,"Logout") EndFunc Func Post() While $Exit = 0 _IENavigate($IE,$Thread[2] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess,$Message) _IEFormImageClick ($Post,"Submit","alt") Sleep(30000) _IENavigate($IE,$Thread[3] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess,$Message) _IEFormImageClick ($Post,"Submit","alt") Sleep(30000) WEnd EndFunc Func start() Begin() EndFunc Edited June 28, 2006 by codemyster Link to comment Share on other sites More sharing options...
Paulie Posted June 28, 2006 Share Posted June 28, 2006 for simplicity purposes, what variable is use w/o being declared, and if it doesn't tell you, have you run it through SciTE4Autoit3? Link to comment Share on other sites More sharing options...
NELyon Posted June 28, 2006 Author Share Posted June 28, 2006 yeah, scite is giving me the error. it is the $Euser variable. and i am guessing the Epass and Emsg because they are set up the same Link to comment Share on other sites More sharing options...
Paulie Posted June 28, 2006 Share Posted June 28, 2006 yeah, scite is giving me the error. it is the $Euser variable. and i am guessing the Epass and Emsg because they are set up the sameWell for all those variables, just put Global $Euser For each at the top of code Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 28, 2006 Share Posted June 28, 2006 Ok, i tried to make a GUI for goflago's gaia forum poster. However, i am getting an error, Variable used without being declared. Anyone know whats wrong? CODE #include <IE.au3> #include <GUIConstants.au3> $Username = GUICtrlRead($Euser) $Password = GUICtrlRead($Epass) $Message = GUICtrlRead($Emsg) $TopicNumber = "13179136" $PostNumber = "" $sid = "" $sid2 = "" Dim $Thread[4] = ["http://gaiaonline.com/forum/viewtopic.php?t=" & $TopicNumber,"http://www.gaiaonline.com/forum/posting.php?mode=edit&p=" & $PostNumber,"http://www.gaiaonline.com/forum/posting.php?mode=reply&tc=1&t=" & $TopicNumber,"http://www.gaiaonline.com/forum/posting.php?mode=reply&tc=561&t=" & $TopicNumber] $Forum = "http://gaiaonline.com/forum/viewforum.php?f=23" $Main = "http://gaiaonline.com" $Exit = 1 ;Hotkeys HotKeySet("^s", "Begin") HotKeySet("^e", "Stop") GUICreate("Gaia forum poster", 357, 419, 192, 125) $Euser = GUICtrlCreateInput("Username", 64, 96, 233, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Gaia Forum Poster. Uses the poster made by", 80, 40, 214, 17) GUICtrlCreateLabel("GoFlago", 152, 56, 44, 17) $Epass = GUICtrlCreateInput("Password", 64, 152, 233, 21, -1, $WS_EX_CLIENTEDGE) $Emsg = GUICtrlCreateEdit("", 48, 224, 257, 169, -1, $WS_EX_CLIENTEDGE) GUICtrlSetData($Edit1, "Message") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit While $Exit = 1 Sleep(100) WEnd Func Begin() If $Exit = 1 Then $Exit = 0 Global $IE = _IECreate("") Call("Prog") EndIf EndFunc Func Stop() $Exit = 1 Endfunc Func Prog() Call("Login") Call("Post") EndFunc Func Login() _IENavigate($IE,"http://www.gaiaonline.com/gaia/login.php?") $Login = _IEFormGetObjByName($IE,"loginForm") $User = _IEFormElementGetObjByName($Login,"username") $Pass = _IEFormElementGetObjByName($Login,"password") _IEFormElementSetValue($User,$Username) _IEFormElementSetValue($Pass,$Password) _IEFormSubmit($Login) $sid2 = _IEPropertyGet($IE,"locationurl") $sid = "&" & StringMid($sid2,37, 9999) EndFunc Func Logout() _IENavigate($IE,$Main) _IELinkClickByText($IE,"Logout") EndFunc Func Post() While $Exit = 0 _IENavigate($IE,$Thread[2] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess,$Message) _IEFormImageClick ($Post,"Submit","alt") Sleep(30000) _IENavigate($IE,$Thread[3] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess,$Message) _IEFormImageClick ($Post,"Submit","alt") Sleep(30000) WEnd EndFunc Func start() Begin() EndFunc Right at the start of your script: #include <IE.au3> #include <GUIConstants.au3> $Username = GUICtrlRead($Euser) $Password = GUICtrlRead($Epass) $Message = GUICtrlRead($Emsg) What are $Euser, $Epass, and $Emsg supposed to have been set by? Just declaring them with Global won't help because they have to be set to the valid control IDs you are trying to read with GuiCtrlRead(). Let's say you move them into your GUI message loop like this: While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else $Username = GUICtrlRead($Euser) $Password = GUICtrlRead($Epass) $Message = GUICtrlRead($Emsg) ;;;;;;; EndSelect WEnd Now those variables are constantly updated from the GUI, and when the GUI is closed you will exit the message loop and have your data in the variables. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
NELyon Posted June 28, 2006 Author Share Posted June 28, 2006 (edited) Thanks, i got it to work!EDIT: no, now i am just returning like 5 errorsIt's working, but i can't close the GUI while it's doing the scriptEDIT: i just made a GUISetState(@SW_HIDE, $Forum_1) when i click the start button Edited June 28, 2006 by codemyster 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