Hallo allerseits,
also in einer GUI hatte ich das schon hinbekommen, aber in einem TrayTool scheint das so nicht zu funktionieren. Ich versuche einen Autostart einzubauen, den ich mit einem Hacken entsprechend an und abwählen kann. Eintragen geht gerade noch so , aber beim Abwählen löscht er den Link nicht, was mache ich bloss falsch? Hoffe ist nicht zu lang, poste das ma eben
AutoIt
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <File.au3>
#include <GuiButton.au3>
FileInstall("C:\Users\Rickl\Music\kamera.mp3", "C:\Windows\Temp\kamera.mp3", 2)
Opt("TrayMenuMode",1) ; Hide default tray menu items
Opt("TrayAutoPause", 0); This will allow you to click on the TrayIcon without pause the script
TraySetIcon("Shell32.dll",-325)
TraySetClick(8) ;only show the menu when right clicking
#Tray Tip
TraySetToolTip ("Andis ClippingTool - Bitte klicken für Screenshot")
;HOTKEYS
HotKeySet("+{F2}", "Shot") ;Screenshot spezielle Anwendung
HotKeySet("+{F3}", "ActiveWindow") ;Screnshot aktives Fenster
;HotKeySet("{ESC}", "_Exit")
; Global $Terminate = False
; HotKeySet("{ESC}", "Terminate")
; HotKeySet("^s", Intervall()")
;Variablen--------------------------------------------------------------------------------------------------
$Folderitem = TrayCreateItem("Clip Ordner")
$delitem = TrayCreateItem("Clip Ordner leeren")
TrayCreateItem("") ; Create a separator line.
$Spezitem = TrayCreateItem("Mess Bildschirm")
TrayItemSetState($spezitem,$TRAY_UNCHECKED)
$Holeitem = TrayCreateItem("Ganzer Bildschirm")
;$Intervalitem = TrayCreateItem("Intervall-Shot")
TrayCreateItem("") ; Create a separator line.
$aboutitem = TrayCreateItem("Über")
$infoitem = TrayCreateItem("Info")
$Supportitem = TrayCreateItem("Support-Mail")
TrayCreateItem("") ; Create a separator line.
$Mailforwarditem = TrayCreateItem("weiterleiten per Mail (Newest)")
;TrayItemSetState($Mailforwarditem,$TRAY_CHECKED)
$autostartitem = TrayCreateItem("mit Windows starten")
;TrayItemSetState($autostartitem,$TRAY_CHECKED)
$exititem = TrayCreateItem("Exit")
$appPath = _PathFull("Microsoft\Windows\Start Menu\Programs\Startup\AndisClippingTool.exe", @AppDataDir)
;$clipPath = ("c:\clips")
$checkPath = ("c:\check.txt")
$checkPath = _PathFull("Microsoft\check.txt", @AppDataDir)
$targetdirPath = _PathFull("clips\", @MyDocumentsDir )
Global $BeepFile = 'C:\Windows\Temp\kamera.mp3'
Global $sTimestamp
Local $appPath
$CmdPid = Run("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe .\mailer.ps1 -noexit" & 'Get-ChildItem',@ScriptDir, @SW_HIDE); Starting PicMailer
;CHECKS------------------------------------------------------------------------------------------------------
;Mehrere Instanzen vermeiden---------------------------------------------------------------------------------
$g_szVersion = "My Somewhat Unique Window Title"
If WinExists($g_szVersion) Then
Exit
EndIf
AutoItWinSetTitle($g_szVersion)
;------------------------------------------------------------------------------------------------------------
;Clipverzeichnis anlegen-------------------------------------------------------------------------------------
If FileExists ($targetdirPath) = 1 Then
;MsgBox(0,"info", "File exists" , 10)
Else
;MsgBox(0,"info", "File does not exist" , 10)
DirCreate ( $targetdirPath )
DirCreate ( $targetdirPath & "app" )
EndIf
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
;Prüfen ob Tool zum ersten mal gestartet mit check.txt
If FileExists ($checkPath) = 1 Then
;MsgBox(0,"info", "File exists" , 10)
Else
MakeShellmenu()
SplashTextOn("Achtung", "Andis Clipping Tool residiert ab jetz hier unten im Traymenu ⇲ !", 450, 60, 1400, 950, 1, "Verdana")
sleep(5000)
SplashOff()
_FileCreate($checkPath)
EndIf
;------------------------------------------------------------------------------------------------------------
Func MakeShellmenu()
RegWrite("HKEY_CLASSES_ROOT\Directory\Background\shell\WindowShot", "Icon", "REG_SZ", "Shell32.dll,325")
RegWrite("HKEY_CLASSES_ROOT\Directory\Background\shell\WindowShot\command", "", "REG_SZ", "" & @Scriptdir & "\HOTKEYMakeShotActiveWindow.exe %W")
EndFunc
;MAIN LOOP---------------------------------------------------------------------------------------------------
While 1
Switch TrayGetMsg() ;switch seems nicer in this case
Case 0
ContinueLoop
Case $TRAY_EVENT_PRIMARYDOWN ;reaction to left clicking
;Msgbox(64,"","left click!")
checkapp()
;WinSetState($hWnd, "", @SW_Restore)
Case $delitem
TrayItemSetState($delitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
ProcessClose ($CmdPid)
FileDelete($targetdirPath & "\*.*")
FileDelete($targetdirPath & "\app\*.*")
$CmdPid
Case $spezitem
TrayItemSetState($spezitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
CheckApp()
Case $holeitem
TrayItemSetState($holeitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
SoundPlay($BeepFile)
HoleScreen()
; Case $Intervalitem
; TrayItemSetState($Intervalitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
; Intervall()
Case $aboutitem
TrayItemSetState($aboutitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
Msgbox(64, "Über", "Mit diesem Tool wird per Doppelklick ein Snapshot von der Anwendung ... erzeugt, diese wird anschliessend auf Rechner ..., in Verzeuichnis ... abgelegt.")
Case $Folderitem
TrayItemSetState($Folderitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
Run("Explorer.exe " & $targetdirPath)
Case $supportitem
TrayItemSetState($supportitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
ShellExecute("mailto:Rickl@landesarchiv.berlin.de")
Case $infoitem
TrayItemSetState($infoitem,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
Msgbox(64, "About", "Bei Fragen und Anregungen, sowie Problemen kontaktieren Sie bitte mich!")
Case $autostartitem
If BitAND(GUICtrlRead($autostartitem), $BN_CLICKED) = $BN_CLICKED Then
;MsgBox(0,"Info","Text",1)
If Not FileExists(@StartupDir & "\ACT.lnk") Then
FileCreateShortcut(@ScriptFullPath, @StartupDir & "\ACT.lnk", @ScriptDir, "", "AutoIT Script Description")
EndIf
Else
If FileExists(@StartupDir & "\ACT.lnk") Then
FileDelete(@StartupDir & "\ACT.lnk")
EndIf
;Endif
EndIf
Case $Mailforwarditem
; if unchecked -> chekced else
TrayItemSetState($Mailforwarditem ,$TRAY_UNCHECKED)
TraySetState()
Case $exititem
ProcessClose ($CmdPid)
ExitLoop
EndSwitch
WEnd
Exit
;-----------------------------------------------------------------------------------------------------------
Func CheckApp()
If WinExists ( "Unbenannt - Editor" ) Then
SoundPlay($BeepFile)
shot()
Else
Msgbox(64, "About", "Applikation läuft nicht!")
EndIf
EndFunc
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func Shot()
$sTimestamp = @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC ; ggf. noch & @MSEC
$sFileName= $targetdirPath & "app\" & "Notepad_" & $sTimestamp &".jpg"
$title = "Unbenannt - Editor" ;Beispiel mit Notepad
$list = WinList() ;liste alle Fenster
If $list[0][0] > 0 Then ;wenn Liste nicht leer, dann weiter
$i = 1
Do
If StringInStr($list[$i][0], $title) > 0 Then ;finde erstes Notepad Fenster
$hWnd = $list[$i][1] ;merke Handel vom Fenster
WinSetState($hWnd, "", @SW_RESTORE) ;stelle wieder das Notepad Fenster her, da minimiert der Screenshot sonst schwarz wäre
Sleep(250) ;warte auf das Notepad Fenster
_ScreenCapture_CaptureWnd($sFileName, $hWnd) ;mache ein Foto und speichere das Bild ab
WinSetState($hWnd, "", @SW_MINIMIZE) ;minimiere das Fenster wieder
ExitLoop ;verlasse Schleife
EndIf
$i += 1
Until $i >= $list[0][0] ;suche solange bis alle Fenster durchsucht sind!
EndIf
EndFunc
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func HoleScreen()
$sTimestamp = @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC ; ggf. noch & @MSEC
$sFileName= $targetdirPath & "FullScreen_" & $sTimestamp & ".jpg"
_ScreenCapture_Capture($sFileName,0,0,@DesktopWidth,@DesktopHeight)
ShellExecute($sFileName)
EndFunc
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func ActiveWindow()
$sTimestamp = @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC ; ggf. noch & @MSEC
$sFileName= $targetdirPath & "ActiveWindow_" & $sTimestamp &".jpg"
$ActiveWindow = WinGetHandle("[active]")
SoundPlay($BeepFile)
$Image = _ScreenCapture_CaptureWnd ( "", $ActiveWindow, 0, 0, -1, -1, True )
$fFreeBmp = True
_ScreenCapture_SaveImage ( $sFilename & "PictuRec.jpg", $Image, $fFreeBmp )
EndFunc
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func Intervall()
While 1
Sleep(1000)
Send("+{F2}")
WEnd
EndFunc
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func _Exit()
MsgBox("Title", "", "Script wurde abgebrochen.", 2)
Exit 0
EndFunc
;------------------------------------------------------------------------------------------------------------
Func Terminate()
$Terminate = True
EndFunc ;==>Terminate
Alles anzeigen
lg
Chris