huan51415 Posted July 11, 2023 Share Posted July 11, 2023 Hi All, Hello everyone, I would like to ask, currently I want to use Autoit to write "Windows ADK Fast Startup" Autoit Test, but I don't know how to prevent the script from closing when Windows ADK Fast Startup is executed, or how to save the current state of the script before execution, and continue execution from the saved state after Windows ADK execution is completed. Is there a good person who is willing to provide a script for me to learn from, thank you very much. Link to comment Share on other sites More sharing options...
argumentum Posted July 11, 2023 Share Posted July 11, 2023 read about OnAutoItExitRegister(). huan51415 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
huan51415 Posted July 11, 2023 Author Share Posted July 11, 2023 Thank you for your reply, I will try to study it, but if possible, is there an example, I don't understand how to apply this command. Link to comment Share on other sites More sharing options...
argumentum Posted July 11, 2023 Share Posted July 11, 2023 ok, I don't have an environment to play around with this but try _WinAPI_GetSystemPowerStatus(). Let me know if it worked. huan51415 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted July 11, 2023 Share Posted July 11, 2023 3 hours ago, huan51415 said: I don't know how to prevent the script from closing you should not prevent the script from closing but in the 1st example it shows that you can save whatever setting you'd like to save from that function. Unless you go into detail of what are you upto, this is all I'm gonna do. huan51415 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
huan51415 Posted July 11, 2023 Author Share Posted July 11, 2023 1 hour ago, argumentum said: you should not prevent the script from closing but in the 1st example it shows that you can save whatever setting you'd like to save from that function. Unless you go into detail of what are you upto, this is all I'm gonna do. Hello argumentum, I am inquiring about the usage of OnAutoItExitRegister(), but I still don’t know much about it, and I haven’t found relevant examples. Can you help explain the usage of OnAutoItExitRegister() in detail, sincere thanks. Link to comment Share on other sites More sharing options...
Andreik Posted July 11, 2023 Share Posted July 11, 2023 (edited) This is a basic prototype: ; Program starts here ; Maybe you want to check and load saved stuffs here OnStart() OnAutoItExitRegister('OnExit') ; Press ESC to exit the program HotKeySet('{ESC}', 'Quit') ; Program code here ; ... ; Main loop to keep the program running While True Sleep(10) WEnd Func Quit() Exit EndFunc Func OnExit() ConsoleWrite('The program will close soon.' & @CRLF) ; Do your save stuffs here EndFunc Func OnStart() ConsoleWrite('The program just started.' & @CRLF) ; Do your load stuffs here EndFunc Edited July 11, 2023 by Andreik huan51415 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
huan51415 Posted July 12, 2023 Author Share Posted July 12, 2023 11 hours ago, Andreik said: This is a basic prototype: ; Program starts here ; Maybe you want to check and load saved stuffs here OnStart() OnAutoItExitRegister('OnExit') ; Press ESC to exit the program HotKeySet('{ESC}', 'Quit') ; Program code here ; ... ; Main loop to keep the program running While True Sleep(10) WEnd Func Quit() Exit EndFunc Func OnExit() ConsoleWrite('The program will close soon.' & @CRLF) ; Do your save stuffs here EndFunc Func OnStart() ConsoleWrite('The program just started.' & @CRLF) ; Do your load stuffs here EndFunc Thanks for the great help, I'll try and see if it helps me. In addition, I would like to ask, if I want to set a storage point for a certain paragraph in the script, so that I can return to this storage point and continue to execute the script, how should I do it? Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2023 Share Posted July 12, 2023 I am not sure what do you mean by storage point and script paragraphs. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
huan51415 Posted July 12, 2023 Author Share Posted July 12, 2023 23 minutes ago, Andreik said: I am not sure what do you mean by storage point and script paragraphs. Let's take an example: ; Program starts here ; Maybe you want to check and load saved stuffs here OnStart() ;------save point OnAutoItExitRegister('OnExit') ; Press ESC to exit the program HotKeySet('{ESC}', 'Quit') ; Program code here ; ... ;------back to save point ; Main loop to keep the program running While True Sleep(10) WEnd Func Quit() Exit EndFunc Func OnExit() ConsoleWrite('The program will close soon.' & @CRLF) ; Do your save stuffs here EndFunc Func OnStart() ConsoleWrite('The program just started.' & @CRLF) ; Do your load stuffs here EndFunc ;------back to save point li ke this Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2023 Share Posted July 12, 2023 Ok, but what kind of information do you want to save/load? Give me an example. huan51415 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
huan51415 Posted July 12, 2023 Author Share Posted July 12, 2023 1 hour ago, Andreik said: Ok, but what kind of information do you want to save/load? Give me an example. I need to judge that if the script execution is interrupted in the middle, I can continue execution from where it was interrupted. Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2023 Share Posted July 12, 2023 I don't know very much about Windows ADK so I can't help you unless you detail about what script are you talking about, what it's suppose to do and how would you normally detect if it's interrupted. Then we can find a solution with AutoIt. huan51415 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
spudw2k Posted July 12, 2023 Share Posted July 12, 2023 I imagine that you can have "steps" in your script, and a file which tracks which steps or the last step in the process the script has performed. If this is part of an imaging process or some sort of task sequence, then you could log to either the local disk--if appropriate--or to a share folder. huan51415 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
huan51415 Posted July 12, 2023 Author Share Posted July 12, 2023 Windows ADK Fast startup will restart the OS multiple times and calculate the data at boot time, but I need to continue to execute the script after Windows ADK Fast startup is executed. Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2023 Share Posted July 12, 2023 (edited) I still don't get where is AutoIt involved and what it's suppose to do. Is your AutoIt script related to Windows ADK or you simply want to run an AutoIt script after windows boot up and continue from where it was when windows shutdown? Edited July 12, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
rsn Posted July 12, 2023 Share Posted July 12, 2023 It sounds like the goal is to write a benchmarking/processing/optimizing app in AutoIt for the evaluation of fast startup tests using the Windows Assessment Toolkit/Console. That sounds like a huge undertaking if you don't have reasonable command of the scripting language or how to articulate the process and goals of the script. Link to comment Share on other sites More sharing options...
huan51415 Posted July 13, 2023 Author Share Posted July 13, 2023 13 hours ago, Andreik said: I still don't get where is AutoIt involved and what it's suppose to do. Is your AutoIt script related to Windows ADK or you simply want to run an AutoIt script after windows boot up and continue from where it was when windows shutdown? Yes, I simply want to run an AutoIt script after windows boot up and continue from where it was when windows shutdown. Link to comment Share on other sites More sharing options...
Andreik Posted July 13, 2023 Share Posted July 13, 2023 (edited) It depends what kind of data do you want to save but here is a simple prototype. Basically I keep update the value of a variable named counter and save it's content when the program is closed due to windows restart/shutdown or the program is closed using tray icon. When the program is run after restart it will continue to count from the value previously saved. expandcollapse popup; Program starts here OnAutoItExitRegister('OnExit') ; Press ESC to exit the program HotKeySet('{ESC}', 'Quit') ; Program code here Global $iCount = 0 ; Maybe you want to check and load saved stuffs here OnStart() ; Main loop to keep the program running While True $iCount += 1 Sleep(10) WEnd Func Quit() Exit EndFunc Func OnExit() ConsoleWrite('The program will close soon.' & @CRLF) ; Program will end soon, let's save our counter variable ConsoleWrite('Current count value: ' & $iCount & @CRLF) Local $hFile = FileOpen('current_state.dat', 2) FileWrite($hFile, $iCount) FileClose($hFile) EndFunc Func OnStart() ConsoleWrite('The program just started.' & @CRLF) ; Let's check if we have a file that saved out counter variable If FileExists(@ScriptDir & '\current_state.dat') Then $iCount = FileRead(@ScriptDir & '\current_state.dat') ConsoleWrite('I will continue from ' & $iCount & @CRLF) Else ConsoleWrite('There is no previous state saved.' & @CRLF) EndIf EndFunc This is a basic example but if you have more complex tasks like data received over TCP or some kind of data processing it' important to know what do you want and need to save in order to continue the task. In case of TCP there might be some wasted data so it would be useful to define specific save points in your code. When your program reach certain points you can save the current state. For saving current state I used a dat file but you can use ini files if it's more suitable for your case. Edit: if your program is suppose to restart automatically after windows restart, probably it should be registered as a service. Edited July 13, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
huan51415 Posted July 14, 2023 Author Share Posted July 14, 2023 Thank you for your help. I have some ideas and experiments are underway. I will reply if there is any progress. 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