MarioTester Posted January 29, 2012 Share Posted January 29, 2012 So, Hey!I already posted here explaining as AutoIt is my first language and seriously, I love it! I'm doing scripts for all kind of things, its really great. Well, anyways, in this particular script I'm doing, while it works very well, I would like to add a feature that I have no idea on how to do, I have already been through help file without any luck, well, let me explain.My basic Idea is, the whole script works perfectly, he needs only two variables to work, these variables are unique to eachother and change at every run. The variable 1 is a link, the variable 2 is the message that is supposed to be written in said link.I.e:First run: Go to www.google.com, write "potato", searchSecond run: Go to www.bing.com, write "power ranger", searchOk so, this is the basic idea, what I want to do though is, through a GUI, be able to add both variables, so that would be kind of writting something in the Gui, clicking "Add" and editing the source code forever, with those new two variables. That's what I dont even know how to begin doing. Anyways, let me show you the script:expandcollapse popupHotKeySet( "{END}", "Terminate") Global $OpenAddress Global $Answer Global $Count = 0; Global $Total = 17; While $Count < $total Site() Tooltip( $Count&"/"&$Total,0,0,"Actual / Total") WEnd While $Count = $Total Tooltip( "Done a total of "&$total,0,0,"Im finished.") sleep(100) WEnd Func SetVariables();The threads and answers Select Case $Count = 0 $OpenAddress ="http://censored.com" $Answer = "Anyword." Case $Count = 1 $OpenAddress = "http://censored1.com" $Answer = "Otherword." Case $Count = 2 $OpenAddress = "http://censored3.com" $Answer = "Anotherword" Case Else MsgBox(0, "Ops", "That isn't supposed to happen, dude") EndSelect EndFunc Func Site() ShellExecute("opera.exe", "", "C:\Program Files\Opera\", "open"); When I do this, browser opens a new tab WinWaitActive("Speed Dial - Opera") SetVariables() Send($OpenAddress & "{enter}") Sleep(500) Do $loaded = Pixelsearch(1036, 247, 1038, 249, 0x0B2943, 10);way to check page loaded Sleep(200) Until IsArray($loaded) = 1 MouseClick("left", 1059, 247, 1) Do $loaded2= PixelSearch(155, 337, 157, 339, 0xFFE622, 10);Checks if second page loaded sleep(200) Until IsArray($loaded2) = 1 send("{Tab}") sleep(50) Send($Answer&"{tab}"&"{enter}") $Count = $Count + 1 sleep(50) return "done" EndFunc Func Terminate() ;This is a function and doesn't actually run unless you tell it to. For example Exit EndFunc ;==>TerminateSo anyways, This is the basic idea, the actual "setvariables()" include 18 "$openaddress" and "$Answer", going to case 0 until case 18, but It would be pointless to post all of then, since 3 are enough to give the idea. Right now, when I want to add variables, I manually go there and add cases in source code. I know there's no GUI whatsoever in this script, It's because creating the GUI would be pointless without knowing how to make the whole "add new variables" part.Also, I believe that I should use "Switch" instead of "Select". I'm going to do that.Thanks in advance! TL;DR I'm new to autoit or any programming language whatsoever. Link to comment Share on other sites More sharing options...
Beege Posted January 29, 2012 Share Posted January 29, 2012 MarioTester, As I don't have opera I can't really test this, but this might work. expandcollapse popupHotKeySet("{END}", "Terminate") Global $OpenAddress Global $Answer Global $Count = 0; Global $Total = 17; HotKeySet("^!n", "Add_New");ctrl+shift+n While 1 If $Count < $Total Then Site() ToolTip($Count & "/" & $Total, 0, 0, "Actual / Total") Else ToolTip("Done a total of " & $Total, 0, 0, "Im finished.") Sleep(100) EndIf WEnd Func Add_New() $OpenAddress = InputBox('New Link', 'Add New Link') $Answer = InputBox('New Answer', 'Add New Answer') $Total += 1 EndFunc Func SetVariables();The threads and answers Select Case $Count = 0 $OpenAddress = "http://censored.com" $Answer = "Anyword." Case $Count = 1 $OpenAddress = "http://censored1.com" $Answer = "Otherword." Case $Count = 2 $OpenAddress = "http://censored3.com" $Answer = "Anotherword" Case Else MsgBox(0, "Ops", "That isn't supposed to happen, dude") EndSelect EndFunc ;==>SetVariables Func Site() ShellExecute("opera.exe", "", "C:\Program Files\Opera\", "open"); When I do this, browser opens a new tab WinWaitActive("Speed Dial - Opera") SetVariables() Send($OpenAddress & "{enter}") Sleep(500) Do $loaded = PixelSearch(1036, 247, 1038, 249, 0x0B2943, 10);way to check page loaded Sleep(200) Until IsArray($loaded) = 1 MouseClick("left", 1059, 247, 1) Do $loaded2 = PixelSearch(155, 337, 157, 339, 0xFFE622, 10);Checks if second page loaded Sleep(200) Until IsArray($loaded2) = 1 Send("{Tab}") Sleep(50) Send($Answer & "{tab}" & "{enter}") $Count = $Count + 1 Sleep(50) Return "done" EndFunc ;==>Site Func Terminate() ;This is a function and doesn't actually run unless you tell it to. For example Exit EndFunc ;==>Terminate Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
MarioTester Posted January 29, 2012 Author Share Posted January 29, 2012 First of all, thanks for quick answer Beegee =) Im not sure I got your suggestion wrong, but I fail to understand how this would solve the problem. Maybe I'm missing something, but you see, the point is, I want to somehow assign two new values to two variables for a certain case +=1, however, these new two values I add should be able to be there forever, whenever I executed the script again they would already be there, instead of me having to input them every time. TL;DR I'm new to autoit or any programming language whatsoever. Link to comment Share on other sites More sharing options...
Beege Posted January 29, 2012 Share Posted January 29, 2012 Oh I see, my mistake. Well you can't modify the source of your code while its running, but what you could do is create a simple .ini file that has all your links and answers in it. Then when your script starts read in all the links from that file. When you have new one write it to the file. This way it would be saved permanently. Look at functions IniRead, IniWrite etc. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
MarioTester Posted January 29, 2012 Author Share Posted January 29, 2012 I can write INIS!? THAT'S GREAT!!! That's definitely going to solve my problem thanks a lot Beege o/ TL;DR I'm new to autoit or any programming language whatsoever. Link to comment Share on other sites More sharing options...
Beege Posted January 29, 2012 Share Posted January 29, 2012 Your very welcome Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator 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