Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 22:39

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Autoit multiple If endif question

Discussion on Autoit multiple If endif question within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2014
Posts: 5
Received Thanks: 0
Autoit multiple If endif question

Hello!
Here I'm again.
I'm reading help files, but it is my "English" or it is just a bit too complcated for now, but - here is my script -

HTML Code:
HotKeySet("{Del}", "TooglePause")
Global $Paused
Opt('PixelCoordMode', 0)
Global $handle = WinGetHandle("Lineage*II * ", "")

While 1
WEnd

Func TooglePause()
	$Paused = Not $Paused
	While $Paused

		;target hp bar check at 0 HP
		$tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)

		If IsArray($tHppixel) = 0 Then
			Send("{F12}") ;finding next mob
			Sleep(20)

			If IsArray($tHppixel) = 0 Then
				Send("{F11}") ;finding next mob
				Sleep(20)

				If IsArray($tHppixel) = 0 Then
					Send("{F10}") ;finding next mob
					Sleep(20)

				EndIf

			EndIf
   ;target should be found at this point, so attacking
		Else
			Send("{F2}") ;attacking mob skill 1
			Sleep(20)
			Send("{F3}") ;attacking mob skill 2
			Sleep(20)

		EndIf
	WEnd
EndFunc   ;==>TooglePause
I'm trying to next target mob if previous mob HP didn't show up. What happens is it presses F12,F11,F10 and stops at F10. I tried to implement ElseIf, but result is exactly the same. What am I doing wrong this time?


And one more question - is it possible to stop script with different script?
What I mean is if have script no1 running which every 1h stops other script no2 by pressing no1 hotkey for 1 minute and then again presses no1 hotkey and script no1 starts?! Or it should be implemented in script no2?
klikata is offline  
Old 08/25/2014, 21:27   #2
 
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
Code:
Opt('PixelCoordMode', 0)
Opt('SendKeyDelay', 25)

HotKeySet("{Del}", "TooglePause")

Global $paused = True
Global $handle

While Sleep(10)
    If Not $paused Then
        $handle = WinGetHandle("Lineage*II * ", "")
        If Not @error Then
            ;target hp bar check at 0 HP
            $tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)
            If @error Then
                Send("{F12}") ;finding next mob

                $tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)
                If @error Then
                    Send("{F11}") ;finding next mob

                    $tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)
                    If IsArray($tHppixel) = 0 Then
                        Send("{F10}") ;finding next mob
                    EndIf
                EndIf
            EndIf

            If IsArray($tHppixel) Then
                ;target found, attacking
                Send("{F2}") ;attacking mob skill 1
                Send("{F3}") ;attacking mob skill 2
            EndIf
        EndIf
    EndIf
WEnd

Func TooglePause()
    $Paused = Not $Paused
EndFunc
KDeluxe is offline  
Thanks
1 User
Old 08/26/2014, 14:20   #3
 
elite*gold: 0
Join Date: Jun 2014
Posts: 5
Received Thanks: 0
Thank you!
Added few extra sleep and now works as a charm. Your script gives me a good lesson of how to put things together and save pc resources as well. Cheers!
klikata is offline  
Old 08/26/2014, 20:45   #4

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
Quote:
Originally Posted by KDeluxe View Post
Code:
Opt('PixelCoordMode', 0)
Opt('SendKeyDelay', 25)

HotKeySet("{Del}", "TooglePause")

Global $paused = True
Global $handle

While Sleep(10)
    If Not $paused Then
        $handle = WinGetHandle("Lineage*II * ", "")
        If Not @error Then
            ;target hp bar check at 0 HP
            $tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)
            If @error Then
                Send("{F12}") ;finding next mob

                $tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)
                If @error Then
                    Send("{F11}") ;finding next mob

                    $tHppixel = PixelSearch(787, 58, 787, 58, 0x6F1713, 2, 1, $handle)
                    If IsArray($tHppixel) = 0 Then
                        Send("{F10}") ;finding next mob
                    EndIf
                EndIf
            EndIf

            If IsArray($tHppixel) Then
                ;target found, attacking
                Send("{F2}") ;attacking mob skill 1
                Send("{F3}") ;attacking mob skill 2
            EndIf
        EndIf
    EndIf
WEnd

Func TooglePause()
    $Paused = Not $Paused
EndFunc
Was macht While Sleep(10) ?
Also läuft die Schleife 10 Millisekunden lang? Wenn ja, wozu ist das gut
Moneypulation is offline  
Old 08/26/2014, 22:35   #5
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
Quote:
Originally Posted by moneypulation View Post
Was macht While Sleep(10) ?
Also läuft die Schleife 10 Millisekunden lang? Wenn ja, wozu ist das gut
Die Sleep funktion gibt immer 1 (True) zurück. Entsprechend ist
Code:
While Sleep(10)
WEnd
identisch zu
Code:
While True
    Sleep(10)
WEnd
Am Ende kann man mit "While Sleep(10)" eine Endlosschleife realisieren, welche gleichzeitig die CPU entlastet.
lolkop is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[NOOB] AutoIt Multiple Image Search
08/01/2014 - AutoIt - 0 Replies
Hello there, I am trying to make a very simple bot for a game I am currently playing. Here's the concept: There's an event every 30 minutes, so I'd like the bot to click on an image to open the window, then wait for the button to appear (there's a 30 minute timer before the image appears) then I want it to click on another image that will appear to start the actual battle. Once again wait for the battle to end and press X to close the window + repeat. Whilst in the battle, the timer...
Incomplete AutoIt Login Script for Multiple Accounts
10/27/2013 - League of Legends - 0 Replies
Hello guys, got quite bored today and wrote a little AutoIt Script, because I was pissed to change my account name and write the password all the time. When you start it, you can Choose your account Name, press Log In and it automatically starts the launcher and logs in. Bad thing is, I have no clue about Auto It Programming so it's needed to add all things manually. Also all accounts must have the same password and the "Remember Username" should not be checked. #cs...
Autoit multiple windows
10/17/2013 - AutoIt - 8 Replies
Hi IS it possible to make autoit work with multiple window for example i have 5 windows of running game, now i need when i start bot to ask me what window i want to choose. Please help :)
[Question] Wie ruft man in AutoIt eine Website per knopfdruck auf [Question]
08/04/2011 - AutoIt - 7 Replies
Wie ruft man eine Website per knopfdruck in AutoIt auf? Wenn geht Code und nochbesser Erklärung bei :D Danke schonmal im voraus :handsdown:
[Frage] If...Then...Endif
12/19/2010 - AutoIt - 13 Replies
Hallo, Hab da ein problem und zwar will ich das sich ne msgbox öffnet wenn eine gewisse uhrzeit und datum erreicht ist, die in einer listbox stehen: $_hb_date1 = GUICtrlRead($lbl_date) $_fw_date1 = GUICtrlRead($lb_fw_date) $_fw_time1 = GUICtrlRead($lb_fw_time) $_hb_time1 = GUICtrlread($lbl_uhrzeit)



All times are GMT +1. The time now is 22:40.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.