Testy Posted February 28, 2008 Share Posted February 28, 2008 (edited) Ok, I'll show my work, ; TAB GuiCtrlCreateTab(5, 35, 355, 115) GuiCtrlCreateTabItem("1") GuiCtrlCreateLabel("Region 1", 10, 10) ;R1 $Button1r1 = GUICtrlCreateButton("Site 1", 15, 65, 40, 20) $Button2r1 = GUICtrlCreateButton("Site 2", 57, 65, 40, 20) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1") WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") Case $Button2r1 Run("C:\folder\application.exe appServer=127.0.0.2") WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") Ok, I know how to do this via Autoit v2, but how do I make a 'bank' of data that can be called upon so that I don't have to keep generating lines and lines of repeated information? I'd rather take the login info and make the 4-5 lines 'just' 4 or 5 lines. Thank you kindly for any assistance. Edited February 28, 2008 by Testy Link to comment Share on other sites More sharing options...
Kerros Posted February 28, 2008 Share Posted February 28, 2008 how about a function func signon() WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndFunc Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
GEOSoft Posted February 28, 2008 Share Posted February 28, 2008 (edited) Do you mean like so Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1, $Button2r1 Run("C:\folder\application.exe appServer=127.0.0.1") WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndSwitch If you have more than 2 buttons and you created them consecutively then you can also use Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 To $Button5r1 Run("C:\folder\application.exe appServer=127.0.0.1") WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndSwitch In this scenario you have 5 buttons created as follows $Button1r1 = GUICtrlCreateButton(.................... $Button2r1 = GUICtrlCreateButton(.................... $Button3r1 = GUICtrlCreateButton(.................... $Button4r1 = GUICtrlCreateButton(.................... $Button5r1 = GUICtrlCreateButton(.................... Edit: Spelling Edited February 28, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Testy Posted February 28, 2008 Author Share Posted February 28, 2008 how about a function func signon() WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndFunc So: $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1") $signon func signon() WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndFunc Will call to the login info? Link to comment Share on other sites More sharing options...
GEOSoft Posted February 28, 2008 Share Posted February 28, 2008 So: $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1") $signon func signon() WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndFunc Will call to the login info?No Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1") signon()will. BTW you can also use the code I gave to do the same from multiple controls like so. Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1, $Button2r1 Run("C:\folder\application.exe appServer=127.0.0.1") signon() EndSwitch Func signon() WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndFunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Testy Posted February 28, 2008 Author Share Posted February 28, 2008 how about a function func signon() WinWaitActive("Sign On") Send("User{TAB}") Send("Password{ENTER}") EndFunc Thank you, worked like a charm. You saved me hundreds of lines. I will get this, just a matter of time. GuiCtrlCreateTab(5, 35, 355, 115) GuiCtrlCreateTabItem("1") GuiCtrlCreateLabel("Region 1", 10, 10) $Button1r1 = GUICtrlCreateButton("SLANC", 15, 65, 40, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1 appServerPort=36008 app=app schema=UserSchema") Call("test1") Func Test1() WinWaitActive("Sign On") Send("oooo{TAB}") Send("oooo{ENTER}") EndFunc EndSwitch WEnd Link to comment Share on other sites More sharing options...
weaponx Posted February 28, 2008 Share Posted February 28, 2008 Don't define functions inside loops. Link to comment Share on other sites More sharing options...
Testy Posted February 28, 2008 Author Share Posted February 28, 2008 Don't define functions inside loops.How do you mean? I am 'very' new to v3. Link to comment Share on other sites More sharing options...
weaponx Posted February 28, 2008 Share Posted February 28, 2008 How do you mean? I am 'very' new to v3.Do you know what a loop is?Do you know what a function is?If you know both of these things you will see you have:While 1....Func Test1() WinWaitActive("Sign On") Send("oooo{TAB}") Send("oooo{ENTER}")EndFunc....WEndThe Func / EndFunc should be at the very beginning or end of your script and not nested inside anything else, this is improper. Link to comment Share on other sites More sharing options...
GEOSoft Posted February 28, 2008 Share Posted February 28, 2008 What weaponx is refering to is this While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1 appServerPort=36008 app=app schema=UserSchema") Call("test1") Func Test1() WinWaitActive("Sign On") Send("oooo{TAB}") Send("oooo{ENTER}") EndFunc EndSwitch WEnd Should be While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1r1 Run("C:\folder\application.exe appServer=127.0.0.1 appServerPort=36008 app=app schema=UserSchema") Call("test1") EndSwitch WEnd Func Test1() WinWaitActive("Sign On") Send("oooo{TAB}") Send("oooo{ENTER}") EndFunc Also Call() is a bad habit Change Call("test1") to test1() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Testy Posted February 29, 2008 Author Share Posted February 29, 2008 Weapons x , Geosoft, Worked well thank you. 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