Jump to content

Need A Little Help With My Script


Recommended Posts

I'm sure this is covered in help or on here, but I haven't been able to find after looking most of the weekend.

I simply need a way to set the script to pause for 10 seconds before moving on to the next line. It is disabling/renabling my net connection and I need to give it time to acquire the IP address before continuing.

Link to comment
Share on other sites

  • Moderators

I'm sure this is covered in help or on here, but I haven't been able to find after looking most of the weekend.

I simply need a way to set the script to pause for 10 seconds before moving on to the next line. It is disabling/renabling my net connection and I need to give it time to acquire the IP address before continuing.

Sleep(10000)

Edit:

Now if you are trying to get the script to do something while it's pausing (like establish the IP), it's best to show us how your doing it for a more practical answer than the one I gave.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Sleep(10000)

Edit:

Now if you are trying to get the script to do something while it's pausing (like establish the IP), it's best to show us how your doing it for a more practical answer than the one I gave.

It dosen't need to do anything while it's pausing as windows does the ip work on it's own. Thanks for the help!

Link to comment
Share on other sites

It dosen't need to do anything while it's pausing as windows does the ip work on it's own. Thanks for the help!

I'd have thought that

while Ping("your gateway IP address",250) = 0
;do nothing
wend

would be quicker and more robust, assuming the computer you're configuing is on a network of course.

Edited by sjorrel
Link to comment
Share on other sites

I'd have thought that

while Ping("your gateway IP address",250) = 0
;do nothing
wend

would be quicker and more robust, assuming the computer you're configuing is on a network of course.

That would work if I was using using batch do most of the work. Right now all my script does is pull the current mac address from a file and paste it into a batch file, which it then executes.. here is the code

;-----------------------------------------------------------------------------
; backup bandwidth monitor pro logs
;-----------------------------------------------------------------------------
DirCopy("\Program Files\Bandwidth Monitor Pro\Stats", "\backup\bmp_logs", 1)

;-----------------------------------------------------------------------------
; close bandwidth monitor pro
;-----------------------------------------------------------------------------
; not completed

;-----------------------------------------------------------------------------
; find the current mac address via batch
;-----------------------------------------------------------------------------
RunWait("\batch\current_mac.bat")


;-----------------------------------------------------------------------------
; find and copy results from ipconfig_results.txt routine
;-----------------------------------------------------------------------------
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
WinSetOnTop("Untitled - Notepad", "", 1)
Send("^o")
WinSetOnTop("Open", "", 1)
Send("\current\ipconfig_results.txt{ENTER}")
WinSetOnTop("ipconfig_results.txt - Notepad", "", 1)
Send("^f")
WinSetOnTop("Find", "", 1)
Send("00-01-05{ENTER}")
WinSetOnTop("Find", "", 1)
Send("{TAB 4}{ENTER}{LEFT 5}")
Send("{BS}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}")
Send("{SHIFTDOWN}{LEFT 17}{SHIFTUP}")
Send("^c!fx")
WinWaitActive("Notepad")
Send("!n")

;-----------------------------------------------------------------------------
; paste current mac address into change_mac.bat batch file
;-----------------------------------------------------------------------------
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
WinSetOnTop("Untitled - Notepad", "", 1)
Send("^o")
WinSetOnTop("Open", "", 1)
Send("\batch\change_mac.bat{ENTER}")
WinWaitActive("change_mac.bat - Notepad")
Send("^f")
Send("set var3={ENTER}{TAB 4}{ENTER}")
Send("{LEFT}{RIGHT}{SHIFTDOWN}{RIGHT 17}{SHIFTUP}")
Send("^v!fx")
WinWaitActive("Notepad")
Send("!y")

;-----------------------------------------------------------------------------
; execute change_mac.bat and finish
;-----------------------------------------------------------------------------
RunWait("\batch\change_mac.bat")

;-----------------------------------------------------------------------------
; wait 10 seconds before re-opening bandwidth monitor pro
;-----------------------------------------------------------------------------
Sleep(10000)

;-----------------------------------------------------------------------------
; restart bandwith monitor pro
;-----------------------------------------------------------------------------
; not completed

;-----------------------------------------------------------------------------
; display textbox informing of mac address change
;-----------------------------------------------------------------------------
MsgBox(64, ""Mac address has been changed!")

I know there are much better ways to do this, and as I get more proficent with autoit I will move away from using batch. Right now the script get the mac address from ipconfig /all and then copy/paste the current mac into the below batch as var3, then it executes the batch. The end of the batch disables/reanables the network connection. If I follow your logic above, I would have to put the subnet in. Unfortunally the subnet changes each time I change the mac address.

Here is the batch file.

REM -enter mac addresses below, with no hyphens
REM -there must be 10 registered mac addresses
REM -must be in ALL CAPS!!!! 
REM -EXAMPLE: set mac0=mac_address_here
REM -EXAMPLE: set mac0=00:11:22:33:44:55:66

set mac0=
set mac1=
set mac2=
set mac3=
set mac4=
set mac5=
set mac6=
set mac7=
set mac8=
set mac9=



REM -set device ID below
REM -EXAMPLE: set var2=0009
set var1=

REM -set network connection hardware ID
set var2=


REM -----------------------------------------------
REM --= DO NOT CHANGE ANYTHING BELOW THIS POINT =--
REM -----------------------------------------------



REM -current mac varible
set var3=

IF "%var3%" == "%mac0%" GOTO set_mac_1
IF "%var3%" == "%mac1%" GOTO set_mac_2
IF "%var3%" == "%mac2%" GOTO set_mac_3
IF "%var3%" == "%mac3%" GOTO set_mac_4
IF "%var3%" == "%mac4%" GOTO set_mac_5
IF "%var3%" == "%mac5%" GOTO set_mac_6
IF "%var3%" == "%mac6%" GOTO set_mac_7
IF "%var3%" == "%mac7%" GOTO set_mac_8
IF "%var3%" == "%mac8%" GOTO set_mac_9
IF "%var3%" == "%mac9%" GOTO set_mac_0

:set_mac_1
\smaccl\smaccl.exe -uid %var1% %mac1%
goto devcon
:set_mac_2
\smaccl\smaccl.exe -uid %var1% %mac2%
goto devcon
:set_mac_3
\smaccl\smaccl.exe -uid %var1% %mac3%
goto devcon
:set_mac_4
\smaccl\smaccl.exe -uid %var1% %mac4%
goto devcon
:set_mac_5
\smaccl\smaccl.exe -uid %var1% %mac5%
goto devcon
:set_mac_6
\smaccl\smaccl.exe -uid %var1% %mac6%
goto devcon
:set_mac_7
\smaccl\smaccl.exe -uid %var1% %mac7%
goto devcon
:set_mac_8
\smaccl\smaccl.exe -uid %var1% %mac8%
goto devcon
:set_mac_9
\smaccl\smaccl.exe -uid %var1% %mac9%
goto devcon
:set_mac_0
\smaccl\smaccl.exe -uid %var1% %mac0%
goto devcon

REM -devcon disable/re-enable routine
:devcon
devcon.exe disable =net %var2%
devcon.exe enable =net %var2%
Edited by schnikies79
Link to comment
Share on other sites

I wish you the best of luck, but honestly, the batch file could easily be incorporated into the AutoIt language. Since you wish to learn, I'll leave it to you to put it together, but I'd seriously read the help file on

Run()

RunWait()

The set_mac sections could be turned into a function

Function Set_Mac(ByVal $var3)
       RunWait('\smaccl\smaccl.exe -uid %var1% %mac' & $var3 & '%')
EndFunc

As well as other fun items. :think:

Take care and welcome to AutoIt!

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

I wish you the best of luck, but honestly, the batch file could easily be incorporated into the AutoIt language. Since you wish to learn, I'll leave it to you to put it together, but I'd seriously read the help file on

Run()

RunWait()

The set_mac sections could be turned into a function

Function Set_Mac(ByVal $var3)
       RunWait('\smaccl\smaccl.exe -uid %var1% %mac' & $var3 & '%')
EndFunc

As well as other fun items. :think:

Take care and welcome to AutoIt!

I'll read up on run and runwait. The script was orginally made in Macro Scheduler before I found autoit. I started looking around after I found out what it cost to get the compiler for Macro Scheduler. No matter though, autoit seems a lot nicer, I just have to learn it.

The above autoit script was thrown togethor in probally 30 mins or so after I got it and I haven't touched it since. I've been reading the help files and these forums and It's starting to make sense but I'm still having some problems. Not wanting to be that annoying new guy that asks about everything, I'm trying to learn it on my own. Great forum!

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...