baraider Posted April 25, 2008 Posted April 25, 2008 I'm looking for help to create a simple pseudo script that will do 2 things, A, B. If you run it the first time, it will do A first and then B. If you run it again, it will do B first and then A. The third run will be the same order as the first run and so on. Maybe using a counter, a loop or something. First run do A do B the same script the next run will do do B do A
flip209 Posted April 25, 2008 Posted April 25, 2008 Are you talking running a script and the loop repeating or running script closing and running again? " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
C2C Posted April 25, 2008 Posted April 25, 2008 If i got it correctly he wants to run the script and get A command first and then B and if you run the script again the other way around. I can see this happening but the script has to make a ini a txt or something like that in lets say temp folder just so it knows which run is it ----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win
Swift Posted April 25, 2008 Posted April 25, 2008 Like this? Untested. Global $Count=1 If ProcessExists(@Scriptname) Then $Count=2 Switch $Count Case 1 ;first time ran. Case 2 ;second time ran. EndSwitch
flip209 Posted April 25, 2008 Posted April 25, 2008 I was thinking a regkey and use a if x key = 0 then a then b set x key 1 or if x key = 1 then b then a set x key 0... " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
baraider Posted April 25, 2008 Author Posted April 25, 2008 C2C got what I want to do correctly. I was thinking of something along the line of using mod function, increase a variable. $n= 0 If mod($n, 2) = 0 Then Do A Do B Else Do B Do A EndIf $n = $n + 1 The problem is that $n starts out = 0 all the time.
Valuater Posted April 25, 2008 Posted April 25, 2008 Maybe... expandcollapse popup; Press Esc to terminate script, Pause/Break to "pause" Global $Paused, $Runner, $Reverse = True, $How_long_to_Wait = 3000 ; 3000 = 3 seconds HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{F9}", "ShowMe") ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Func ShowMe() $Runner = Not $Runner While $Runner If $Reverse = True Then ; Do "A" then "B" MsgBox(0x0, "A", "Doing *A* Then *B* ", 2) Else ; Do "B" then "A" MsgBox(0x0, "B", "Doing *B* Then *A* ", 2) EndIf $Reverse = Not $Reverse Sleep($How_long_to_Wait) WEnd EndFunc ;==>ShowMe 8)
baraider Posted April 25, 2008 Author Posted April 25, 2008 Thank you guys. This is the only post I have anyone trying to help so I will tell you why I added several unrelated questions to solve my original problem.Here is my original script. What it does is to enable/disable monitor 2,3 when I run this.What I really want is when I run it the first time, it will disable monitor 3 first, then 2.When I run it again, it will enable monitor 2 first, then 3.Sorry for the convoluted question and hope the experts here can help. Thanksexpandcollapse popup;The starting setup is as follow ;Monitor 1 is primary monitor with the display order 1->2->3 ;We will enable/disable 2,3 and make 1 primary ; exec cpanel app `display settings Run("C:\WINDOWS\system32\control.exe desk.cpl,@0,3") ; wait for window to be active WinWaitActive("Display Properties") ; select 3rd display Send("{3}") ; work back to the extend desktop controls Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") ; toggle extend desktop control and apply Send("{SPACE}") ;select 2nd display ;Send("{2}") ; work back to the extend desktop controls Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") Send("+{TAB}") ; toggle extend desktop control and apply Send("{SPACE}") Send("{ENTER}")
C2C Posted April 25, 2008 Posted April 25, 2008 Writes to file in temp $file = FileExists (@TempDir & "\run.ini") if $file = 0 then IniWrite(@TempDir & "\run.ini", "section", "runs", "0") Else $var = IniRead(@TempDir & "\run.ini", "section", "runs") if $var = 0 Then ; YOUR A HERE ; YOUR B HERE IniWrite(@TempDir & "\run.ini", "section", "runs", "1") Else ; YOUR B HERE ; YOUR A HERE IniWrite(@TempDir & "\run.ini", "section", "runs", "0") EndIf EndIf ----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win
baraider Posted April 25, 2008 Author Posted April 25, 2008 C2C, Thanks for the suggestion. There is an error on this line $var = IniRead(@TempDir & "\run.ini", "section", "runs") Incorrect number of parameters in function call.
flip209 Posted April 25, 2008 Posted April 25, 2008 IniRead ( "filename", "section", "key", "default" ) " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
baraider Posted April 25, 2008 Author Posted April 25, 2008 Awesome guy. Got it to work. Exactly what I need. Thanks to C2C, flip209 and everyone else. You guys rock
C2C Posted April 25, 2008 Posted April 25, 2008 Crud i forgot the default value baaah ill have to use help files next time thanks for helping out flip. @baraider cheers m8 ----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win
flip209 Posted April 25, 2008 Posted April 25, 2008 C2C, You did all the work I just looked it up in the help file " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
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