How to make this script run faster?

Get help with using AutoHotkey and its commands and hotkeys
RaisetheBass
Posts: 16
Joined: 08 Jul 2018, 06:17

How to make this script run faster?

16 Apr 2019, 03:20

it take so much time to run this code...too much if make this script run slow?


Code: Select all

#NoEnv
Loop
{
IE.Visible := True
WinActivate, ahk_class IEFrame
WinWaitActive, ahk_class IEFrame
WinGetTitle, WinTitle, ahk_class IEFrame
wb:=pwb_Get()
loaded := false
While !loaded
    try
    {
        if (wb.document.GetElementByID("wait") != "")
            loaded := true
    Sleep 100
if (wb.document.GetElementsByTagName("dv")[20].innertext) = "Online"
	goto Thing20
	else if (wb.document.GetElementsByTagName("dv")[21].innertext) = "Online"
	goto Thing21
	else if (wb.document.GetElementsByTagName("dv")[22].innertext) = "Online"
	goto Thing22
	else if (wb.document.GetElementsByTagName("dv")[23].innertext) = "Online"
	goto Thing23
	else if (wb.document.GetElementsByTagName("dv")[24].innertext) = "Online"
	goto Thing24
	else if (wb.document.GetElementsByTagName("dv")[25].innertext) = "Online"
	goto Thing25
	else if (wb.document.GetElementsByTagName("dv")[26].innertext) = "Online"
	goto Thing26
	else if (wb.document.GetElementsByTagName("dv")[27].innertext) = "Online"
	goto Thing27
	else if (wb.document.GetElementsByTagName("dv")[28].innertext) = "Online"
	goto Thing28
	else if (wb.document.GetElementsByTagName("dv")[29].innertext) = "Online"
	goto Thing29
	else if (wb.document.GetElementsByTagName("dv")[30].innertext) = "Online"
	goto Thing30
	else if (wb.document.GetElementsByTagName("dv")[31].innertext) = "Online"
	goto Thing31
	else if (wb.document.GetElementsByTagName("dv")[32].innertext) = "Online"
	goto Thing32
	else if (wb.document.GetElementsByTagName("dv")[33].innertext) = "Online"
	goto Thing33
	else if (wb.document.GetElementsByTagName("dv")[34].innertext) = "Online"
	goto Thing34
	else if (wb.document.GetElementsByTagName("dv")[35].innertext) = "Online"
	goto Thing35
	else if (wb.document.GetElementsByTagName("dv")[36].innertext) = "Online"
	goto Thing36
	else if (wb.document.GetElementsByTagName("dv")[37].innertext) = "Online"
	goto Thing37
	else if (wb.document.GetElementsByTagName("dv")[38].innertext) = "Online"
	goto Thing38
	else if (wb.document.GetElementsByTagName("dv")[39].innertext) = "Online"
	goto Thing39
	else if (wb.document.GetElementsByTagName("dv")[40].innertext) = "Online"
	goto Thing40
	else if (wb.document.GetElementsByTagName("dv")[41].innertext) = "Online"
	goto Thing41
	else if (wb.document.GetElementsByTagName("dv")[42].innertext) = "Online"
	goto Thing42
	else if (wb.document.GetElementsByTagName("dv")[43].innertext) = "Online"
	goto Thing43
	else if (wb.document.GetElementsByTagName("dv")[44].innertext) = "Online"
	goto Thing44
	else if (wb.document.GetElementsByTagName("dv")[45].innertext) = "Online"
	goto Thing45
	else if (wb.document.GetElementsByTagName("dv")[46].innertext) = "Online"
	goto Thing46
	else if (wb.document.GetElementsByTagName("dv")[47].innertext) = "Online"
	goto Thing47
	else if (wb.document.GetElementsByTagName("dv")[48].innertext) = "Online"
	goto Thing48
	else if (wb.document.GetElementsByTagName("dv")[49].innertext) = "Online"
	goto Thing49
	else if (wb.document.GetElementsByTagName("dv")[50].innertext) = "Online"
	goto Thing50
	else if (wb.document.GetElementsByTagName("dv")[51].innertext) = "Online"
	goto Thing51
	else if (wb.document.GetElementsByTagName("dv")[52].innertext) = "Online"
	goto Thing52
	else if (wb.document.GetElementsByTagName("dv")[53].innertext) = "Online"
	goto Thing53
	else if (wb.document.GetElementsByTagName("dv")[54].innertext) = "Online"
	goto Thing54
	else if (wb.document.GetElementsByTagName("dv")[55].innertext) = "Online"
	goto Thing55
	else if (wb.document.GetElementsByTagName("dv")[56].innertext) = "Online"
	goto Thing56
	else if (wb.document.GetElementsByTagName("dv")[57].innertext) = "Online"
	goto Thing57
	else if (wb.document.GetElementsByTagName("dv")[58].innertext) = "Online"
	goto Thing58
	else if (wb.document.GetElementsByTagName("dv")[59].innertext) = "Online"
	goto Thing59
	else if (wb.document.GetElementsByTagName("dv")[60].innertext) = "Online"
	goto Thing60
	else if (wb.document.GetElementsByTagName("dv")[61].innertext) = "Online"
	goto Thing61
	else if (wb.document.GetElementsByTagName("dv")[62].innertext) = "Online"
	goto Thing62
	else if (wb.document.GetElementsByTagName("dv")[63].innertext) = "Online"
	goto Thing63
	else if (wb.document.GetElementsByTagName("dv")[64].innertext) = "Online"
	goto Thing64
	else if (wb.document.GetElementsByTagName("dv")[65].innertext) = "Online"
	goto Thing65
	else if (wb.document.GetElementsByTagName("dv")[66].innertext) = "Online"
	goto Thing66
	else if (wb.document.GetElementsByTagName("dv")[67].innertext) = "Online"
	goto Thing67
	else if (wb.document.GetElementsByTagName("dv")[68].innertext) = "Online"
	goto Thing68
	else if (wb.document.GetElementsByTagName("dv")[69].innertext) = "Online"
	goto Thing69
	else if (wb.document.GetElementsByTagName("dv")[70].innertext) = "Online"
	goto Thing70
	else if (wb.document.GetElementsByTagName("dv")[71].innertext) = "Online"
	goto Thing71
	else if (wb.document.GetElementsByTagName("dv")[72].innertext) = "Online"
	goto Thing72
	else if (wb.document.GetElementsByTagName("dv")[73].innertext) = "Online"
	goto Thing73
	else if (wb.document.GetElementsByTagName("dv")[74].innertext) = "Online"
	goto Thing74
	else if (wb.document.GetElementsByTagName("dv")[75].innertext) = "Online"
	goto Thing75
	else if (wb.document.GetElementsByTagName("dv")[76].innertext) = "Online"
	goto Thing76
	else if (wb.document.GetElementsByTagName("dv")[77].innertext) = "Online"
	goto Thing77
	else if (wb.document.GetElementsByTagName("dv")[21].innertext) = "Offline"
	goto DeleteThing21
	else if (wb.document.GetElementsByTagName("dv")[22].innertext) = "Offline"
	goto DeleteThing22
	else if (wb.document.GetElementsByTagName("dv")[23].innertext) = "Offline"
	goto DeleteThing23
	else if (wb.document.GetElementsByTagName("dv")[24].innertext) = "Offline"
	goto DeleteThing24
	else if (wb.document.GetElementsByTagName("dv")[25].innertext) = "Offline"
	goto DeleteThing25
	else if (wb.document.GetElementsByTagName("dv")[26].innertext) = "Offline"
	goto DeleteThing26
	else if (wb.document.GetElementsByTagName("dv")[27].innertext) = "Offline"
	goto DeleteThing27
	else if (wb.document.GetElementsByTagName("dv")[28].innertext) = "Offline"
	goto DeleteThing28
	else if (wb.document.GetElementsByTagName("dv")[29].innertext) = "Offline"
	goto DeleteThing29
	else if (wb.document.GetElementsByTagName("dv")[30].innertext) = "Offline"
	goto DeleteThing30
	else if (wb.document.GetElementsByTagName("dv")[31].innertext) = "Offline"
	goto DeleteThing31
	else if (wb.document.GetElementsByTagName("dv")[32].innertext) = "Offline"
	goto DeleteThing32
	else if (wb.document.GetElementsByTagName("dv")[33].innertext) = "Offline"
	goto DeleteThing33
	else if (wb.document.GetElementsByTagName("dv")[34].innertext) = "Offline"
	goto DeleteThing34
	else if (wb.document.GetElementsByTagName("dv")[35].innertext) = "Offline"
	goto DeleteThing35
	else if (wb.document.GetElementsByTagName("dv")[36].innertext) = "Offline"
	goto DeleteThing36
	else if (wb.document.GetElementsByTagName("dv")[37].innertext) = "Offline"
	goto DeleteThing37
	else if (wb.document.GetElementsByTagName("dv")[38].innertext) = "Offline"
	goto DeleteThing38
	else if (wb.document.GetElementsByTagName("dv")[39].innertext) = "Offline"
	goto DeleteThing39
	else if (wb.document.GetElementsByTagName("dv")[40].innertext) = "Offline"
	goto DeleteThing40
	else if (wb.document.GetElementsByTagName("dv")[41].innertext) = "Offline"
	goto DeleteThing41
	else if (wb.document.GetElementsByTagName("dv")[42].innertext) = "Offline"
	goto DeleteThing42
	else if (wb.document.GetElementsByTagName("dv")[43].innertext) = "Offline"
	goto DeleteThing43
	else if (wb.document.GetElementsByTagName("dv")[44].innertext) = "Offline"
	goto DeleteThing44
	else if (wb.document.GetElementsByTagName("dv")[45].innertext) = "Offline"
	goto DeleteThing45
	else if (wb.document.GetElementsByTagName("dv")[46].innertext) = "Offline"
	goto DeleteThing46
	else if (wb.document.GetElementsByTagName("dv")[47].innertext) = "Offline"
	goto DeleteThing47
	else if (wb.document.GetElementsByTagName("dv")[48].innertext) = "Offline"
	goto DeleteThing48
	else if (wb.document.GetElementsByTagName("dv")[49].innertext) = "Offline"
	goto DeleteThing49
	else if (wb.document.GetElementsByTagName("dv")[50].innertext) = "Offline"
	goto DeleteThing50
	else if (wb.document.GetElementsByTagName("dv")[51].innertext) = "Offline"
	goto DeleteThing51
	else if (wb.document.GetElementsByTagName("dv")[52].innertext) = "Offline"
	goto DeleteThing52
	else if (wb.document.GetElementsByTagName("dv")[53].innertext) = "Offline"
	goto DeleteThing53
	else if (wb.document.GetElementsByTagName("dv")[54].innertext) = "Offline"
	goto DeleteThing54
	else if (wb.document.GetElementsByTagName("dv")[55].innertext) = "Offline"
	goto DeleteThing55
	else if (wb.document.GetElementsByTagName("dv")[56].innertext) = "Offline"
	goto DeleteThing56
	else if (wb.document.GetElementsByTagName("dv")[57].innertext) = "Offline"
	goto DeleteThing57
	else if (wb.document.GetElementsByTagName("dv")[58].innertext) = "Offline"
	goto DeleteThing58
	else if (wb.document.GetElementsByTagName("dv")[59].innertext) = "Offline"
	goto DeleteThing59
	else if (wb.document.GetElementsByTagName("dv")[60].innertext) = "Offline"
	goto DeleteThing60
	else if (wb.document.GetElementsByTagName("dv")[61].innertext) = "Offline"
	goto DeleteThing61
	else if (wb.document.GetElementsByTagName("dv")[62].innertext) = "Offline"
	goto DeleteThing62
	else if (wb.document.GetElementsByTagName("dv")[63].innertext) = "Offline"
	goto DeleteThing63
	else if (wb.document.GetElementsByTagName("dv")[64].innertext) = "Offline"
	goto DeleteThing64
	else if (wb.document.GetElementsByTagName("dv")[65].innertext) = "Offline"
	goto DeleteThing65
	else if (wb.document.GetElementsByTagName("dv")[66].innertext) = "Offline"
	goto DeleteThing66
	else if (wb.document.GetElementsByTagName("dv")[67].innertext) = "Offline"
	goto DeleteThing67
	else if (wb.document.GetElementsByTagName("dv")[68].innertext) = "Offline"
	goto DeleteThing68
	else if (wb.document.GetElementsByTagName("dv")[69].innertext) = "Offline"
	goto DeleteThing69
	else if (wb.document.GetElementsByTagName("dv")[70].innertext) = "Offline"
	goto DeleteThing70
	else if (wb.document.GetElementsByTagName("dv")[71].innertext) = "Offline"
	goto DeleteThing71
	else if (wb.document.GetElementsByTagName("dv")[72].innertext) = "Offline"
	goto DeleteThing72
	else if (wb.document.GetElementsByTagName("dv")[73].innertext) = "Offline"
	goto DeleteThing73
	else if (wb.document.GetElementsByTagName("dv")[74].innertext) = "Offline"
	goto DeleteThing74
	else if (wb.document.GetElementsByTagName("dv")[75].innertext) = "Offline"
	goto DeleteThing75
	else if (wb.document.GetElementsByTagName("dv")[76].innertext) = "Offline"
	goto DeleteThing76
	else if (wb.document.GetElementsByTagName("dv")[77].innertext) = "Offline"
	goto DeleteThing77
	else
	goto Next
}
}
User avatar
evilC
Posts: 4588
Joined: 27 Feb 2014, 12:30

Re: How to make this script run faster?

16 Apr 2019, 06:48

No, but it can be made a ton shorter.

Code: Select all

#NoEnv
Loop
{
	IE.Visible := True
	WinActivate, ahk_class IEFrame
	WinWaitActive, ahk_class IEFrame
	WinGetTitle, WinTitle, ahk_class IEFrame
	wb:=pwb_Get()
	loaded := false
	While !loaded {
		try
		{
			if (wb.document.GetElementByID("wait") != "")
				loaded := true
			Sleep 100
			Loop 57
			{
				i := A_Index + 19
				if (wb.document.GetElementsByTagName("dv")[i].innertext) = "Online"
					goto Thing%i%
			}
			Loop 57
			{
				i := A_Index + 20
				if (wb.document.GetElementsByTagName("dv")[i].innertext) = "Offline"
					goto DeleteThing%i%
			}
			goto Next
		}
	}
}
RaisetheBass
Posts: 16
Joined: 08 Jul 2018, 06:17

Re: How to make this script run faster?

17 Apr 2019, 10:43

thank for reply..

Have other way to make it search the element 1 until 100 without loop?
hd0202
Posts: 99
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: How to make this script run faster?

17 Apr 2019, 23:16

Code: Select all

SetBatchLines, -1
Hubert

Return to “Ask For Help”

Who is online

Users browsing this forum: Ataricx, Bing [Bot], Odlanir, swagfag, vsub and 29 guests