Fly By Night Posted May 2, 2006 Share Posted May 2, 2006 Hi I had the following in a For .. Next loop before but had to revert to this long method due to it sending wrong keypresses. Here is the code, expandcollapse popupFunc SBAuto() $i = 1; Sleep(4500) Send("{NUMPAD0}") Sleep($annDelay) If $yourpos <> 1 Then Send("{NUMPAD1}") Sleep(500) Send("{NUMPAD1}") Sleep(4500) EndIf If $yourpos <> 2 Then Send("{NUMPAD2}") Sleep(500) Send("{NUMPAD2}") Sleep(4500) EndIf If $yourpos <> 3 Then Send("{NUMPAD3}") Sleep(500) Send("{NUMPAD3}") Sleep(4500) EndIf If $yourpos <> 4 Then Send("{NUMPAD4}") Sleep(500) Send("{NUMPAD4}") Sleep(4500) EndIf If $yourpos <> 5 Then Send("{NUMPAD5}") Sleep(500) Send("{NUMPAD5}") Sleep(4500) EndIf If $yourpos <> 6 Then Send("{NUMPAD6}") Sleep(500) Send("{NUMPAD6}") Sleep(4500) EndIf If $yourpos <> 7 Then Send("{NUMPAD7}") Sleep(500) Send("{NUMPAD7}") Sleep(4500) EndIf If $yourpos <> 8 Then Send("{NUMPAD8}") Sleep(500) Send("{NUMPAD8}") EndIf Sleep(80000) EndFunc ;==>SBAuto Before I was using something like this which might be slighty out as wiped what i had Func SBAuto2() Sleep(4500) Send("{NUMPAD0}") Sleep($annDelay) For $i = 1 to 8 Step 1 $temp = """{NUMPAD" & $i & "}""" If $yourpos <> $1 Then Send($temp) Sleep(500) Send($temp) Sleep(4500) EndIf Next Sleep(80000) EndFunc It was making up the NUMPAD1 to 8 alright as I had a label up changing as it went up the loop. For some reason though it kept sending weird things to program and it didn't run as intended. Seemed to keep sending NUMPAD2 a lot. Can anyone see what might have gone wrong in the loop and why I had to go back to the "Long" version? Thanks Link to comment Share on other sites More sharing options...
jvanegmond Posted May 2, 2006 Share Posted May 2, 2006 (edited) $temp = """{NUMPAD" & $i & "}""" Why do you use so many " ? $temp = "{NUMPAD" & $i & "}" is probably enough. Edited May 2, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Valuater Posted May 2, 2006 Share Posted May 2, 2006 just add While 1 SBAuto() Sleep(1) Wend to the top of your script ( above it ) 8) Link to comment Share on other sites More sharing options...
jvanegmond Posted May 2, 2006 Share Posted May 2, 2006 I understood from his post he did not simply ment "How to loop my function?" . His question should be: What's wrong with the second code? github.com/jvanegmond Link to comment Share on other sites More sharing options...
Fly By Night Posted May 2, 2006 Author Share Posted May 2, 2006 (edited) I used $temp = """{NUMPAD" & $i & "}""" as the Send command takes Send("{Numpad1}") Using $temp = "{NUMPAD" & $i & "}" would make it Send({Numpad1}) Also I made a mistake in the SBAuto2 function, If $yourpos <> $1 Then should be If $yourpos <> $i Then I know about this so you don't need to tell me that. Cheers for the help so far. I can't see what i've done wrong as it is running Send with the right value so that's why I came to the forums. Plus yes sorry I'm asking why the loop is not behaving. I'm calling it ok this is just the function that didn't behave as planned. Edited May 2, 2006 by Fly By Night Link to comment Share on other sites More sharing options...
Valuater Posted May 2, 2006 Share Posted May 2, 2006 maybe this expandcollapse popupRun("notepad") Dim $annDelay = 10, $yourpos = 0 While $yourpos < 8 $yourpos = $yourpos + 1 SBAuto2() Send("{ENTER}") SBAuto() Send("{ENTER 2}") WEnd Func SBAuto2() Sleep(450) Send("{NUMPAD0}") Sleep($annDelay) For $i = 1 to 8 Step 1 $temp = "{NUMPAD" & $i & "}" If $yourpos <> $i Then Send($temp) Sleep(50) Send($temp) Sleep(450) EndIf Next ;Sleep(80000); commented out EndFunc Func SBAuto() $i = 1; Sleep(450) Send("{NUMPAD0}") Sleep($annDelay) If $yourpos <> 1 Then Send("{NUMPAD1}") Sleep(50) Send("{NUMPAD1}") Sleep(450) EndIf If $yourpos <> 2 Then Send("{NUMPAD2}") Sleep(50) Send("{NUMPAD2}") Sleep(450) EndIf If $yourpos <> 3 Then Send("{NUMPAD3}") Sleep(50) Send("{NUMPAD3}") Sleep(450) EndIf If $yourpos <> 4 Then Send("{NUMPAD4}") Sleep(50) Send("{NUMPAD4}") Sleep(450) EndIf If $yourpos <> 5 Then Send("{NUMPAD5}") Sleep(50) Send("{NUMPAD5}") Sleep(450) EndIf If $yourpos <> 6 Then Send("{NUMPAD6}") Sleep(50) Send("{NUMPAD6}") Sleep(450) EndIf If $yourpos <> 7 Then Send("{NUMPAD7}") Sleep(50) Send("{NUMPAD7}") Sleep(450) EndIf If $yourpos <> 8 Then Send("{NUMPAD8}") Sleep(50) Send("{NUMPAD8}") EndIf ; Sleep(80000) EndFunc ;==>SBAuto this test both functions and works fine 8) Link to comment Share on other sites More sharing options...
Fly By Night Posted May 3, 2006 Author Share Posted May 3, 2006 Cheers I'll try that. I see my $temp = """{NUMPAD" & $i & "}""" wasn't working after all and $temp = "{NUMPAD" & $i & "}" does after all. Maybe you dont need the quotes for the value when using a variable with Send(). Thanks again .... Link to comment Share on other sites More sharing options...
Valuater Posted May 3, 2006 Share Posted May 3, 2006 Welcome 8) 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