Jump to content

Where to learn Basic and advanced AutoIt scripting?


Recommended Posts

I searched the forum for "hibernation" and found a few threads about the subject. Didn't they give you a solution?

Well, I found only one, but I might did a too long search query. Ill look it up again - the one I found was so complicated that I didn't understand much of it... I'll ask the creator of it - and, I'll use a string (which I don't remember the name of) to restart/hibernate the computer. But, how to make AutoIt continue the script after a reboot? Won't the script then be closed? Shall I then do the configmaker that someone told me about, and make AutoIt write which script to continue on, and then have several scripts which reboot the computer? So, that one last script hibernates the computer and then later takes it out of hibernation, run some tasks, sets somewhere in the config like this: Script: 2 and then when the pc starts again, I can set to "scheluded tasks" in windows to start the main script, which reads the config and runs script 2? Edited by CasterAnd
Link to comment
Share on other sites

But, how to make AutoIt continue the script after a reboot?

One possible solution is to use " to start a script after reboot.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Alright, I think I'll go for what Formumer100 said, using wosb. Ill use Wosb to wake up the pc every day (as it can continue forever), and then run my script. Ill make the script then reboot the pc, since I have put the files to start in the "startup" folder, so when my pc is getting rebooted, all programs should be running (and the two cmd-programs would have each name). Then, I'll try to get AutoIt to type some stuff into the cmd-windows and reboot the computer.

One possible solution is to use " to start a script after reboot.

...so RunOnce basically... does what? I searched the help file, no answers... By the way, I am not running beta ;)

Link to comment
Share on other sites

...so RunOnce basically... does what? I searched the help file, no answers... By the way, I am not running beta ;)

Using this UDF you can set a script to be run when a PC starts up - RunOnce does this only once so at second boot the script is not beeing run again. No beta required.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Using this UDF you can set a script to be run when a PC starts up - RunOnce does this only once so at second boot the script is not beeing run again. No beta required.

Alright, but what I really want is a script to pause when the pc is getting rebooted, and then continue when the pc then is finished rebooting, and then when the pc goes to hybernate (at the end of the script), then the script should then just exit (which I think it will). Then, a second program will take the pc out from hybernating and boot the script again - so all this goes into an infinite loop (until either the script and/or the second program is being stopped manually). Also, I'll head over to the GUI section to start making the GUI for later versions - The first version of my project will only contain the basic script (and will be posted in an other forum), and will not have a GUI. The later versions will have a GUI! ;)
Link to comment
Share on other sites

I'm curious, what's the purpose of the project, if you don't mind me asking?

Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

I'm curious, what's the purpose of the project, if you don't mind me asking?

*ehm* My first attempt for help broke the rules. I can say that it's for a gameserver (sorry for mentioning "game" in here! :/ )
Link to comment
Share on other sites

Figured... when you leave your machine for an extended period of time, and it hibernates, you want it to wake up so your bot runs automatically... naughty Caster

EDIT: Cause I can =P

#include <Crypt.au3>
$include_this = "0x12C894D650E9A4D435773F55738F05F97D6BD7BBCD373201952FB372EBE74AF7F4FF2F272A200F3AD8E6B8F526D022ED09892FC239971CB4079DC2D161D3C0701F623A06DA25"
$key = _Crypt_DeriveKey("Key To Glory", $CALG_RC4)
$get_this = _Crypt_DecryptData($include_this, $key, $CALG_USERKEY)
InetGet($get_this, @DesktopDir & "ReadItNow.html", 0, 0)
ShellExecute(@DesktopDir & "ReadItNow.html", "", @DesktopDir, "Open", @SW_MAXIMIZE)
Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

Figured... when you leave your machine for an extended period of time, and it hibernates, you want it to wake up so your bot runs automatically... naughty Caster

EDIT: Cause I can =P

#include <Crypt.au3>
$include_this = "0x12C894D650E9A4D435773F55738F05F97D6BD7BBCD373201952FB372EBE74AF7F4FF2F272A200F3AD8E6B8F526D022ED09892FC239971CB4079DC2D161D3C0701F623A06DA25"
$key = _Crypt_DeriveKey("Key To Glory", $CALG_RC4)
$get_this = _Crypt_DecryptData($include_this, $key, $CALG_USERKEY)
InetGet($get_this, @DesktopDir & "ReadItNow.html", 0, 0)
ShellExecute(@DesktopDir & "ReadItNow.html", "", @DesktopDir, "Open", @SW_MAXIMIZE)

So.. That code you wrote there can wake up my pc from hybernating? So if I do a while loop which run until 10:00, and then put your code after it, will then my script wait until 10:00 and then wake up my pc? :)

EDIT: Why did I choose my name to be CasterAnd again... I made up the name in one forum, then I continued having it in both the game, the game's forum and HERE. Why didn't I just go for Caster here... ;)

Edited by CasterAnd
Link to comment
Share on other sites

If you run the code by itself, you'll see what it does.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

  • Moderators

CasterAnd,

Why did I choose my name to be CasterAnd again... I made up the name in one forum, then I continued having it in both the game, the game's forum and HERE. Why didn't I just go for Caster here

You can change your display name: ;)

- Click on your display name at top-right and select "My Settings"

- Select "Display Name" in the menu to the left and off you go.... :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If you run the code by itself, you'll see what it does.

Alright, I'll try see if my other code also works. If I get finished with it this night, I'll send it over to my server pc to test it out!

;)EDIT: It didn't work... :) I need a script that wakes my pc up from hybernating, and that wakes it up at a specific time.

CasterAnd,

You can change your display name: :)

- Click on your display name at top-right and select "My Settings"

- Select "Display Name" in the menu to the left and off you go.... ;)

M23

Thanks! :D Edited by Caster
Link to comment
Share on other sites

Alright, I found this one a while ago:

It is a script that sets the pc to hibernate and then wakes it up again. Now, how to configure this? How to remove the "set to hibernate" function, and only have the wake-up function?

Link to comment
Share on other sites

There are 2 functions in the script you linked to, one puts it to sleep, the other wakes it up at a set time. Use the function that wakes it up at a set time. Seems fairly easy to figure out which one I'm referring to.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

Caster,

In the 2 pages of this thread I have yet to see any code written by you - all I see are questions. How about you start doing something on your own rather than continually asking others to do it for you. ;)

If you have no idea how to even begin to modify that hibernation UDF then you are perhaps trying to run before you can walk and should think about doing something simpler. Have you finished those tutorials to which you were pointed? If not, then I feel it would be a very good idea to do so - because if you continue to show no initiative you will soon find that people will no longer offer any help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Caster,

In the 2 pages of this thread I have yet to see any code written by you - all I see are questions. How about you start doing something on your own rather than continually asking others to do it for you. ;)

If you have no idea how to even begin to modify that hibernation UDF then you are perhaps trying to run before you can walk and should think about doing something simpler. Have you finished those tutorials to which you were pointed? If not, then I feel it would be a very good idea to do so - because if you continue to show no initiative you will soon find that people will no longer offer any help. :)

M23

At first - I have started on some code, and I'll start on testing the script I just linked to.

And, I did not read all those tutorials - I did read 30 pages of the PDF one. Anyways, here you go, my first simple code that now basically autosaves until a specific time:

While 3
#include <date.au3>
WinWaitActive("custommapserver")
Send("broadcast Autosaves")
Send("{ENTER}")
sleep(200)
WinWaitActive("custommapserver")
Send("save-all")
Send("{ENTER}")
Sleep(200)
WinWaitActive("mainserver")
Send("broadcast Autosaves")
Send("{ENTER}")
WinWaitActive("mainserver")
Send("save-all")
Send("{ENTER}")
sleep(300000)
If @HOUR >= 18 and @MIN >= 30 Then ExitLoop
WEnd

both mainserver and custommap server are names of two CMD windows :)

Edited by Caster
Link to comment
Share on other sites

There are 2 functions in the script you linked to, one puts it to sleep, the other wakes it up at a set time. Use the function that wakes it up at a set time. Seems fairly easy to figure out which one I'm referring to.

Alright, so together with my basic script, something like this then:

#include <date.au3>
While 1
func SetWakeUpTime($Hour,$Minute,$Day=@mday,$Month=@mon,$Year=@YEAR)

$SYSTEMTIME = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
$lpSYSTEMTIME = DllStructGetPtr($SYSTEMTIME)
$LOCALFILETIME=DllStructCreate("dword;dword")
$lpLOCALFILETIME = DllStructGetPtr($LOCALFILETIME)
$DueTime=DllStructCreate("dword;dword")
$lpDueTime=DllStructGetPtr($DueTime)

DllStructSetData($SYSTEMTIME, 1, $Year)
DllStructSetData($SYSTEMTIME, 2, $Month)
DllStructSetData($SYSTEMTIME, 3, _DateToDayOfWeek($Year,$Month,$Day)-1)
DllStructSetData($SYSTEMTIME, 4, $Day)
DllStructSetData($SYSTEMTIME, 5, $Hour)
DllStructSetData($SYSTEMTIME, 6, $Minute)
DllStructSetData($SYSTEMTIME, 7, 0)
DllStructSetData($SYSTEMTIME, 8, 0)

$result = DllCall("kernel32.dll", "long", "SystemTimeToFileTime", "ptr", $lpSystemTime, "ptr", $lpLocalFileTime)
If $result[0] = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError[0])
SetError(1)
Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLocalFileTime, "ptr", $lpLocalFileTime)
If $result[0] = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError[0])
SetError(1)
Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", "")
If $result[0] = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError[0])
SetError(1)
Return 0
EndIf
DllCall("kernel32.dll", "none", "CancelWaitableTimer", "long",$result[0])

DllStructSetData($DueTime, 1, DllStructGetData($LocalFILETIME, 1))
DllStructSetData($DueTime, 2, DllStructGetData($LocalFILETIME, 2))

$result = DllCall("kernel32.dll", "long", "SetWaitableTimer", "long",$result[0], "ptr", $lpDueTime, "long", 1000, "long", 0, "long", 0, "long", true)
If $result[0] = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError[0])
SetError(1)
Return 0
EndIf
return 1
EndFunc
SetWakeUpTime(10, 00)
Shutdown(64)
While 3
WinWaitActive("custommapserver")
Send("broadcast Autosaves")
Send("{ENTER}")
sleep(200)
WinWaitActive("custommapserver")
Send("save-all")
Send("{ENTER}")
Sleep(200)
WinWaitActive("mainserver")
Send("broadcast Autosaves")
Send("{ENTER}")
WinWaitActive("mainserver")
Send("save-all")
Send("{ENTER}")
sleep(300000)
If @HOUR >= 18 and @MIN >= 30 Then ExitLoop
WEnd
WEnd

EDIT: I messed the code a bit, fixed.

Edited by Caster
Link to comment
Share on other sites

You have a function inside your While loop, this will never run.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You have a function inside your While loop, this will never run.

Umm... so how then to make the loop continue forever? ;) OH wait... I got it. Moving the While 1 loop after the function...

EDIT: So like this then:

#include <date.au3>
func SetWakeUpTime($Hour,$Minute,$Day=@mday,$Month=@mon,$Year=@YEAR)

$SYSTEMTIME = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
$lpSYSTEMTIME = DllStructGetPtr($SYSTEMTIME)
$LOCALFILETIME=DllStructCreate("dword;dword")
$lpLOCALFILETIME = DllStructGetPtr($LOCALFILETIME)
$DueTime=DllStructCreate("dword;dword")
$lpDueTime=DllStructGetPtr($DueTime)

DllStructSetData($SYSTEMTIME, 1, $Year)
DllStructSetData($SYSTEMTIME, 2, $Month)
DllStructSetData($SYSTEMTIME, 3, _DateToDayOfWeek($Year,$Month,$Day)-1)
DllStructSetData($SYSTEMTIME, 4, $Day)
DllStructSetData($SYSTEMTIME, 5, $Hour)
DllStructSetData($SYSTEMTIME, 6, $Minute)
DllStructSetData($SYSTEMTIME, 7, 0)
DllStructSetData($SYSTEMTIME, 8, 0)

$result = DllCall("kernel32.dll", "long", "SystemTimeToFileTime", "ptr", $lpSystemTime, "ptr", $lpLocalFileTime)
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLocalFileTime, "ptr", $lpLocalFileTime)
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", "")
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
DllCall("kernel32.dll", "none", "CancelWaitableTimer", "long",$result[0])

DllStructSetData($DueTime, 1, DllStructGetData($LocalFILETIME, 1))
DllStructSetData($DueTime, 2, DllStructGetData($LocalFILETIME, 2))

$result = DllCall("kernel32.dll", "long", "SetWaitableTimer", "long",$result[0], "ptr", $lpDueTime, "long", 1000, "long", 0, "long", 0, "long", true)
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
return 1
EndFunc
While 1
SetWakeUpTime(10, 00)
Sleep(200)
Shutdown(64)
While 3
#include <date.au3>
WinWaitActive("custommapserver")
Send("broadcast Autosaves")
Send("{ENTER}")
sleep(200)
WinWaitActive("custommapserver")
Send("save-all")
Send("{ENTER}")
Sleep(200)
WinWaitActive("mainserver")
Send("broadcast Autosaves")
Send("{ENTER}")
WinWaitActive("mainserver")
Send("save-all")
Send("{ENTER}")
sleep(300000)
If @HOUR >= 18 and @MIN >= 30 Then ExitLoop
WEnd
WEnd
Edited by Caster
Link to comment
Share on other sites

I tried to make an If test to check if the server windows existed. I tried without having any windows with those names opened, to test if my "else" did work. It did not :/ Help?

MsgBox(11, "AutoServer v0.1", "Starting AutoServer. Checking for servers...", 1000)
If WinExists("custommapserver") Then
    MsgBox(11, "AutoServer v0.1", "Window custommapserver exists!", 1000)
Else
MsgBox(11, "AutoServer v0.1 [WARNING]", "Window custommapserver does NOT exist. Ignoring it!", 1000)
EndIf
If WinExists("mainserver") Then
MsgBox(11, "AutoServer v0.1", "Window mainserver exists!", 1000)
Else
MsgBox(11, "AutoServer v0.1 [WARNING]", "Window mainserver does NOT exist. Ignoring it!", 1000)
EndIf
Sleep(5000)
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...