Jump to content

Wake on Lan Skript


joehittn
 Share

Recommended Posts

my attempt:

i wanted to make a gui button to run a function, which contains another funciton...

; Arbeitsvariablen
Global $i

; Variablen - Workstationbezeichnungen (IPs)
#include <Array.au3>
Global $CompArray[26]
$CompArray[1] = "r15"
.....


; Variablen - MAC-Adressen
#include <Array.au3>
Global $MacArray[26]
$MacArray[1] = "00:04:76:8E:41:2D"
.....


GUI-stuff...

GUICtrlSetOnEvent($Button1, "Wakeup_all_schleife")



; Functions
Func Wakeup_all_schleife ()
for $i = 1 to 2
    Wakeup_all ()
Next
Exit
EndFunc


Func Wakeup_all ()
    sleep (500)
    send ("#r", 0)
    sleep (500)
    send ("cmd", 0)
    sleep (500)
    send ("{enter}")    
    sleep (500)
    send("Z:")
    send ("{enter}")
    send("cd Z:\temp\aktuelles\")
    sleep (500)
    send ("{enter}")
    send ("wolcmd " & $MacArray[$i] & " " & $CompArray[$i] & " 255.255.255.0 80", 1)
    send ("{enter}")
    sleep (2000)
    WinClose("Untitled - Notepad", "")
EndFunc

i guess its a problem with the $i variable used in the for-loop, which cant be used afterwards in the function, but aehm, i dont know why that is and how i could get around this...

thnx in advance,

joehittn

Link to comment
Share on other sites

The For keyword automatically declares a local variable, I believe, so the For/Next is working with the local $i but your second function is using the global one. Just dump the global and pass the variable as a parameter:

; Functions
Func Wakeup_all_schleife ()
    for $i = 1 to 2
        Wakeup_all ($i)
    Next
    Exit
EndFunc

Func Wakeup_all ($n)

    ; ...

    send ("wolcmd " & $MacArray[$n] & " " & $CompArray[$n] & " 255.255.255.0 80", 1)
    send ("{enter}")
    sleep (2000)
    WinClose("Untitled - Notepad", "")
EndFunc

You don't have to rename the variable from $i to $n in the second function, I just did it to enphasize what was being done.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well of course... you could do something like this:

Func Wakeup_all_schleife ()
for $i = 1 to 2
    Wakeup_all ($i)
Next
Exit
EndFunc


Func Wakeup_all ($a)
    sleep (500)
    send ("#r", 0)
    sleep (500)
    send ("cmd", 0)
    sleep (500)
    send ("{enter}")    
    sleep (500)
    send("Z:")
    send ("{enter}")
    send("cd Z:\temp\aktuelles\")
    sleep (500)
    send ("{enter}")
    send ("wolcmd " & $MacArray[$a] & " " & $CompArray[$a] & " 255.255.255.0 80", 1)
    send ("{enter}")
    sleep (2000)
    WinClose("Untitled - Notepad", "")
EndFunc

-edit-

Listen to the penguin!

Edited by Nahuel
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...