1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Xenobiologist

Beiträge von Xenobiologist

  • Skripthilfe benötigt! Dualmonitor Autoumschaltung

    • Xenobiologist
    • 6. Januar 2008 um 02:39

    Hi,

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    HotKeySet("{ESC}", "_Exit")
    FileInstall("captdll.dll", "captdll.dll")
    $pic = @TempDir & "\dump_full.jpg"
    DllCall("captdll.dll", "int:cdecl", "CaptureScreen", "str", @TempDir & "\dump_full.jpg", "int", 300)
    If Not @error Then
    GUICreate("63^!~45<|we[>583{32}]", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUICtrlCreatePic($pic, 0, 0, @DesktopWidth + 10, @DesktopHeight + 2)
    GUISetState()
    WinSetOnTop("63^!~45<|we[>583{32}]", "", 1)
    SplashTextOn("", "Bitte Warten...ESC zum Abbruch", 260, 20, -1, -1, 1)
    DllCall('User32.dll', 'int', 'ShowCursor', 'int', False)
    EndIf
    ;~ DllCall('User32.dll', 'int', 'ShowCursor', 'int', False)
    Run("rundll32.exe shell32.dll,Control_RunDLL DESK.CPL", @WindowsDir, @SW_HIDE)
    WinWait("Eigenschaften von Anzeige", "", 500)
    If Not WinActive("Eigenschaften von Anzeige") Then WinActivate("Eigenschaften von Anzeige")
    Send("+^{TAB}")
    WinWait("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern")
    If Not WinActive("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern") Then WinActivate("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern")
    Send(2)
    If ControlCommand("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern", "Button4", "IsChecked", "") Then
    ControlCommand("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern", "Button4", "UnCheck", "")
    Else
    ControlCommand("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern", "Button4", "Check", "")
    EndIf
    ControlClick("Eigenschaften von Anzeige", "&Windows-Desktop auf diesem Monitor erweitern", "OK")
    Sleep(500)
    FileDelete($pic)
    Func _Exit()
    Exit
    EndFunc ;==>_Exit
    DirRemove(@TempDir & "\Screenshots", 1)
    Func DesktopScreenShot()
    Local $Quality = 100; Dateityp zum Speichern des Screenshots:
    DirCreate(@TempDir & "\Screenshots\")
    ; -1 steht für *.BMP
    ; 1-100 steht für Qualität des *.JPG
    If $Quality = -1 Then
    Local $SaveAs = ".bmp"
    Else
    Local $SaveAs = ".jpg"
    EndIf
    Local $CaptureDirectory = @TempDir & "\Screenshots\" ; Verzeichnis für die Screenshots
    Local $CaptureFile = "Desktop" & $SaveAs
    $ret = $CaptureDirectory & $CaptureFile
    $capt = DllOpen("captdll.dll")
    DllCall($capt, "int", "CaptureRegion", "str", $ret, "int", "0", "int", "0", "int", @DesktopWidth, "int", @DesktopHeight, "int", $Quality)
    DllClose($capt)
    ; $CaptureDirectory & $CaptureFile = zu speichernder Pfad und Name des Screenshots
    ; "0" = Links
    ; "0" = Oben
    ; @DesktopWidth = Breite
    ; @DesktopHeight = Höhe
    ; $Quality = BMP (-1) od. JPG (1-100)
    If @error Then
    $ret = 0
    SetError(1)
    EndIf
    Return $ret
    EndFunc ;==>DesktopScreenShot

    [/autoit]

    So long,

    Mega

  • Fehlermeldung bei ShellExecute unterdrücken

    • Xenobiologist
    • 6. Januar 2008 um 02:37

    Hi,

    wie möchtest du es denn jetzt genau haben?

    AVI Datei öffnen mit?
    a) auf dem System verknüpfte Anwendung
    b) einer bevorzugten Anwendung, falls sie auf dem Rechner vorhanden ist
    c) was passiert wenn avi nicht verknüpft ist

    ?

    So long,

    Mega

  • Hilfe beim Script

    • Xenobiologist
    • 6. Januar 2008 um 02:31

    Hi,

    kannst du die Probleme etwas anschaulicher machen. Ich habe keine Lust alle Links zu beusuchen und den Quelltext zu analysieren um dein Problem zu verstehen.

    So long,

    Mega

  • AutoIt-Gruppe im StudiVZ

    • Xenobiologist
    • 4. Januar 2008 um 17:04

    Mitglied

    So long,

    Mega

  • Dienst

    • Xenobiologist
    • 4. Januar 2008 um 15:10

    Hi,

    ich habe dein Skript nicht getestet, aber ich habe bei mir

    ShellExecute('notepad', '', @WindowsDir)

    unter dem Beep und das funktioniert auch. Du musst das Skript kompilieren und dann starten!

    und löschen dann kannst du dann mit

    [autoit]

    #include "ServiceControl.au3"
    $servicename = "MegaService"
    ConsoleWrite(_DeleteService("", $servicename) & @CRLF)

    [/autoit]

    So long,

    Mega

  • text in memory füllen

    • Xenobiologist
    • 4. Januar 2008 um 14:56

    Hi,

    meine Frage zielte eher dahin, ob du es einfach nur asuprobieren willst, oder ob du einen Grund hast warum aus zwei nicht ein Skript werden kann.

    So long,

    Mega

  • OrganizeIncludes

    • Xenobiologist
    • 4. Januar 2008 um 02:40

    HI,

    update siehe 1st post.

    So long,

    Mega

  • text in memory füllen

    • Xenobiologist
    • 4. Januar 2008 um 00:45

    Hi,

    die 2 Autoit-Skripte sollen sich über den Speicher Daten teilen? Warum ?

    So long,

    Mega

  • langes Fenster in ein Bild capturen

    • Xenobiologist
    • 4. Januar 2008 um 00:43

    Hi,

    welchen Brwoser willst du denn nutzen? Welche Seite könnte ich als Test nehmen?

    So long,

    Mega

  • ControlSend kein Text und keine ID

    • Xenobiologist
    • 4. Januar 2008 um 00:41

    Hi,

    einfach immer "" schreiben für die Parameter die du nicht hast.

    So long,

    Mega

  • Dienst

    • Xenobiologist
    • 3. Januar 2008 um 20:24

    HI,

    na siehste. :D

    So long,

    Mega

  • Dienst

    • Xenobiologist
    • 3. Januar 2008 um 17:01

    Hi,

    ich habe:

    Spoiler anzeigen
    [autoit]

    Global $STANDARD_RIGHTS_REQUIRED = 0x000F0000

    [/autoit] [autoit][/autoit] [autoit]

    ; Service Control Manager access types
    Global $SC_MANAGER_CONNECT = 0x0001
    Global $SC_MANAGER_CREATE_SERVICE = 0x0002
    Global $SC_MANAGER_ENUMERATE_SERVICE = 0x0004
    Global $SC_MANAGER_LOCK = 0x0008
    Global $SC_MANAGER_QUERY_LOCK_STATUS = 0x0010
    Global $SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020

    [/autoit] [autoit][/autoit] [autoit]

    Global $SC_MANAGER_ALL_ACCESS = BitOR($STANDARD_RIGHTS_REQUIRED, _
    $SC_MANAGER_CONNECT, _
    $SC_MANAGER_CREATE_SERVICE, _
    $SC_MANAGER_ENUMERATE_SERVICE, _
    $SC_MANAGER_LOCK, _
    $SC_MANAGER_QUERY_LOCK_STATUS, _
    $SC_MANAGER_MODIFY_BOOT_CONFIG)

    [/autoit] [autoit][/autoit] [autoit]

    ; Service access types
    Global $SERVICE_QUERY_CONFIG = 0x0001
    Global $SERVICE_CHANGE_CONFIG = 0x0002
    Global $SERVICE_QUERY_STATUS = 0x0004
    Global $SERVICE_ENUMERATE_DEPENDENTS = 0x0008
    Global $SERVICE_START = 0x0010
    Global $SERVICE_STOP = 0x0020
    Global $SERVICE_PAUSE_CONTINUE = 0x0040
    Global $SERVICE_INTERROGATE = 0x0080
    Global $SERVICE_USER_DEFINED_CONTROL = 0x0100

    [/autoit] [autoit][/autoit] [autoit]

    Global $SERVICE_ALL_ACCESS = BitOR($STANDARD_RIGHTS_REQUIRED, _
    $SERVICE_QUERY_CONFIG, _
    $SERVICE_CHANGE_CONFIG, _
    $SERVICE_QUERY_STATUS, _
    $SERVICE_ENUMERATE_DEPENDENTS, _
    $SERVICE_START, _
    $SERVICE_STOP, _
    $SERVICE_PAUSE_CONTINUE, _
    $SERVICE_INTERROGATE, _
    $SERVICE_USER_DEFINED_CONTROL)

    [/autoit] [autoit][/autoit] [autoit]

    ; Service controls
    Global $SERVICE_CONTROL_STOP = 0x00000001
    Global $SERVICE_CONTROL_PAUSE = 0x00000002
    Global $SERVICE_CONTROL_CONTINUE = 0x00000003
    Global $SERVICE_CONTROL_INTERROGATE = 0x00000004
    Global $SERVICE_CONTROL_SHUTDOWN = 0x00000005
    Global $SERVICE_CONTROL_PARAMCHANGE = 0x00000006
    Global $SERVICE_CONTROL_NETBINDADD = 0x00000007
    Global $SERVICE_CONTROL_NETBINDREMOVE = 0x00000008
    Global $SERVICE_CONTROL_NETBINDENABLE = 0x00000009
    Global $SERVICE_CONTROL_NETBINDDISABLE = 0x0000000A
    Global $SERVICE_CONTROL_DEVICEEVENT = 0x0000000B
    Global $SERVICE_CONTROL_HARDWAREPROFILECHANGE = 0x0000000C
    Global $SERVICE_CONTROL_POWEREVENT = 0x0000000D
    Global $SERVICE_CONTROL_SESSIONCHANGE = 0x0000000E

    [/autoit] [autoit][/autoit] [autoit]

    ; Service types
    Global $SERVICE_KERNEL_DRIVER = 0x00000001
    Global $SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
    Global $SERVICE_ADAPTER = 0x00000004
    Global $SERVICE_RECOGNIZER_DRIVER = 0x00000008
    Global $SERVICE_DRIVER = BitOR($SERVICE_KERNEL_DRIVER, _
    $SERVICE_FILE_SYSTEM_DRIVER, _
    $SERVICE_RECOGNIZER_DRIVER)
    Global $SERVICE_WIN32_OWN_PROCESS = 0x00000010
    Global $SERVICE_WIN32_SHARE_PROCESS = 0x00000020
    Global $SERVICE_WIN32 = BitOR($SERVICE_WIN32_OWN_PROCESS, _
    $SERVICE_WIN32_SHARE_PROCESS)
    Global $SERVICE_INTERACTIVE_PROCESS = 0x00000100
    Global $SERVICE_TYPE_ALL = BitOR($SERVICE_WIN32, _
    $SERVICE_ADAPTER, _
    $SERVICE_DRIVER, _
    $SERVICE_INTERACTIVE_PROCESS)

    [/autoit] [autoit][/autoit] [autoit]

    ; Service start types
    Global $SERVICE_BOOT_START = 0x00000000
    Global $SERVICE_SYSTEM_START = 0x00000001
    Global $SERVICE_AUTO_START = 0x00000002
    Global $SERVICE_DEMAND_START = 0x00000003
    Global $SERVICE_DISABLED = 0x00000004

    [/autoit] [autoit][/autoit] [autoit]

    ; Service error control
    Global $SERVICE_ERROR_IGNORE = 0x00000000
    Global $SERVICE_ERROR_NORMAL = 0x00000001
    Global $SERVICE_ERROR_SEVERE = 0x00000002
    Global $SERVICE_ERROR_CRITICAL = 0x00000003

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: Starts a service on a computer
    ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used
    ; $sServiceName - name of the service to start
    ; Requirements: None
    ; Return Values: On Success - 1
    ; On Failure - 0 and @error is set to extended Windows error code
    ; Note: This function does not check to see if the service has started successfully
    ;===============================================================================
    Func _StartService($sComputerName, $sServiceName)
    Local $hAdvapi32
    Local $hKernel32
    Local $arRet
    Local $hSC
    Local $hService
    Local $lError = -1

    [/autoit] [autoit][/autoit] [autoit]

    $hAdvapi32 = DllOpen("advapi32.dll")
    If $hAdvapi32 = -1 Then Return 0
    $hKernel32 = DllOpen("kernel32.dll")
    If $hKernel32 = -1 Then Return 0
    $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
    "str", $sComputerName, _
    "str", "ServicesActive", _
    "long", $SC_MANAGER_CONNECT)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hSC = $arRet[0]
    $arRet = DllCall($hAdvapi32, "long", "OpenService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "long", $SERVICE_START)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hService = $arRet[0]
    $arRet = DllCall($hAdvapi32, "int", "StartService", _
    "long", $hService, _
    "long", 0, _
    "str", "")
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hService)
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
    EndIf
    DllClose($hAdvapi32)
    DllClose($hKernel32)
    If $lError <> -1 Then
    SetError($lError)
    Return 0
    EndIf
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: Stops a service on a computer
    ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used
    ; $sServiceName - name of the service to stop
    ; Requirements: None
    ; Return Values: On Success - 1
    ; On Failure - 0 and @error is set to extended Windows error code
    ; Note: This function does not check to see if the service has stopped successfully
    ;===============================================================================
    Func _StopService($sComputerName, $sServiceName)
    Local $hAdvapi32
    Local $hKernel32
    Local $arRet
    Local $hSC
    Local $hService
    Local $lError = -1

    [/autoit] [autoit][/autoit] [autoit]

    $hAdvapi32 = DllOpen("advapi32.dll")
    If $hAdvapi32 = -1 Then Return 0
    $hKernel32 = DllOpen("kernel32.dll")
    If $hKernel32 = -1 Then Return 0
    $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
    "str", $sComputerName, _
    "str", "ServicesActive", _
    "long", $SC_MANAGER_CONNECT)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hSC = $arRet[0]
    $arRet = DllCall($hAdvapi32, "long", "OpenService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "long", $SERVICE_STOP)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hService = $arRet[0]
    $arRet = DllCall($hAdvapi32, "int", "ControlService", _
    "long", $hService, _
    "long", $SERVICE_CONTROL_STOP, _
    "str", "")
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hService)
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
    EndIf
    DllClose($hAdvapi32)
    DllClose($hKernel32)
    If $lError <> -1 Then
    SetError($lError)
    Return 0
    EndIf
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: Checks if a service exists on a computer
    ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used
    ; $sServiceName - name of the service to check
    ; Requirements: None
    ; Return Values: On Success - 1
    ; On Failure - 0
    ;===============================================================================
    Func _ServiceExists($sComputerName, $sServiceName)
    Local $hAdvapi32
    Local $arRet
    Local $hSC
    Local $bExist = 0

    [/autoit] [autoit][/autoit] [autoit]

    $hAdvapi32 = DllOpen("advapi32.dll")
    If $hAdvapi32 = -1 Then Return 0
    $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
    "str", $sComputerName, _
    "str", "ServicesActive", _
    "long", $SC_MANAGER_CONNECT)
    If $arRet[0] <> 0 Then
    $hSC = $arRet[0]
    $arRet = DllCall($hAdvapi32, "long", "OpenService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "long", $SERVICE_INTERROGATE)
    If $arRet[0] <> 0 Then
    $bExist = 1
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0])
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
    EndIf
    DllClose($hAdvapi32)
    Return $bExist
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: Checks if a service is running on a computer
    ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used
    ; $sServiceName - name of the service to check
    ; Requirements: None
    ; Return Values: On Success - 1
    ; On Failure - 0
    ; Note: This function relies on the fact that only a running service responds
    ; to a SERVICE_CONTROL_INTERROGATE control code. Check the ControlService
    ; page on MSDN for limitations with using this method.
    ;===============================================================================
    Func _ServiceRunning($sComputerName, $sServiceName)
    Local $hAdvapi32
    Local $arRet
    Local $hSC
    Local $hService
    Local $bRunning = 0

    [/autoit] [autoit][/autoit] [autoit]

    $hAdvapi32 = DllOpen("advapi32.dll")
    If $hAdvapi32 = -1 Then Return 0
    $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
    "str", $sComputerName, _
    "str", "ServicesActive", _
    "long", $SC_MANAGER_CONNECT)
    If $arRet[0] <> 0 Then
    $hSC = $arRet[0]
    $arRet = DllCall($hAdvapi32, "long", "OpenService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "long", $SERVICE_INTERROGATE)
    If $arRet[0] <> 0 Then
    $hService = $arRet[0]
    $arRet = DllCall($hAdvapi32, "int", "ControlService", _
    "long", $hService, _
    "long", $SERVICE_CONTROL_INTERROGATE, _
    "str", "")
    $bRunning = $arRet[0]
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hService)
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
    EndIf
    DllClose($hAdvapi32)
    Return $bRunning
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: Creates a service on a computer
    ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used
    ; $sServiceName - name of the service to create
    ; $sDisplayName - display name of the service
    ; $sBinaryPath - fully qualified path to the service binary file
    ; The path can also include arguments for an auto-start service
    ; $sServiceUser - [optional] default is LocalSystem
    ; name of the account under which the service should run
    ; $sPassword - [optional] default is empty
    ; password to the account name specified by $sServiceUser
    ; Specify an empty string if the account has no password or if the service
    ; runs in the LocalService, NetworkService, or LocalSystem account
    ; $nServiceType - [optional] default is $SERVICE_WIN32_OWN_PROCESS
    ; $nStartType - [optional] default is $SERVICE_AUTO_START
    ; $nErrorType - [optional] default is $SERVICE_ERROR_NORMAL
    ; $nDesiredAccess - [optional] default is $SERVICE_ALL_ACCESS
    ; $sLoadOrderGroup - [optional] default is empty
    ; names the load ordering group of which this service is a member
    ; Requirements: Administrative rights on the computer
    ; Return Values: On Success - 1
    ; On Failure - 0 and @error is set to extended Windows error code
    ; Note: Dependencies cannot be specified using this function
    ; Refer to the CreateService page on MSDN for more information
    ;===============================================================================
    Func _CreateService($sComputerName, _
    $sServiceName, _
    $sDisplayName, _
    $sBinaryPath, _
    $sServiceUser = "LocalSystem", _
    $sPassword = "", _
    $nServiceType = 0x00000010, _
    $nStartType = 0x00000002, _
    $nErrorType = 0x00000001, _
    $nDesiredAccess = 0x000f01ff, _
    $sLoadOrderGroup = "")
    Local $hAdvapi32
    Local $hKernel32
    Local $arRet
    Local $hSC
    Local $lError = -1

    [/autoit] [autoit][/autoit] [autoit]

    $hAdvapi32 = DllOpen("advapi32.dll")
    If $hAdvapi32 = -1 Then Return 0
    $hKernel32 = DllOpen("kernel32.dll")
    If $hKernel32 = -1 Then Return 0
    $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
    "str", $sComputerName, _
    "str", "ServicesActive", _
    "long", $SC_MANAGER_ALL_ACCESS)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hSC = $arRet[0]
    $arRet = DllCall($hAdvapi32, "long", "OpenService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "long", $SERVICE_INTERROGATE)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hAdvapi32, "long", "CreateService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "str", $sDisplayName, _
    "long", $nDesiredAccess, _
    "long", $nServiceType, _
    "long", $nStartType, _
    "long", $nErrorType, _
    "str", $sBinaryPath, _
    "str", $sLoadOrderGroup, _
    "ptr", 0, _
    "str", "", _
    "str", $sServiceUser, _
    "str", $sPassword)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0])
    EndIf
    Else
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0])
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
    EndIf
    DllClose($hAdvapi32)
    DllClose($hKernel32)
    If $lError <> -1 Then
    SetError($lError)
    Return 0
    EndIf
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: Deletes a service on a computer
    ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used
    ; $sServiceName - name of the service to delete
    ; Requirements: Administrative rights on the computer
    ; Return Values: On Success - 1
    ; On Failure - 0 and @error is set to extended Windows error code
    ;===============================================================================
    Func _DeleteService($sComputerName, $sServiceName)
    Local $hAdvapi32
    Local $hKernel32
    Local $arRet
    Local $hSC
    Local $hService
    Local $lError = -1

    [/autoit] [autoit][/autoit] [autoit]

    $hAdvapi32 = DllOpen("advapi32.dll")
    If $hAdvapi32 = -1 Then Return 0
    $hKernel32 = DllOpen("kernel32.dll")
    If $hKernel32 = -1 Then Return 0
    $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
    "str", $sComputerName, _
    "str", "ServicesActive", _
    "long", $SC_MANAGER_ALL_ACCESS)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hSC = $arRet[0]
    $arRet = DllCall($hAdvapi32, "long", "OpenService", _
    "long", $hSC, _
    "str", $sServiceName, _
    "long", $SERVICE_ALL_ACCESS)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    Else
    $hService = $arRet[0]
    $arRet = DllCall($hAdvapi32, "int", "DeleteService", _
    "long", $hService)
    If $arRet[0] = 0 Then
    $arRet = DllCall($hKernel32, "long", "GetLastError")
    $lError = $arRet[0]
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hService)
    EndIf
    DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
    EndIf
    DllClose($hAdvapi32)
    DllClose($hKernel32)
    If $lError <> -1 Then
    SetError($lError)
    Return 0
    EndIf
    Return 1
    EndFunc

    [/autoit]

    und

    Spoiler anzeigen
    [autoit]

    ;=============================================================================
    ; Ideas from http://www.andreavb.com/tip060002.html, author: Andrea Tincani
    ; AutoIt scripts written by CatchFish, Feb 24th, 2006.
    ; 100% public domain. Feel free to remove the comments and claim it your own.
    ;=============================================================================
    #include-once

    [/autoit] [autoit][/autoit] [autoit]

    ;===============
    ; API Constants
    ;===============
    Const $SERVICES_ACTIVE_DATABASE = "ServicesActive"
    ; Service Control
    Const $SERVICE_CONTROL_STOP = 0x1
    Const $SERVICE_CONTROL_PAUSE = 0x2
    ; Service State - for CurrentState
    Const $SERVICE_STOPPED = 0x1
    Const $SERVICE_START_PENDING = 0x2
    Const $SERVICE_STOP_PENDING = 0x3
    Const $SERVICE_RUNNING = 0x4
    Const $SERVICE_CONTINUE_PENDING = 0x5
    Const $SERVICE_PAUSE_PENDING = 0x6
    Const $SERVICE_PAUSED = 0x7
    ; Service Control Manager object specific access types
    Const $STANDARD_RIGHTS_REQUIRED = 0xF0000
    Const $SC_MANAGER_CONNECT = 0x1
    Const $SC_MANAGER_CREATE_SERVICE = 0x2
    Const $SC_MANAGER_ENUMERATE_SERVICE = 0x4
    Const $SC_MANAGER_LOCK = 0x8
    Const $SC_MANAGER_QUERY_LOCK_STATUS = 0x10
    Const $SC_MANAGER_MODIFY_BOOT_CONFIG = 0x20
    Const $SC_MANAGER_ALL_ACCESS = BitOR($STANDARD_RIGHTS_REQUIRED, $SC_MANAGER_CONNECT, $SC_MANAGER_CREATE_SERVICE, $SC_MANAGER_ENUMERATE_SERVICE, _
    $SC_MANAGER_LOCK, $SC_MANAGER_QUERY_LOCK_STATUS, $SC_MANAGER_MODIFY_BOOT_CONFIG)
    ; Service object specific access types
    Const $SERVICE_QUERY_CONFIG = 0x1
    Const $SERVICE_CHANGE_CONFIG = 0x2
    Const $SERVICE_QUERY_STATUS = 0x4
    Const $SERVICE_ENUMERATE_DEPENDENTS = 0x8
    Const $SERVICE_START = 0x10
    Const $SERVICE_STOP = 0x20
    Const $SERVICE_PAUSE_CONTINUE = 0x40
    Const $SERVICE_INTERROGATE = 0x80
    Const $SERVICE_USER_DEFINED_CONTROL = 0x100
    Const $SERVICE_ALL_ACCESS = BitOR($STANDARD_RIGHTS_REQUIRED, $SERVICE_QUERY_CONFIG, $SERVICE_CHANGE_CONFIG, $SERVICE_QUERY_STATUS, _
    $SERVICE_ENUMERATE_DEPENDENTS, $SERVICE_START, $SERVICE_STOP, $SERVICE_PAUSE_CONTINUE, $SERVICE_INTERROGATE, $SERVICE_USER_DEFINED_CONTROL)

    [/autoit] [autoit][/autoit] [autoit]

    ;====================================================================
    ; DO NOT call these functions as they are used for internal affairs.
    ;====================================================================
    Func __CreateStructServiceStatus()
    ; ServiceType, CurrentState, ControlsAccepted, Win32ExitCode, ServiceSpecificExitCode, CheckPoint, WaitHint
    Return DllStructCreate("int;int;int;int;int;int;int")
    EndFunc ;==>__CreateStructServiceStatus

    [/autoit] [autoit][/autoit] [autoit]

    Func __CloseServiceHandle($v_hSCObject, $v_hAdvAPI = "advapi32.dll")
    Local $_Result = DllCall($v_hAdvAPI, "int", "CloseServiceHandle", "int", $v_hSCObject)
    If @error = 0 Then
    Return $_Result[0]
    Else
    SetError(@error)
    Return 0
    EndIf
    EndFunc ;==>__CloseServiceHandle

    [/autoit] [autoit][/autoit] [autoit]

    Func __ControlService($v_hService, $v_dwControl, $v_lpServiceStatus, $v_hAdvAPI = "advapi32.dll")
    Local $_Result = DllCall($v_hAdvAPI, "int", "ControlService", "int", $v_hService, "int", $v_dwControl, "ptr", $v_lpServiceStatus)
    If @error = 0 Then
    Return $_Result[0]
    Else
    SetError(@error)
    Return 0
    EndIf
    EndFunc ;==>__ControlService

    [/autoit] [autoit][/autoit] [autoit]

    Func __OpenSCManager($v_lpMachineName, $v_lpDatabaseName, $v_dwDesiredAccess, $v_hAdvAPI = "advapi32.dll")
    Local $_Result = DllCall($v_hAdvAPI, "int", "OpenSCManagerA", "str", $v_lpMachineName, "str", $v_lpDatabaseName, "int", $v_dwDesiredAccess)
    If @error = 0 Then
    Return $_Result[0]
    Else
    SetError(@error)
    Return 0
    EndIf
    EndFunc ;==>__OpenSCManager

    [/autoit] [autoit][/autoit] [autoit]

    Func __OpenService($v_hSCManager, $v_lpServiceName, $v_dwDesiredAccess, $v_hAdvAPI = "advapi32.dll")
    Local $_Result = DllCall($v_hAdvAPI, "int", "OpenServiceA", "int", $v_hSCManager, "str", $v_lpServiceName, "int", $v_dwDesiredAccess)
    If @error = 0 Then
    Return $_Result[0]
    Else
    SetError(@error)
    Return 0
    EndIf
    EndFunc ;==>__OpenService

    [/autoit] [autoit][/autoit] [autoit]

    Func __QueryServiceStatus($v_hService, $v_lpServiceStatus, $v_hAdvAPI = "advapi32.dll")
    Local $_Result = DllCall($v_hAdvAPI, "int", "QueryServiceStatus", "int", $v_hService, "ptr", $v_lpServiceStatus)
    If @error = 0 Then
    Return $_Result[0]
    Else
    SetError(@error)
    Return 0
    EndIf
    EndFunc ;==>__QueryServiceStatus

    [/autoit] [autoit][/autoit] [autoit]

    Func __StartService($v_hService, $v_dwNumServiceArgs, $v_lpServiceArgVectors, $v_hAdvAPI = "advapi32.dll")
    Local $_Result = DllCall($v_hAdvAPI, "int", "StartServiceA", "int", $v_hService, "int", $v_dwNumServiceArgs, "int", $v_lpServiceArgVectors)
    If @error = 0 Then
    Return $_Result[0]
    Else
    SetError(@error)
    Return 0
    EndIf
    EndFunc ;==>__StartService

    [/autoit] [autoit][/autoit] [autoit]

    ;===================================================================================================================
    ; Here below are 4 NT-service related functions: _ServiceStatus(), _ServicePause(), _ServiceStart(), _ServiceStop()
    ;===================================================================================================================
    Func _ServiceStatus($v_ServiceName, $v_ComputerName = "")
    Local $_ServiceStat = __CreateStructServiceStatus()
    Local $_hSManager
    Local $_hService
    Local $_hServiceStatus
    Local $_Result = 0
    Local $_Err = 0
    Local $_Ext = 0

    $_hSManager = __OpenSCManager($v_ComputerName, $SERVICES_ACTIVE_DATABASE, $SC_MANAGER_ALL_ACCESS)
    If $_hSManager <> 0 Then
    $_hService = __OpenService($_hSManager, $v_ServiceName, $SERVICE_ALL_ACCESS)
    If $_hService <> 0 Then
    $_hServiceStatus = __QueryServiceStatus($_hService, DllStructGetPtr($_ServiceStat))
    If $_hServiceStatus <> 0 Then
    Switch DllStructGetData($_ServiceStat, 2)
    Case $SERVICE_STOPPED
    $_Result = "Stopped"
    Case $SERVICE_START_PENDING
    $_Result = "Start Pending"
    Case $SERVICE_STOP_PENDING
    $_Result = "Stop Pending"
    Case $SERVICE_RUNNING
    $_Result = "Running"
    Case $SERVICE_CONTINUE_PENDING
    $_Result = "Coninue Pending"
    Case $SERVICE_PAUSE_PENDING
    $_Result = "Pause Pending"
    Case $SERVICE_PAUSED
    $_Result = "Paused"
    Case Else
    $_Err = 4
    EndSwitch
    Else
    $_Ext = @error
    $_Err = 3
    EndIf
    __CloseServiceHandle($_hService)
    Else
    $_Ext = @error
    $_Err = 2
    EndIf
    __CloseServiceHandle($_hSManager)
    Else
    $_Ext = @error
    $_Err = 1
    EndIf

    Return SetError($_Err, $_Ext, $_Result)
    EndFunc ;==>_ServiceStatus

    [/autoit] [autoit][/autoit] [autoit]

    Func _ServicePause($v_ServiceName, $v_ComputerName = "")
    Local $_ServiceStatus = __CreateStructServiceStatus()
    Local $_hSManager
    Local $_hService
    Local $_Result = 0
    Local $_Err = 0
    Local $_Ext = 0

    [/autoit] [autoit][/autoit] [autoit]

    $_hSManager = __OpenSCManager($v_ComputerName, $SERVICES_ACTIVE_DATABASE, $SC_MANAGER_ALL_ACCESS)
    If $_hSManager <> 0 Then
    $_hService = __OpenService($_hSManager, $v_ServiceName, $SERVICE_ALL_ACCESS)
    If $_hService <> 0 Then
    $_Result = __ControlService($_hService, $SERVICE_CONTROL_PAUSE, DllStructGetPtr($_ServiceStatus))
    If $_Result = 0 Then
    $_Ext = @error
    $_Err = 3
    EndIf
    __CloseServiceHandle($_hService)
    Else
    $_Ext = @error
    $_Err = 2
    EndIf
    __CloseServiceHandle($_hSManager)
    Else
    $_Ext = @error
    $_Err = 1
    EndIf

    Return SetError($_Err, $_Ext, $_Result)
    EndFunc ;==>_ServicePause

    [/autoit] [autoit][/autoit] [autoit]

    Func _ServiceStart($v_ServiceName, $v_ComputerName = "")
    Local $_hSManager
    Local $_hService
    Local $_Result = 0
    Local $_Err = 0
    Local $_Ext = 0

    [/autoit] [autoit][/autoit] [autoit]

    $_hSManager = __OpenSCManager($v_ComputerName, $SERVICES_ACTIVE_DATABASE, $SC_MANAGER_ALL_ACCESS)
    If $_hSManager <> 0 Then
    $_hService = __OpenService($_hSManager, $v_ServiceName, $SERVICE_ALL_ACCESS)
    If $_hService <> 0 Then
    $_Result = __StartService($_hService, 0, 0)
    If $_Result = 0 Then
    $_Ext = @error
    $_Err = 3
    EndIf
    __CloseServiceHandle($_hService)
    Else
    $_Ext = @error
    $_Err = 2
    EndIf
    __CloseServiceHandle($_hSManager)
    Else
    $_Ext = @error
    $_Err = 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return SetError($_Err, $_Ext, $_Result)
    EndFunc ;==>_ServiceStart

    [/autoit] [autoit][/autoit] [autoit]

    Func _ServiceStop($v_ServiceName, $v_ComputerName = "")
    Local $_ServiceStatus = __CreateStructServiceStatus()
    Local $_hSManager
    Local $_hService
    Local $_Result = 0
    Local $_Err = 0
    Local $_Ext = 0

    [/autoit] [autoit][/autoit] [autoit]

    $_hSManager = __OpenSCManager($v_ComputerName, $SERVICES_ACTIVE_DATABASE, $SC_MANAGER_ALL_ACCESS)
    If $_hSManager <> 0 Then
    $_hService = __OpenService($_hSManager, $v_ServiceName, $SERVICE_ALL_ACCESS)
    If $_hService <> 0 Then
    $_Result = __ControlService($_hService, $SERVICE_CONTROL_STOP, DllStructGetPtr($_ServiceStatus))
    If $_Result = 0 Then
    $_Ext = @error
    $_Err = 3
    EndIf
    __CloseServiceHandle($_hService)
    Else
    $_Ext = @error
    $_Err = 2
    EndIf
    __CloseServiceHandle($_hSManager)
    Else
    $_Ext = @error
    $_Err = 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return SetError($_Err, $_Ext, $_Result)
    EndFunc ;==>_ServiceStop

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================================================================================
    ; NT-service related funtions use internal service names. So use this function to convert the display name, as you see in the Services Manager.
    ;===============================================================================================================================================
    Func _ToInternalServiceName($v_ServiceDisplayName)
    Local $_Result = ""
    Local $_NTSvcKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"
    Local $_SubKey
    Local $i = 1

    If $v_ServiceDisplayName = "" Then Return $_Result
    While 1
    $_SubKey = RegEnumKey($_NTSvcKey, $i)
    $i += 1
    If @error = 0 Then
    If RegRead($_NTSvcKey & "\" & $_SubKey, "DisplayName") = $v_ServiceDisplayName Then
    $_Result = $_SubKey
    ExitLoop
    EndIf
    Else
    ExitLoop
    EndIf
    WEnd

    Return $_Result
    EndFunc ;==>_ToInternalServiceName

    [/autoit] [autoit][/autoit] [autoit]

    ; ---------------------------------------------
    ; Function: _ServiceStatusWait()
    ; Purpose: Waits for service status to match the given parameter.
    ; Call with: _ServiceStatusWait($v_ServiceName, $v_ComputerName = "", $s_Status = "Running", $i_Timeout = 0)
    ; Where: $v_ServiceName = string service name
    ; $v_ComputerName = computer to operate on, default is local
    ; $s_Status (optional) = status string to wait for, default is "Running"
    ; $i_Timeout = timeout in seconds, default 0 = never timeout
    ; On success returns 1
    ; On failure of the service status request returns 0 and sets @error and @extended
    ; On timeout returns 0 and @error = -1
    ; Notes: The service name is the 'internal' name, not necessarily the 'display'
    ; name seen in the GUI manager. Use _ToInternalServiceName() to translate
    ; display name to internal.
    ; Requires: _NTServices.au3
    ; ---------------------------------------------
    Func _ServiceStatusWait($v_ServiceName, $v_ComputerName = "", $s_Status = "Running", $i_Timeout = 0)
    Local $sStatus = _ServiceStatus($v_ServiceName, $v_ComputerName)
    If Not @error Then
    If $sStatus = $s_Status Then
    Return 1
    Else
    Local $iTimer = TimerInit()
    Do
    Sleep(250)
    If _ServiceStatus($v_ServiceName, $v_ComputerName) = $s_Status Then Return 1
    Until $i_Timeout And (TimerDiff($iTimer) > ($i_Timeout * 1000))
    ; Timeout
    Return SetError(-1, 0, 0)
    EndIf
    Else
    ; Error seeing service
    Return SetError(@error, @extended, 0)
    EndIf
    EndFunc ;==>_ServiceStatusWait

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetServiceState($s_pc, $service, $State)
    Local Const $wbemFlagReturnImmediately = 0x10
    Local Const $wbemFlagForwardOnly = 0x20

    [/autoit] [autoit][/autoit] [autoit]

    Local $colItems = "", $objItem, $ret_status = -1
    Local $a_status[25] = ["Success", "Not supported", "Access denied", "Dependent services running", _
    "Invalid service control", "Service cannot accept control", "Service not active", "Service request timeout", _
    "Unknown failure", "Path not found", "Service already stopped", "Service database locked", "Service dependency deleted", _
    "Service dependency failure", "Service disabled", "Service logon failed", "Service marked for deletion", "Service no thread", _
    "Status circular dependency", "Status duplicate name", "Status - invalid name", "Status - invalid parameter", _
    "Status - invalid service account", "Status - service exists", "Service already paused" ]
    If Ping($s_pc) Then
    Local $objWMIService = ObjGet("winmgmts:\\" & $s_pc & "\root\CIMV2")
    If @error Then
    MsgBox(16, "_SetServiceState", "ObjGet Error: winmgmts")
    Return
    EndIf
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service", "WQL", _
    $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If @error Then
    MsgBox(16, "_SetServiceState", "ExecQuery Error: SELECT * FROM Win32_Service")
    Return
    EndIf
    If IsObj($colItems) Then
    For $objItem In $colItems
    If $objItem.Name = $service Then
    Select
    Case $State = "Boot" Or $State = "System" Or $State = "Automatic" Or $State = "Manual" Or $State = "Disabled"
    $ret_status = $objItem.ChangeStartMode ($State)
    Case $State = "Stop"
    $ret_status = $objItem.StopService ()
    Case $State = "Start"
    $ret_status = $objItem.StartService ()
    Case $State = "Pause"
    $ret_status = $objItem.PauseService ()
    Case $State = "Resume"
    $ret_status = $objItem.ResumeService ()
    Case $State = "Delete"
    $ret_status = $objItem.Delete ()
    EndSelect
    ExitLoop
    EndIf
    Next
    EndIf
    EndIf
    If $ret_status <> -1 Then
    Return $a_status[$ret_status]
    Else
    SetError(1)
    Return $ret_status
    EndIf
    EndFunc ;==>_SetServiceState

    [/autoit]

    So long,

    Mega

  • Dienst

    • Xenobiologist
    • 3. Januar 2008 um 16:42

    HI,

    [autoit]

    #include "ServiceControl.au3"
    #include "Misc.au3"
    ;#NoTrayIcon ; Kann man natürlich auch noch wegmachen :)

    [/autoit][autoit][/autoit][autoit]

    If _Singleton("MegaService", 1) = 0 Then
    MsgBox(64, "Warning", "An occurence of test is already running", 3)
    Exit
    EndIf

    [/autoit][autoit][/autoit][autoit]

    Global $pathSrvAny = "c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\srvany.exe"
    Global $servicename = "MegaService"
    If Not _ServiceExists (@ComputerName, $servicename) And @Compiled Then
    _CreateService ("", $servicename, "Mega Skript", $pathSrvAny, "LocalSystem", "", 0x110)
    RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename & "\Parameters", "Application", "REG_SZ", @ScriptFullPath)
    EndIf

    [/autoit][autoit][/autoit][autoit]

    While 1
    Sleep(500)
    theFunc()
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Func theFunc()
    If @HOUR = 16 And @MIN = 24 And @SEC = 00 Then ; hier mal die Zeit anpassen :)
    ToolTip("Skript gestartet" & " Service An(1)Aus(0) :" & _ServiceExists (@ComputerName, $servicename), 0, 0)
    Beep(500, 5000)
    Else
    ToolTip("Skript inaktiv" & " Service An(1)Aus(0) :" & _ServiceExists (@ComputerName, $servicename), 0, 0)
    EndIf
    EndFunc ;==>theFunc

    [/autoit]

    So long,

    Mega

  • 2 MS-Windows Datei-Explorer nebeneinander starten

    • Xenobiologist
    • 3. Januar 2008 um 16:15

    Hi,

    [autoit]

    Send('#m')
    _closeAllExplorer()
    ShellExecuteWait('explorer', @WindowsDir, '', '', @SW_MAXIMIZE)
    ShellExecuteWait('explorer', @ScriptDir, '', '', @SW_MAXIMIZE)
    Sleep(1000)
    DllCall("user32.dll", "int", "CascadeWindows", "int", 0, "int", 4, "int", 0, "int", 0, "int", 0); Cascade
    Sleep(1000)
    DllCall("user32.dll", "int", "TileWindows", "int", 0, "int", 1, "int", 0, "int", 0, "int", 0); Tile Horizontal
    Sleep(1000)
    DllCall("user32.dll", "int", "TileWindows", "int", 0, "int", 0, "int", 0, "int", 0, "int", 0); Tile Vertical
    Sleep(1000)
    _closeAllExplorer()

    Func _closeAllExplorer()
    Local $opt = Opt('WinTitleMatchMode', 4)
    Do
    until WinClose("[CLASS:ExploreWClass]") = 0 and WinClose("[CLASS:CabinetWClass]") = 0
    Opt('WinTitleMatchMode', $opt)
    EndFunc ;==>_closeAllExplorer

    [/autoit]

    So long,

    Mega

  • AutoIt-Gruppe im StudiVZ

    • Xenobiologist
    • 3. Januar 2008 um 14:24

    Hmmh,

    sollte ich da beitreten? ?(

    So long,

    Mega

  • Laustärke Regeln unter Vista...

    • Xenobiologist
    • 3. Januar 2008 um 11:23

    HI,

    geht es auch nicht mit der audio.au3 ausm EngForum? (no Vista ;( )

    So long,

    Mega

  • TrayItemSetOnEvent geht nur 1 mal

    • Xenobiologist
    • 3. Januar 2008 um 11:20

    HI,

    meinst du so?

    Spoiler anzeigen
    [autoit]

    #Include <GuiConstants.au3>
    #include <Array.au3>
    #include <GuiListBox.au3>
    #include <file.au3>
    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>
    #Include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("TrayIconHide", 0)
    Opt("TrayOnEventMode", 1)
    Opt("TrayMenuMode", 1)
    Opt("GuiOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    FileInstall("No.ico", @ScriptDir & "\Icons\No.ico")
    FileInstall("Yes.ico", @ScriptDir & "\Icons\Yes.ico")

    [/autoit] [autoit][/autoit] [autoit]

    Global $addip, $addname, $anz, $badd, $bclear, $bexit, $BL, $bok, $BR, $bremove, $bsave, $bstandard, $cbtooltip, $cbwindow, $corner, $cornerBL, $cornerBR, $cornerTL, $cornerTR, $count, $DeskX, $DeskY, $error1, $error2, $gui, $GuiIP, $GuiSettings, $h, $i, $Ih, $Iintervall, $ini, $Intervall, $ips, $ips2, $Itimeout, $Iw, $lineIndex, $list, $list2, $pathIPs, $Paused, $ping, $pingip, $SaveIPs, $script, $SectionIP, $Sections, $slider, $state, $timeout, $TL, $tool, $ToolTipEnabled, $TR, $trans, $urllist, $varIP, $w, $WinEnabled, $x, $y

    [/autoit] [autoit][/autoit] [autoit]

    $pathIPs = @ScriptDir & "\Destiny.ini"
    $script = "WhoIsOn RelOadEd"
    $ini = @ScriptDir & "\Settings.ini"
    $Intervall = 10000
    $timeout = 4000
    $corner = 3
    $WinEnabled = 1
    $ToolTipEnabled = 1
    $trans = 40
    $w = 300
    $h = 200
    $error1 = 0
    $error2 = 0

    [/autoit] [autoit][/autoit] [autoit]

    $DeskX = @DesktopWidth
    $DeskY = @DesktopHeight

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("!{End}", "_OnExitFunc")
    HotKeySet("!{PAUSE}", "TogglePause")
    HotKeySet("^!g", '_ShowGUI')
    HotKeySet("^!t", "TrayIcon")
    HotKeySet("^!s", '_Settings')
    HotKeySet("^!c", "_Change")

    [/autoit] [autoit][/autoit] [autoit]

    TrayCreateItem("Settings")
    TrayItemSetOnEvent(-1, "_Settings")
    TrayCreateItem("Change IPs")
    TrayItemSetOnEvent(-1, "_Change")
    TrayCreateItem("-")
    TrayCreateItem("Hide/Show")
    TrayItemSetOnEvent(-1, "_ShowGUI")
    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "_OnExitFunc")

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($ini) Then
    $Intervall = IniRead($ini, "Ping", "Intervall", $Intervall)
    $timeout = IniRead($ini, "Position", "Timeout", $timeout)
    $corner = IniRead($ini, "Position", "Corner", $corner)
    $WinEnabled = IniRead($ini, "Window", "Enabled", $WinEnabled)
    $w = IniRead($ini, "Window", "Weight", $w)
    $h = IniRead($ini, "Window", "Height", $h)
    $trans = IniRead($ini, "Window", "Transparency", $trans)
    $ToolTipEnabled = IniRead($ini, "ToolTip", "Enabled", $ToolTipEnabled)
    Else
    IniWrite($ini, "Ping", "Intervall", $Intervall)
    IniWrite($ini, "Ping", "Timeout", $timeout)
    IniWrite($ini, "Position", "Corner", $corner)
    IniWrite($ini, "Window", "Enabled", $WinEnabled)
    IniWrite($ini, "Window", "Weight", $w)
    IniWrite($ini, "Window", "Height", $h)
    IniWrite($ini, "Window", "Transparency", $trans)
    IniWrite($ini, "ToolTip", "Enabled", $ToolTipEnabled)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $corner = 1 Then
    $x = 5
    $y = 5
    ElseIf $corner = 2 Then
    $x = $DeskX - $w - 5
    $y = 5
    ElseIf $corner = 3 Then
    $x = $DeskX - $w - 5
    $y = $DeskY - $h - 35
    ElseIf $corner = 4 Then
    $x = 5
    $y = $DeskY - $h - 35
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $gui = GUICreate($script, $w, $h, $x, $y, $WS_POPUPWINDOW, $WS_EX_TRANSPARENT + $WS_EX_TOOLWINDOW)
    WinSetOnTop($script, '', 1)
    WinSetTrans($script, '', (100 - $trans) * 2.55)
    $list2 = _GUICtrlListView_Create($gui, "||", 5, 5, $w - 10, $h - 10)
    _GUICtrlListView_SetColumn($list2, 0, "Name", ($w / 2) - 30, 2)
    _GUICtrlListView_SetColumn($list2, 1, "IP", ($w / 2) - 30, 2)
    _GUICtrlListView_SetColumn($list2, 2, "Status", 50, 2)

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($pathIPs) Then
    $Sections = IniReadSectionNames($pathIPs)
    If $Sections = 0 Then
    Else
    $lineIndex = 0
    For $i = 1 To $Sections[0]
    $varIP = IniReadSection($pathIPs, $Sections[$i])
    _GUICtrlListView_AddItem($list2, $varIP[1][0])
    _GUICtrlListView_AddSubItem($list2, $lineIndex, $Sections[$i], 1)
    _GUICtrlListView_AddSubItem($list2, $lineIndex, $varIP[1][1], 2)
    $lineIndex += 1
    Next
    EndIf
    Else
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW, $gui)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _PingProc()

    [/autoit] [autoit][/autoit] [autoit]

    Func _PingProc()
    While 1
    $count = _GUICtrlListView_GetItemCount($list2)
    For $i = 0 To $count - 1
    $pingip = _GUICtrlListView_GetItemText($list2, $i, 1)
    Ping($pingip, $timeout)
    Next
    Sleep($Intervall)
    WEnd
    EndFunc ;==>_PingProc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Change()

    [/autoit] [autoit][/autoit] [autoit]

    $GuiIP = GUICreate($script & " Destiny IPs", 345, 310)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitSettings")

    [/autoit] [autoit][/autoit] [autoit]

    $list = _GUICtrlListView_Create($GuiIP, "|", 5, 5, 250, 300)
    _GUICtrlListView_SetColumn($list, 0, "Name", 120, 2)
    _GUICtrlListView_SetColumn($list, 1, "IP", 125, 2)

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($pathIPs) Then
    $Sections = IniReadSectionNames($pathIPs)
    $lineIndex = 0
    For $i = 1 To $Sections[0]
    $varIP = IniReadSection($pathIPs, $Sections[$i])
    _GUICtrlListView_AddItem($list, $varIP[1][0])
    _GUICtrlListView_AddSubItem($list, $lineIndex, $Sections[$i], 1)
    ;~ _GUICtrlListView_AddSubItem($list2, $lineIndex, $varIP[1][1], 2)
    $lineIndex += 1
    Next
    Else
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $badd = GUICtrlCreateButton("&add", 260, 10, 80)
    GUICtrlSetOnEvent(-1, "_AddIP")
    $bremove = GUICtrlCreateButton("&remove", 260, 50, 80)
    GUICtrlSetOnEvent(-1, "_RemoveIP")
    $bclear = GUICtrlCreateButton("&clear", 260, 90, 80)
    GUICtrlSetOnEvent(-1, "_ClearIP")
    $bok = GUICtrlCreateButton("&ok", 260, 280, 80)
    GUICtrlSetOnEvent(-1, "_SaveIP")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW, $GuiIP)
    EndFunc ;==>_Change

    [/autoit] [autoit][/autoit] [autoit]

    Func _AddIP()
    Do
    $addname = InputBox("Name", "Please enter a name", "", "", 100, 130)
    If @error = 1 Then
    $error1 = 1
    ExitLoop
    Else
    EndIf
    until $addname <> ""
    If $error1 = 1 Then
    Else
    Do
    $addip = InputBox("IP", "Please enter the IP", "", "", 100, 130)
    If @error = 1 Then
    $error2 = 1
    ExitLoop
    Else
    EndIf
    Until StringRegExp($addip, "[0-9]+")
    If $error2 <> 1 Then
    _GUICtrlListView_AddItem($list, $addname)
    _GUICtrlListView_AddSubItem($list, _GUICtrlListView_GetItemCount($list) - 1, $addip, 1)
    Else
    EndIf
    EndIf
    $error1 = 0
    $error2 = 0
    EndFunc ;==>_AddIP

    [/autoit] [autoit][/autoit] [autoit]

    Func _RemoveIP()
    _GUICtrlListView_DeleteItemsSelected($list)
    EndFunc ;==>_RemoveIP

    [/autoit] [autoit][/autoit] [autoit]

    Func _ClearIP()
    _GUICtrlListView_DeleteAllItems($list)
    EndFunc ;==>_ClearIP

    [/autoit] [autoit][/autoit] [autoit]

    Func _SaveIP()

    [/autoit] [autoit][/autoit] [autoit]

    FileDelete($pathIPs)
    $anz = _GUICtrlListView_GetItemCount($list)
    If $anz = 0 Then
    Else
    For $i = 1 To $anz
    IniWrite($pathIPs, _GUICtrlListView_GetItemText($list, $i - 1, 1), _GUICtrlListView_GetItemText($list, $i - 1), "-")
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_HIDE, $GuiIP)

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($pathIPs) Then
    $Sections = IniReadSectionNames($pathIPs)
    $lineIndex = 0
    For $i = 1 To $Sections[0]
    $varIP = IniReadSection($pathIPs, $Sections[$i])
    _GUICtrlListView_AddItem($list2, $varIP[1][0])
    _GUICtrlListView_AddSubItem($list2, $lineIndex, $Sections[$i], 1)
    _GUICtrlListView_AddSubItem($list2, $lineIndex, $varIP[1][1], 2)
    $lineIndex += 1
    Next
    Else
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _PingProc()

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_SaveIP

    [/autoit] [autoit][/autoit] [autoit]

    Func _Settings()

    [/autoit] [autoit][/autoit] [autoit]

    $GuiSettings = GUICreate($script & " Settings", 450, 200)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitSettings")

    [/autoit] [autoit][/autoit] [autoit]

    ;ToolTip
    GUICtrlCreateGroup("Tooltip", 5, 5, 135, 60)
    $cbtooltip = GUICtrlCreateCheckbox("Enable ToolTip", 25, 30, 100)
    GUICtrlSetTip(-1, "Enables the ToolTip-Information")
    GUICtrlSetState($cbtooltip, IniRead($ini, "ToolTip", "Enabled", $ToolTipEnabled))

    [/autoit] [autoit][/autoit] [autoit]

    ;ping
    GUICtrlCreateGroup("Ping", 5, 70, 135, 120)
    GUICtrlCreateLabel("Intervall:", 15, 105, 40)
    GUICtrlSetTip(-1, "Time between pings in miliseconds")
    $Iintervall = GUICtrlCreateInput(IniRead($ini, "Ping", "Intervall", $Intervall), 60, 100, 50)
    GUICtrlCreateLabel("ms", 115, 105, 20)
    GUICtrlCreateLabel("Timeout:", 15, 140, 40)
    GUICtrlSetTip(-1, "Timeout after no response in miliseconds")
    $Itimeout = GUICtrlCreateInput(IniRead($ini, "Ping", "Timeout", $timeout), 60, 135, 50)
    GUICtrlCreateLabel("ms", 115, 140, 20)

    [/autoit] [autoit][/autoit] [autoit]

    ;weight & height
    GUICtrlCreateGroup("Window", 150, 5, 200, 100)
    $cbwindow = GUICtrlCreateCheckbox("Enable Info-Window", 160, 20, 120)
    GUICtrlSetTip(-1, "Enables the Information-Window on startup")
    GUICtrlSetState($cbwindow, IniRead($ini, "Window", "Enabled", $WinEnabled))
    GUICtrlSetOnEvent($cbwindow, "_DisabelWindow")
    GUICtrlCreateLabel("Weight:", 180, 50, 40)
    GUICtrlSetTip(-1, "Wight of the Information-Window")
    $Iw = GUICtrlCreateInput(IniRead($ini, "Window", "Weight", $w), 220, 45, 50)
    GUICtrlCreateLabel("mm", 275, 50, 20)
    GUICtrlCreateLabel("Height:", 180, 80, 40)
    GUICtrlSetTip(-1, "Hight of the Information-Window")
    $Ih = GUICtrlCreateInput(IniRead($ini, "Window", "Height", $h), 220, 75, 50)
    GUICtrlCreateLabel("mm", 275, 80, 20)
    $slider = GUICtrlCreateSlider(300, 15, 25, 85, $TBS_VERT + $TBS_AUTOTICKS)
    GUICtrlSetTip(-1, "Transparency of the Information-Window")
    GUICtrlSetLimit($slider, 100, 0)
    GUICtrlSetData($slider, IniRead($ini, "Window", "Transparency", $trans))
    GUICtrlCreateLabel("0", 335, 15, 10, 15)
    GUICtrlCreateLabel("100", 327, 85, 20, 15)

    [/autoit] [autoit][/autoit] [autoit]

    ;corner
    GUICtrlCreateGroup("Corner Position", 150, 110, 200, 80)
    $TL = GUICtrlCreateRadio("Top Left", 160, 125, 60)
    GUICtrlSetTip(-1, "Position the Information-Window appears")
    $TR = GUICtrlCreateRadio("Top Right", 255, 125, 65)
    GUICtrlSetTip(-1, "Position the Information-Window appears")
    $BR = GUICtrlCreateRadio("Bottom Right", 255, 160, 80)
    GUICtrlSetTip(-1, "Position the Information-Window appears")
    $BL = GUICtrlCreateRadio("Bottom Left", 160, 160, 70)
    GUICtrlSetTip(-1, "Position the Information-Window appears")

    [/autoit] [autoit][/autoit] [autoit]

    $corner = IniRead($ini, "Position", "Corner", $corner)
    If $corner = 1 Then
    GUICtrlSetState($TL, 1)
    ElseIf $corner = 2 Then
    GUICtrlSetState($TR, 1)
    ElseIf $corner = 3 Then
    GUICtrlSetState($BR, 1)
    ElseIf $corner = 4 Then
    GUICtrlSetState($BL, 1)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;buttons
    $bsave = GUICtrlCreateButton("save", 360, 10, 80)
    GUICtrlSetOnEvent(-1, "_SaveSettings")
    $bstandard = GUICtrlCreateButton("standard", 360, 45, 80)
    GUICtrlSetOnEvent(-1, "_StandardSettings")
    $bexit = GUICtrlCreateButton("exit", 360, 160, 80)
    GUICtrlSetOnEvent(-1, "_ExitSettings")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW, $GuiSettings)
    EndFunc ;==>_Settings

    [/autoit] [autoit][/autoit] [autoit]

    Func _SaveSettings()
    IniWrite($ini, "Ping", "Intervall", GUICtrlRead($Iintervall))
    IniWrite($ini, "Ping", "Timeout", GUICtrlRead($Itimeout))
    IniWrite($ini, "Window", "Enabled", GUICtrlRead($cbwindow))
    IniWrite($ini, "Window", "Weight", GUICtrlRead($Iw))
    IniWrite($ini, "Window", "Height", GUICtrlRead($Ih))
    IniWrite($ini, "Window", "Transparency", GUICtrlRead($slider))
    IniWrite($ini, "ToolTip", "Enabled", GUICtrlRead($cbtooltip))
    $cornerTL = GUICtrlRead($TL)
    $cornerTR = GUICtrlRead($TR)
    $cornerBR = GUICtrlRead($BR)
    $cornerBL = GUICtrlRead($BL)
    If $cornerTL = 1 Then
    IniWrite($ini, "Position", "Corner", "1")
    ElseIf $cornerTR = 1 Then
    IniWrite($ini, "Position", "Corner", "2")
    ElseIf $cornerBR = 1 Then
    IniWrite($ini, "Position", "Corner", "3")
    ElseIf $cornerBL = 1 Then
    IniWrite($ini, "Position", "Corner", "4")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_SaveSettings

    [/autoit] [autoit][/autoit] [autoit]

    Func _StandardSettings()
    GUICtrlSetData($Iintervall, "10000")
    GUICtrlSetData($Itimeout, "4000")
    GUICtrlSetState($cbwindow, 1)
    GUICtrlSetData($Iw, 300)
    GUICtrlSetData($Ih, 200)
    GUICtrlSetData($slider, 40)
    GUICtrlSetState($cbtooltip, 1)
    GUICtrlSetState($TL, 0)
    GUICtrlSetState($TR, 0)
    GUICtrlSetState($BR, 1)
    GUICtrlSetState($BL, 0)
    GUICtrlSetState($Iw, $GUI_ENABLE)
    GUICtrlSetState($Ih, $GUI_ENABLE)
    GUICtrlSetState($slider, $GUI_ENABLE)
    EndFunc ;==>_StandardSettings

    [/autoit] [autoit][/autoit] [autoit]

    Func _ExitSettings()

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_HIDE, $GuiSettings)

    [/autoit] [autoit][/autoit] [autoit]

    $Intervall = IniRead($ini, "Ping", "Intervall", $Intervall)
    $timeout = IniRead($ini, "Position", "Timeout", $timeout)
    $corner = IniRead($ini, "Position", "Corner", $corner)
    $WinEnabled = IniRead($ini, "Window", "Enabled", $WinEnabled)
    $w = IniRead($ini, "Window", "Weight", $w)
    $h = IniRead($ini, "Window", "Height", $h)
    $trans = IniRead($ini, "Window", "Transparency", $trans)
    $ToolTipEnabled = IniRead($ini, "ToolTip", "Enabled", $ToolTipEnabled)

    [/autoit] [autoit][/autoit] [autoit]

    If $corner = 1 Then
    $x = 5
    $y = 5
    ElseIf $corner = 2 Then
    $x = $DeskX - $w - 5
    $y = 5
    ElseIf $corner = 3 Then
    $x = $DeskX - $w - 5
    $y = $DeskY - $h - 35
    ElseIf $corner = 4 Then
    $x = 5
    $y = $DeskY - $h - 35
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    WinMove($script, "", $x, $y, $w, $h)
    WinSetTrans($script, '', (100 - $trans) * 2.55)
    _WinAPI_SetWindowPos($list2, 0, 5, 5, $w - 10, $h - 10, $SWP_SHOWWINDOW)
    _GUICtrlListView_SetColumn($list2, 0, "Name", ($w / 2) - 30, 2)
    _GUICtrlListView_SetColumn($list2, 1, "IP", ($w / 2) - 30, 2)
    _GUICtrlListView_SetColumn($list2, 2, "Status", 50, 2)

    [/autoit] [autoit][/autoit] [autoit]

    _PingProc()

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_ExitSettings

    [/autoit] [autoit][/autoit] [autoit]

    Func _DisabelWindow()
    If GUICtrlRead($cbwindow) = 1 Then
    GUICtrlSetState($Iw, $GUI_ENABLE)
    GUICtrlSetState($Ih, $GUI_ENABLE)
    GUICtrlSetState($slider, $GUI_ENABLE)
    Else
    GUICtrlSetState($Iw, $GUI_DISABLE)
    GUICtrlSetState($Ih, $GUI_DISABLE)
    GUICtrlSetState($slider, $GUI_DISABLE)
    EndIf
    EndFunc ;==>_DisabelWindow

    [/autoit] [autoit][/autoit] [autoit]

    Func _OnExitFunc()
    Exit
    EndFunc ;==>_OnExitFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;Tray-Icon
    Func TrayIcon()
    Opt("TrayIconHide", Not Opt("TrayIconHide", "Default"))
    EndFunc ;==>TrayIcon

    [/autoit] [autoit][/autoit] [autoit]

    ;Pause
    Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
    Sleep(100)
    ToolTip(@ScriptName & ' is paused')
    WEnd
    ToolTip("")
    EndFunc ;==>TogglePause

    [/autoit] [autoit][/autoit] [autoit]

    Func _ShowGUI()
    $state = WinGetState('WhoIsOn', '')
    If BitAND($state, 2) Then
    WinSetState('WhoIsOn', '', @SW_HIDE)
    ToolTip('', -1, -1, '', '', 2)
    $tool = 1
    Else
    WinSetState('WhoIsOn', '', @SW_SHOW)
    $tool = 0
    EndIf
    EndFunc ;==>_ShowGUI

    [/autoit]

    So long,

    Mega

  • 2 MS-Windows Datei-Explorer nebeneinander starten

    • Xenobiologist
    • 3. Januar 2008 um 11:10

    HI,

    ich nutze dafür den Total Commander :D

    So long,

    Mega

  • Fatal error @v3.2.10.0

    • Xenobiologist
    • 2. Januar 2008 um 18:48

    Hi,

    hast du es auch für das richtige Windows gemacht? (sorry dumme Idee, aber ich habe kein 98 mehr)

    So long,

    Mega

  • IE 6 will nicht IE 5.5 schon

    • Xenobiologist
    • 2. Januar 2008 um 14:15

    Hi,

    mach mal ein Skript mit dem der Fehler reproduzierbar ist. CODE!!!

    So long,

    Mega

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™