我的第一个 Autohotkey 运行速度太慢
My first Autohotkey runs too slow
所以我已经有大约 4 年没有接触过任何类型的脚本了,我想为了脚本而重新投入其中。我喜欢它带来的解决问题的能力。 Annnyyyyway.
我正在制作一个小机器人来测试我第一次尝试能走多远。现在我知道代码很糟糕而且很长,我知道我可以让它更短、更高效(所以任何和所有关于它的提示都是受欢迎的)。
所以我的问题是,我在速度方面做错了什么?因为在部分:
;Select first company. Any missions?
LabelMission1:
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 223
它非常慢,因为它需要整整 3 秒才能通过按 's' 和 'space' 在检查可用任务和 'going to the next company' 之间切换。我尝试通过将睡眠时间从平均 600 次降低到平均 200 次来加快代码速度,但这似乎并没有太大作用,它加快了某些部分的速度,但没有加快公司之间的切换和检查任务。
所以欢迎任何帮助,如果你想完全分解我的代码并编写超级高效的代码,我同意,只要向我解释你做了什么。我想尽可能多地向你们学习:)
编辑:这是用 Scite4Autohotkey 编写的 C++
你好,
都山
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SetKeyDelay, 20, 20
SetMouseDelay, 200
#MaxThreads 255
;What gamemode is the game in? Solo or private?
;send {Escape}
; ImageSearch FoundX, FoundY, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mode_Solo_Play.bmp
; {
; If ErrorLevel = 0
; return
; {
; If ErrorLevel = 1
;
--------------------------------------------------------------------------------------------------------------------------
;Is the game loaded and in bulletin board? ((If not can we see starport service?)) -> ((If not can we see mission board?))
labelstart: ;this label is the startingpoint of the script
sleep 4500
ImageSearch pointX, pointY, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Starport_services.bmp ;Can we see starport services?
{
sleep 150
If ErrorLevel = 1 ; If it CAN'T find Starport Services, it will look for Mission Board instead.
{
sleep 150
ImageSearch pointX2, pointY2, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mission_Board.bmp ;Can we see Mission Board?
if ErrorLevel = 1 ;If it CAN'T find mission board, it will ask for it.
{
MsgBox, 48, Something went wrong!, I can't find "Mission Board" or "Starport Services" anywhere.
MsgBox, 4132, Something went wrong!, Do you wish to retry?
IfMsgBox Yes
{
MsgBox, 4160, Restarting, Click OK and switch back to game with "Starport Services" Open!! `n(YOU GET 15 SECONDS TIME)
sleep 15000
gosub labelstart
}
else IfMsgBox no
ExitApp
}
If ErrorLevel = 0 ;If it finds Mission Board it will navigate to the Mission Board.
{
Sleep 143
SendEvent s
Sleep 177
SendEvent {Space}
sleep 10000
gosub LabelMissionBoard
}
}
If ErrorLevel = 0 ;If it finds Starport services it will navigate to the Mission Board.
{
Sleep 200
SendEvent {space}
sleep 15234
SendEvent s
sleep 134
SendEvent {Space}
sleep 10000
gosub LabelMissionBoard
}
}
;Are we in the mission board?
LabelMissionBoard: ;Jump here to check for missionboard
ImageSearch pointX3, pointY3, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mission_Board_Open.bmp ; Is the mission board open?
{
sleep 233
if ErrorLevel = 1 ;If it CAN'T find the Mission Board Open.
{
MsgBox, 16, Something went wrong!, I can't find the "Mission Board" Opened`, did I open it? `n- If I didn't`, please open it and press OK. (10 seconds before I retry.) `n- If I did please restart the script (end it with ctrl+R)
sleep 9989
gosub LabelMissionBoard
}
if ErrorLevel = 0 ;If it CAN find the Mission Board open.
{
sleep 50
gosub LabelEnoughCredits
}
}
;Do we have enough credits? (over 1,000,000) ((Probably pixel search here))
LabelEnoughCredits:
;LINE IS TEMPORARLEY DISABLED
;PixelSearch, Px, Py, 246, 190, 246, 190, 0xD1CECD, 10, Fast ;Looking for credits over 1,000,000 ((Credits shift to the left when below 1kk, so it should no longer be there.))!!UNTESTED!!
;LINE IS TEMPORARLEY DISABLED
ImageSearch pointX3, pointY3, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Above_1_Million.bmp ;Looking for credits over 1,000,000 ((Credits shift to the left when below 1kk, so it should no longer be there.))!!UNTESTED!!
Sleep 80
{
Sleep 91
If ErrorLevel = 1 ;If it finds out you DON'T have above 1,000,000.
{
MsgBox, 0, MONEY PROBLEM!, Unfortunately you seem to have ran out of funds. If I go further you won't be able to pay your insurance!`n- Please Make sure you have above 1`,000`,000.
sleep 98
ExitApp
}
If Errorlevel = 0 ;If it find out you DO have above 1,000,000.
{
sleep 100
gosub LabelAID
}
}
;Is the filter "Aid" selected?
LabelAID:
ImageSearch pointX4, pointY4, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Aid_Selected.bmp ;Can we find Aid?
{
sleep 123
If Errorlevel = 1 ;If it ISN'T selected.
{
sleep 170
send a
sleep 163
send a
sleep 133
send a
sleep 125
send a
sleep 160
send a
sleep 163
send a
sleep 148
send a
sleep 151
send a
sleep 140
Send w
Sleep 142
Send w
Sleep 136
Send w
Sleep 132
Send w
Sleep 147
Send w
Sleep 146
Send w
Sleep 154
Send w
Sleep 137
Send w
Sleep 124
Send {Space} ;Selecting filter
Sleep 1107
send s
Sleep 113
send s
Sleep 118
send s
Sleep 118
send s
Sleep 116
send s
Sleep 139
Send {Space} ;AID filter is selected.
Sleep 123
send s
sleep 143
send s
sleep 154
send {Space} ;First mission is selected.
Sleep 162
Gosub labelMission1
}
If Errorlevel = 0 ;If aid IS selected.
{
Sleep 143
send s
sleep 143
send s
sleep 154
send {Space}
Sleep 162
Gosub labelMission1 ;If found select first Group to check for mission
}
}
;Select first company. Any missions?
LabelMission1:
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 223
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 150
Send s
sleep 160
send {Space}
Sleep 113
gosub LabelMission2
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected1:
Sleep 266
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 50
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected1 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 831
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 951
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 2nd company. Any missions?
LabelMission2:
ImageSearch pointX6, pointY6, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 143
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 550
Send s
sleep 660
send {Space}
Sleep 613
gosub LabelMission3
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected2:
Sleep 266
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 50
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected2 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 3rd company. Any missions?
LabelMission3:
ImageSearch pointX7, pointY7, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
Sleep 163
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 450
Send s
sleep 460
send {Space}
Sleep 513
gosub LabelMission4
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected3:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected3 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 4th company. Any missions?
LabelMission4:
ImageSearch pointX8, pointY8, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
Sleep 196
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 150
Send s
sleep 260
send {Space}
Sleep 113
gosub LabelMission5
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected4:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected4 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 5th company. Any missions?
LabelMission5:
ImageSearch pointX9, pointY9, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
Sleep 131
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 350
Send s
sleep 360
send {Space}
Sleep 313
gosub LabelMission6
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected5:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected5 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 6th company. Any missions?
LabelMission6:
ImageSearch pointX11, pointY11, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 385
if Errorlevel = 1 ; If mission ISN'T found.
{
sleep 273
gosub LabelSoloPrivate ;If at this point it CAN'T find anymore missions to turn in, it will go to gamemode check.
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected6:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected6 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 300
send {Space}
Sleep 300
send {Space}
sleep 231
send {backspace}
sleep 822
Send {backspace}
sleep 841
send {backspace}
sleep 851
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Back to Main Menu, Were we in Solo or Private?
LabelSoloPrivate:
sleep 678
send {Escape}
sleep 700
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mode_Solo_Play.bmp ;Is the game mode set on Solo play?
{
Sleep 284
If ErrorLevel = 1 ;If game mode ISN'T solo play
{
sleep 786
gosub LabelModeIsPrivate
MsgBox, 0, Current Gamemode, Gamemode is private!
sleep 6000
}
If ErrorLevel = 0 ;If game mode IS Solo Play
{
Sleep 600
gosub LabelModeIsSolo
MsgBox, 0, Current Gamemode, Gamemode is solo!
Sleep 6000
}
}
;If solo, select private. -- If Private, select solo.
LabelModeIsSolo:
{
Sleep 256
send w
Sleep 612
send w
sleep 302
send {space}
sleep 630
send d
sleep 234
send {space}
sleep 15000 ;Waiting for Main Menu to load.
send s
sleep 953
send {space} ;Selecting start.
Sleep 943
send s
Sleep 823
send {space} ;Selecting Private group.
Sleep 723
send {space} ;Starting Private group.
Sleep 18213 ;Waiting for game to start.
gosub labelstart
}
LabelModeIsPrivate:
{
Sleep 502
send w
Sleep 682
send w
sleep 511
send {space}
sleep 687
send d
sleep 799
send {space}
sleep 17631 ;Waiting for Main Menu to load.
send s
sleep 653
send {space} ;Selecting start.
Sleep 943
send s
Sleep 723
send s
Sleep 623
send {space} ;Selecting solo.
Sleep 16347 ;Waiting for game to start.
gosub labelstart
}
;Eat, sleep, rave. Repeat.
^r::ExitApp ;Kills the script, if it goes haywire.
没关系,我完全搞砸了,现在我知道为什么了。感谢大家的帮助....
编辑:很好。
就像我在原著中所说的那样,整个剧本简直糟透了post。至于它有什么问题,没有这里任何人的帮助,即使我知道那里有人看到它并看到错误并决定不提供帮助。
IF 语句和 Searchimage 设置在错误的 { } 中。因为在整个脚本构建中毫无意义,它甚至开始工作都是一个奇迹。
对于初学者来说,这是它应该看起来的样子。
ImageSearch pointX, pointY, 0, 0, 1920, 1080, *125 C:\Users\ICECOLD\Desktop\new_test\Starport_services.bmp ;Can we see starport services?
{
sleep 150
If ErrorLevel = 1 ; If it CAN'T find Starport Services, it will look for Mission Board instead.
{
sleep 150
ImageSearch pointX2, pointY2, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mission_Board.bmp ;Can we see Mission Board?
if ErrorLevel = 1 ;If it CAN'T find mission board, it will ask for it.
{
MsgBox, 48, Something went wrong!, I can't find "Mission Board" or "Starport Services" anywhere.
MsgBox, 4132, Something went wrong!, Do you wish to retry?
IfMsgBox Yes
{
MsgBox, 4160, Restarting, Click OK and switch back to game with "Starport Services" Open!! `n(YOU GET 15 SECONDS TIME)
sleep 15000
gosub labelstart
ExitApp
If ErrorLevel = 0 ;If it finds Mission Board it will navigate to the Mission Board.
{
Sleep 143
SendEvent s
Sleep 177
SendEvent {Space}
sleep 10000
gosub LabelMissionBoard
If ErrorLevel = 0 ;If it finds Starport services it will navigate to the Mission Board.
{
Sleep 200
SendEvent {space}
sleep 15234
SendEvent s
sleep 134
SendEvent {Space}
sleep 10000
} gosub LabelMissionBoard
}
}
}
}
}
正如您在上面的代码中看到的,与我最初 post 编写的代码的开头相反。它同时发生了多件事,所以它没有在找到图像后停止,而是继续前进,无论如何,它没有按下按钮只计算 'sleep' 不管出于什么原因,我有没有 f&^*( 线索,因为我在这一点上基本上是一个初学者。不过是一个咸的。所以这是你该死的答案,现在对不起,我再也不会回到这里了。
所以我已经有大约 4 年没有接触过任何类型的脚本了,我想为了脚本而重新投入其中。我喜欢它带来的解决问题的能力。 Annnyyyyway.
我正在制作一个小机器人来测试我第一次尝试能走多远。现在我知道代码很糟糕而且很长,我知道我可以让它更短、更高效(所以任何和所有关于它的提示都是受欢迎的)。
所以我的问题是,我在速度方面做错了什么?因为在部分:
;Select first company. Any missions?
LabelMission1:
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 223
它非常慢,因为它需要整整 3 秒才能通过按 's' 和 'space' 在检查可用任务和 'going to the next company' 之间切换。我尝试通过将睡眠时间从平均 600 次降低到平均 200 次来加快代码速度,但这似乎并没有太大作用,它加快了某些部分的速度,但没有加快公司之间的切换和检查任务。
所以欢迎任何帮助,如果你想完全分解我的代码并编写超级高效的代码,我同意,只要向我解释你做了什么。我想尽可能多地向你们学习:)
编辑:这是用 Scite4Autohotkey 编写的 C++
你好,
都山
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SetKeyDelay, 20, 20
SetMouseDelay, 200
#MaxThreads 255
;What gamemode is the game in? Solo or private?
;send {Escape}
; ImageSearch FoundX, FoundY, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mode_Solo_Play.bmp
; {
; If ErrorLevel = 0
; return
; {
; If ErrorLevel = 1
;
--------------------------------------------------------------------------------------------------------------------------
;Is the game loaded and in bulletin board? ((If not can we see starport service?)) -> ((If not can we see mission board?))
labelstart: ;this label is the startingpoint of the script
sleep 4500
ImageSearch pointX, pointY, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Starport_services.bmp ;Can we see starport services?
{
sleep 150
If ErrorLevel = 1 ; If it CAN'T find Starport Services, it will look for Mission Board instead.
{
sleep 150
ImageSearch pointX2, pointY2, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mission_Board.bmp ;Can we see Mission Board?
if ErrorLevel = 1 ;If it CAN'T find mission board, it will ask for it.
{
MsgBox, 48, Something went wrong!, I can't find "Mission Board" or "Starport Services" anywhere.
MsgBox, 4132, Something went wrong!, Do you wish to retry?
IfMsgBox Yes
{
MsgBox, 4160, Restarting, Click OK and switch back to game with "Starport Services" Open!! `n(YOU GET 15 SECONDS TIME)
sleep 15000
gosub labelstart
}
else IfMsgBox no
ExitApp
}
If ErrorLevel = 0 ;If it finds Mission Board it will navigate to the Mission Board.
{
Sleep 143
SendEvent s
Sleep 177
SendEvent {Space}
sleep 10000
gosub LabelMissionBoard
}
}
If ErrorLevel = 0 ;If it finds Starport services it will navigate to the Mission Board.
{
Sleep 200
SendEvent {space}
sleep 15234
SendEvent s
sleep 134
SendEvent {Space}
sleep 10000
gosub LabelMissionBoard
}
}
;Are we in the mission board?
LabelMissionBoard: ;Jump here to check for missionboard
ImageSearch pointX3, pointY3, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mission_Board_Open.bmp ; Is the mission board open?
{
sleep 233
if ErrorLevel = 1 ;If it CAN'T find the Mission Board Open.
{
MsgBox, 16, Something went wrong!, I can't find the "Mission Board" Opened`, did I open it? `n- If I didn't`, please open it and press OK. (10 seconds before I retry.) `n- If I did please restart the script (end it with ctrl+R)
sleep 9989
gosub LabelMissionBoard
}
if ErrorLevel = 0 ;If it CAN find the Mission Board open.
{
sleep 50
gosub LabelEnoughCredits
}
}
;Do we have enough credits? (over 1,000,000) ((Probably pixel search here))
LabelEnoughCredits:
;LINE IS TEMPORARLEY DISABLED
;PixelSearch, Px, Py, 246, 190, 246, 190, 0xD1CECD, 10, Fast ;Looking for credits over 1,000,000 ((Credits shift to the left when below 1kk, so it should no longer be there.))!!UNTESTED!!
;LINE IS TEMPORARLEY DISABLED
ImageSearch pointX3, pointY3, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Above_1_Million.bmp ;Looking for credits over 1,000,000 ((Credits shift to the left when below 1kk, so it should no longer be there.))!!UNTESTED!!
Sleep 80
{
Sleep 91
If ErrorLevel = 1 ;If it finds out you DON'T have above 1,000,000.
{
MsgBox, 0, MONEY PROBLEM!, Unfortunately you seem to have ran out of funds. If I go further you won't be able to pay your insurance!`n- Please Make sure you have above 1`,000`,000.
sleep 98
ExitApp
}
If Errorlevel = 0 ;If it find out you DO have above 1,000,000.
{
sleep 100
gosub LabelAID
}
}
;Is the filter "Aid" selected?
LabelAID:
ImageSearch pointX4, pointY4, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Aid_Selected.bmp ;Can we find Aid?
{
sleep 123
If Errorlevel = 1 ;If it ISN'T selected.
{
sleep 170
send a
sleep 163
send a
sleep 133
send a
sleep 125
send a
sleep 160
send a
sleep 163
send a
sleep 148
send a
sleep 151
send a
sleep 140
Send w
Sleep 142
Send w
Sleep 136
Send w
Sleep 132
Send w
Sleep 147
Send w
Sleep 146
Send w
Sleep 154
Send w
Sleep 137
Send w
Sleep 124
Send {Space} ;Selecting filter
Sleep 1107
send s
Sleep 113
send s
Sleep 118
send s
Sleep 118
send s
Sleep 116
send s
Sleep 139
Send {Space} ;AID filter is selected.
Sleep 123
send s
sleep 143
send s
sleep 154
send {Space} ;First mission is selected.
Sleep 162
Gosub labelMission1
}
If Errorlevel = 0 ;If aid IS selected.
{
Sleep 143
send s
sleep 143
send s
sleep 154
send {Space}
Sleep 162
Gosub labelMission1 ;If found select first Group to check for mission
}
}
;Select first company. Any missions?
LabelMission1:
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 223
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 150
Send s
sleep 160
send {Space}
Sleep 113
gosub LabelMission2
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected1:
Sleep 266
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 50
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected1 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 831
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 951
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 2nd company. Any missions?
LabelMission2:
ImageSearch pointX6, pointY6, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 143
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 550
Send s
sleep 660
send {Space}
Sleep 613
gosub LabelMission3
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected2:
Sleep 266
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 50
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected2 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 3rd company. Any missions?
LabelMission3:
ImageSearch pointX7, pointY7, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
Sleep 163
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 450
Send s
sleep 460
send {Space}
Sleep 513
gosub LabelMission4
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected3:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected3 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 4th company. Any missions?
LabelMission4:
ImageSearch pointX8, pointY8, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
Sleep 196
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 150
Send s
sleep 260
send {Space}
Sleep 113
gosub LabelMission5
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected4:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected4 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 5th company. Any missions?
LabelMission5:
ImageSearch pointX9, pointY9, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
Sleep 131
if Errorlevel = 1 ; If mission ISN'T found.
{
Sleep 350
Send s
sleep 360
send {Space}
Sleep 313
gosub LabelMission6
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected5:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected5 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 700
send {Space}
Sleep 700
send {Space}
sleep 1231
send {backspace}
sleep 322
Send {backspace}
sleep 241
send {backspace}
sleep 3251
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Select 6th company. Any missions?
LabelMission6:
ImageSearch pointX11, pointY11, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k.bmp
{
sleep 385
if Errorlevel = 1 ; If mission ISN'T found.
{
sleep 273
gosub LabelSoloPrivate ;If at this point it CAN'T find anymore missions to turn in, it will go to gamemode check.
}
if Errorlevel = 0 ; If missions IS Found.
{
sleep 143
Send D
Sleep 160
Send w
Sleep 166
Send w
Sleep 129
Send w
Sleep 177
Send w
Sleep 167
Send w
Sleep 146
Send w
Sleep 172
Send w
Sleep 112 ;Top of mission list selected
Label25kSelected6:
Sleep 66
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Donate25k_selected.bmp ;Did it select the 25k Mission?
{
sleep 250
If Errorlevel = 1 ;If Mission ISN'T selected.
{
sleep 376
send s
sleep 185
gosub Label25kSelected6 ;If it CAN'T find the mission by pressing 'S' once, it will retry untill it does.
}
If ErrorLevel = 0 ;If Mission IS selected.
{
send w
sleep 50
send w
sleep 50
send w
sleep 50
send {Space}
sleep 360
Send D
Sleep 260
send {Space}
Sleep 300
send {Space}
Sleep 300
send {Space}
sleep 231
send {backspace}
sleep 822
Send {backspace}
sleep 841
send {backspace}
sleep 851
gosub Labelstart ;Mission is turned in, going back to start to see the refresh if there is anymore.
}
}
}
}
;Back to Main Menu, Were we in Solo or Private?
LabelSoloPrivate:
sleep 678
send {Escape}
sleep 700
ImageSearch pointX5, pointY5, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mode_Solo_Play.bmp ;Is the game mode set on Solo play?
{
Sleep 284
If ErrorLevel = 1 ;If game mode ISN'T solo play
{
sleep 786
gosub LabelModeIsPrivate
MsgBox, 0, Current Gamemode, Gamemode is private!
sleep 6000
}
If ErrorLevel = 0 ;If game mode IS Solo Play
{
Sleep 600
gosub LabelModeIsSolo
MsgBox, 0, Current Gamemode, Gamemode is solo!
Sleep 6000
}
}
;If solo, select private. -- If Private, select solo.
LabelModeIsSolo:
{
Sleep 256
send w
Sleep 612
send w
sleep 302
send {space}
sleep 630
send d
sleep 234
send {space}
sleep 15000 ;Waiting for Main Menu to load.
send s
sleep 953
send {space} ;Selecting start.
Sleep 943
send s
Sleep 823
send {space} ;Selecting Private group.
Sleep 723
send {space} ;Starting Private group.
Sleep 18213 ;Waiting for game to start.
gosub labelstart
}
LabelModeIsPrivate:
{
Sleep 502
send w
Sleep 682
send w
sleep 511
send {space}
sleep 687
send d
sleep 799
send {space}
sleep 17631 ;Waiting for Main Menu to load.
send s
sleep 653
send {space} ;Selecting start.
Sleep 943
send s
Sleep 723
send s
Sleep 623
send {space} ;Selecting solo.
Sleep 16347 ;Waiting for game to start.
gosub labelstart
}
;Eat, sleep, rave. Repeat.
^r::ExitApp ;Kills the script, if it goes haywire.
没关系,我完全搞砸了,现在我知道为什么了。感谢大家的帮助....
编辑:很好。
就像我在原著中所说的那样,整个剧本简直糟透了post。至于它有什么问题,没有这里任何人的帮助,即使我知道那里有人看到它并看到错误并决定不提供帮助。
IF 语句和 Searchimage 设置在错误的 { } 中。因为在整个脚本构建中毫无意义,它甚至开始工作都是一个奇迹。
对于初学者来说,这是它应该看起来的样子。
ImageSearch pointX, pointY, 0, 0, 1920, 1080, *125 C:\Users\ICECOLD\Desktop\new_test\Starport_services.bmp ;Can we see starport services?
{
sleep 150
If ErrorLevel = 1 ; If it CAN'T find Starport Services, it will look for Mission Board instead.
{
sleep 150
ImageSearch pointX2, pointY2, 0, 0, 1920, 1080, *100 C:\Users\ICECOLD\Desktop\new_test\Mission_Board.bmp ;Can we see Mission Board?
if ErrorLevel = 1 ;If it CAN'T find mission board, it will ask for it.
{
MsgBox, 48, Something went wrong!, I can't find "Mission Board" or "Starport Services" anywhere.
MsgBox, 4132, Something went wrong!, Do you wish to retry?
IfMsgBox Yes
{
MsgBox, 4160, Restarting, Click OK and switch back to game with "Starport Services" Open!! `n(YOU GET 15 SECONDS TIME)
sleep 15000
gosub labelstart
ExitApp
If ErrorLevel = 0 ;If it finds Mission Board it will navigate to the Mission Board.
{
Sleep 143
SendEvent s
Sleep 177
SendEvent {Space}
sleep 10000
gosub LabelMissionBoard
If ErrorLevel = 0 ;If it finds Starport services it will navigate to the Mission Board.
{
Sleep 200
SendEvent {space}
sleep 15234
SendEvent s
sleep 134
SendEvent {Space}
sleep 10000
} gosub LabelMissionBoard
}
}
}
}
}
正如您在上面的代码中看到的,与我最初 post 编写的代码的开头相反。它同时发生了多件事,所以它没有在找到图像后停止,而是继续前进,无论如何,它没有按下按钮只计算 'sleep' 不管出于什么原因,我有没有 f&^*( 线索,因为我在这一点上基本上是一个初学者。不过是一个咸的。所以这是你该死的答案,现在对不起,我再也不会回到这里了。