Jump to content

Start UP Process


anixon
 Share

Recommended Posts

I was new to AutoIT in November 2006 (my experience was limited to scripting in Excel) and had a few Ideas as to what processes I would like to code.

I would like to thank all those persons who over the last months have helped me with code examples and advice by responding to my many and varied requests for assistance (General Help and Support). I am sure that you all know who you are and thank you again for getting me thus far.

Whilst the code snippets I have listed might not be that sophisticated it may be of help to those who are grappling with how to get to some of AutoIT's features. For me they represents many hours of effort reading, experimenting, testing, seeking assitance and the like.

every minute spent has been a dare I overstate it by saying fantastic experience.

In recent times I have come to realise that AutoIT is a very powerful and sophisticated programming tool.

AND OF COURSE I DONT GUARANTEE THAT ANY OF THE CODE WORKS.

Cheers Ant.. :whistle:

CODE
;A Startup Process

;

;A Nixon March 2007

;Include routine for Encryption/De-encryption Processing

;

#include<String.au3>

;Include Date Time processing

;

#include <Date.au3>

;Include Network processing

;

#include <Inet.au3>

;Numlock OFF

;

Send("{NUMLOCK off}")

;Set Stealthy Mode

;

Opt("TrayIconHide", 1)

;Break Key Disabled (Cannot Ctrl Break to Quit)

;

Break(0)

;Set a variable

;

Global $message = ""

;Error Message Box Subroutine

;

Func DisplayMessage()

splashTextOn("YOUR TITLE", " " & $message , 325, 50, 600, 500, 36, "times new roman", 10, 600)

Sleep(5000)

splashOff()

EndFunc

;Beep on a Process Error Subroutine

;

Func beep()

For $i = 4 to 1 Step -1

Beep(500,50)

Sleep(100)

Next

EndFunc

; Log file subroutine

;

Func WriteLog()

$file = FileOpen(@scriptdir & "\logfiles\" & (@yday) & "Log.txt", 9)

filewriteline($file, "---------------------------------------------------")

filewriteline($file, $logtext & (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC))

filewriteline($file, "---------------------------------------------------")

filewriteline($file, "")

FileClose($file)

EndFunc

;Nominate Progams to close should should they be running

;

Global $file[4] = ["abc.exe","def.exe","ghi.exe"]

For $i = 0 to UBound($file) - 1

_closePROG($file[$i])

Next

Func _closePROG($filename)

$PID = ProcessExists($filename)

If $PID Then ProcessClose($PID)

EndFunc

; Check that the INI files exist for the process/s about to be run.

;

Global $file[3] = ["\inifiles\tuv.ini","\inifiles\wyz.ini"]

For $i = 0 to UBound($file) - 1

_runINI($file[$i])

Next

Func _runINI($filename)

If Not FileExists(@ScriptDir & $filename) Then

plbeep()

$message = $filename & " FILE NOT PRESENT"

DisplayMessage()

Exit ; or call a routine

EndIf

EndFunc

;Check that the Progams Exist for the process/s about to be run.

;

Global $file[4] = ["\abc.*","\def.*","\ghi.*"]

For $i = 0 to UBound($file) - 1

_runPROG($file[$i])

Next

Func _runPROG($filename)

If Not FileExists(@ScriptDir & $filename) Then

plbeep()

$message = $filename & " FILE NOT PRESENT"

DisplayMessage()

Exit ; or call a routine

EndIf

EndFunc

;Check for Network Connectivity and set the INI file activity flags

;

While 1

$IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)

If $iscon[0] = 0 then

$logtext = "No Network"

writelog()

IniWrite(@scriptdir & "\inifiles\abc.ini", "monitor", "network", "0") ;Network not present flag

ExitLoop

Else

$PublicIP = _GetIP()

$logtext = "Network " & $plublicIP

writelog()

IniWrite(@scriptdir & "\inifiles\abc.ini", "monitor", "network", "1") ;Network present flag

ExitLoop

EndIf

WEnd

;Check that the registered (INI File) USB Key is mounted and set the INI key present/not present flags

;

While 1

$drive = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\abc.ini", "usb", "drive", "0"), "password", 1))

$key = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\abc.ini", "usb", "key", "0"), "password", 1))

$type = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\abc.ini", "usb", "type", "0"), "password", 1))

$driveT = DriveGetType($drive)

$serialno = DriveGetSerial($drive)

If $serialno <> $key and $type <> $driveT Then

$logtext = "No USB KEY"

writelog()

IniWrite(@scriptdir & "\inifiles\abc.ini", "monitor", "usbadapter", "0") ;USB Key Not Mounted Flag

ExitLoop

Else

$logtext = "USB Key Present"

writelog()

IniWrite(@scriptdir & "\inifiles\abc.ini", "monitor", "usbadapter", "1") ;USB Key Mounted Flag

ExitLoop

EndIf

WEnd

;

;Run your process code from here

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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