turboxikka228 Posted November 1, 2017 Posted November 1, 2017 Hello i have a code HotKeySet("{F6}","_Exit") While 1 sleep(100) $pos1 = PixelSearch (1176, 636, 1233, 671,0xF0AD4E) If IsArray($pos1) = 1 Then sleep (10) MouseClick("left", 167, 659, 2) Sleep (100) Send("text1") Send("{ENTER}") Sleep (100) Send("text2") Send("{ENTER}") Sleep (100) Send("text3") Send("{ENTER}") Sleep (100) Send("text4") Send("{ENTER}") EndIf $pos2 = PixelSearch(633, 660, 718, 692, 0x5CB85C) If IsArray($pos2) = 1 Then Send("{F5}") Sleep (1000) EndIf WEnd Func _Exit() Exit EndFunc This loop works fine, but i want to send "text1","text2","text3","text4" only once, but it keep spamming "text1","text2","text3","text4" until $pos2 Please help me
gruntydatsun Posted November 1, 2017 Posted November 1, 2017 $i = 1 while 1 if $i = 1 then ConsoleWrite("Only do once") EndIf ConsoleWrite("Do this everytime") wend
turboxikka228 Posted November 1, 2017 Author Posted November 1, 2017 15 minutes ago, gruntydatsun said: $i = 1 while 1 if $i = 1 then ConsoleWrite("Only do once") EndIf ConsoleWrite("Do this everytime") wend sorry but i didnt realise i'm newbie at autoit please explain more
Moderators JLogan3o13 Posted November 1, 2017 Moderators Posted November 1, 2017 @turboxikka228 perhaps further explanation of what you're trying to accomplish would help us help you. Relying on PixelSearch and Sends is a notoriously unstable way of doing things, as you're coming to find. There is doubtless an easier way to accomplish what you are after. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
gruntydatsun Posted November 1, 2017 Posted November 1, 2017 Hey, ok so I mean you create a counter set at one outside the while loop, only do the text1,2,3 part if the value of that counter is 1. Increment the counter at the end of the while loop. Like JLogan3o13 said, there's likely a better way to do what you want to do than using send though. Anyway, here it is in your code: HotKeySet("{F6}","_Exit") $count = 1 While 1 sleep(100) $pos1 = PixelSearch (1176, 636, 1233, 671,0xF0AD4E) if $count = 1 and IsArray($pos1) = 1 Then sleep (10) MouseClick("left", 167, 659, 2) Sleep (100) Send("text1") Send("{ENTER}") Sleep (100) Send("text2") Send("{ENTER}") Sleep (100) Send("text3") Send("{ENTER}") Sleep (100) Send("text4") Send("{ENTER}") EndIf $pos2 = PixelSearch(633, 660, 718, 692, 0x5CB85C) If IsArray($pos2) = 1 Then Send("{F5}") Sleep (1000) EndIf $count += 1 WEnd Func _Exit() Exit EndFunc hope that helps
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