Deutsches AutoHotkey Homepage AutoHotkey Community
Wir helfen uns gegenseitig aus der Patsche
 
 FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   RegistrierenRegistrieren 
 ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin 

Uhr auf Desktop

 
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe!
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
BMP
Gast





BeitragVerfasst am: Mi Nov 29, 2006 12:23 pm    Titel: Uhr auf Desktop Antworten mit Zitat

Ich habe mir ein schönes Desktopbild besorgt. Dort will ich nun eine Uhr mit einbauen.

Die Uhr habe ich ein wenig abgeändert aus einem anderen Skript übernommen.
Nur habe ich noch ein paar kleine Probleme:

1. Die Uhr soll nur auf dem Desktop angezeigt werden.
2. Das Fenster soll natürlich nicht in der Taskbar auftauchen.
3. Beim aufrufen wird das Hintergrundbild z.T. um einige Pixel verschoben. Gibt es einen Befehl um den Desktop zu refreschen ?

Hier mal der vorhandene CODE:


Code:
#NoTrayIcon
#SingleInstance ignore
 
SET1= -CAPTION -SysMenu -ToolWindow
SET2= -AlwaysOnTop -SysMenu -ToolWindow
SET3= x340 y260 w400 h400
SET4= 012345 125
Start:
;;###################################################
;;##         Compiler Version 1.0.43.00            ##
;;##                                               ##
;;## SUBJECT:   GRAPHICS                           ##
;;## AUTHOR :   Dave Perrée  March 2006            ##
;;## PROGRAM:   DEMO ANALOG CLOCK Ver 1.00         ##
;;##                                               ##
;;###################################################

SetTimer,working,100
2pi := 2*3.1415926
GUI, -SysMenu
Gui,Show, W193 H168, AhkClock_01 
;; Get handle to window we've created
hwndA := DllCall("GetActiveWindow")
;;#############################################################################
;; Some trickery! As we've made no provision to handle WM_Paint messages, the     
;; resulting display would be rather messy unless of course we never moved     
;; another window over it. The first line below is the minimum required and
;; does not affect the appearance of the window.
;; It is this line OR the one below it that fools AHK into being responsible
;; for handling the paint messages. Note also the position of the gui,-caption
;; Try remming out the winset line to see how it would appear :)
;; Not a pretty sight eh!
;;#############################################################################
;Winset,Transparent,255,AhkClock_01
Winset,Transcolor,%SET4%,AhkClock_01
WinGet Tray_ID, ID, ahk_class Shell_TrayWnd
Gui %SET1%
Gui %SET2%
Gui Show, %SET3%
Gosub ONCEONLY
Gosub working  ; kick straight in
Return

guiclose:
gosub ReleaseGraphics
exitapp

ONCEONLY:
;; will last for duration of program
_xx := 0   ; x cord of canvas area
_yy := 0   ; y cord   ""
_ww := 600   ; width    ""
_hh := 600   ; height   ""
gosub CreateStruc
gosub CreateBckBuffer
RETURN

Working:
;; NB: all colors in API are BGR tuples
;; popup if computer is idle > 10 minutes
IfGreater, A_TimeIdle, 600000
 winactivate,AhkClock

;; Use a rectangle to clear the canvas (invisible colour!)
hBrush  := DllCall("CreateSolidBrush", UInt,0x452301)
DllCall("SelectObject" ,UINT,memDC,uint,hBrush)
DllCall("FillRect", UInt, MemDC, Str, Rect, UInt, hBrush)
DllCall("DeleteObject", UInt, hBrush)


;;
;; HOUR HAND
HANDpos := 2pi*(((A_hour+A_min/60)*5)/60) ; creeps by minutes
hlen = 145
wide = 8
hcol := Bgr(255,150,0)
GOSUB DRAW_HAND
;;
;; MINUTE HAND
HANDpos := 2pi*((A_min/60)+(A_sec/3600)) ; creeps by seconds
HLEN = 165
WIDE = 6
HCOL := Bgr(0,255,0)
GOSUB DRAW_HAND
;; SECOND HAND
HANDpos := 2pi*(A_sec/60)
HLEN = 190
WIDE = 2
HCOL := Bgr(0,0,255)
GOSUB DRAW_HAND
;;


gosub UpdateScreen

^LButton::
CoordMode, Mouse  ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.


EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U  ; Button has been released, so drag is complete.
{
   SetTimer, EWD_WatchMouse, off
   return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D  ; Escape has been pressed, so drag is cancelled.
{
   SetTimer, EWD_WatchMouse, off
   WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
   return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1   ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX  ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY

return



;;#############################################################################
;;             +++++++++++ END OF PROGRAM SECTION ++++++++++++++
;;#############################################################################

Bgr(_blu,_grn,_red)
{
return (_blu << 16 | _grn << 8 | _red) 
}

DRAW_HAND:
POSX := _ww/2 + hlen*COS(HANDpos-2pi/4)
POSY := _hh/2 + hlen*SIN(HANDpos-2pi/4)

hCurrPen := DllCall("CreatePen" ,uint,0,uint,wide,uint,hcol)
DllCall("SelectObject" ,UINT,memDC,uint,hCurrPen)
DllCall("MoveToEx" ,UINT,memDC, UINT,_ww/2,UINT,_hh/2,UINT,0)
DllCall("LineTo" ,UINT,memDC,UINT,POSX,UINT,POSY)
DllCall("DeleteObject", UInt, hCurrPen)
RETURN

CreateStruc:
VarSetCapacity(Rect, 16, 0)
InsertInteger(0,rect,0)   ; always zero
InsertInteger(0,rect,4)   ; always zero
InsertInteger(_ww,rect,8)
InsertInteger(_hh,rect,12)
Return

CreateBckBuffer:
ScreenDC := DllCall("GetDC", uint,hwndA)
MemDC    := DllCall("CreateCompatibleDC",uint,ScreenDC)
MemBM    := DllCall("CreateCompatibleBitmap",uint,ScreenDC ,uint,_ww,uint,_hh)
DllCall("SelectObject",uint,MemDC,uint,MemBM)
Return

ReleaseGraphics:
DllCall("ReleaseDC", UInt, 0, UInt, ScreenDC)
DllCall("DeleteObject", UInt,MemDC)
DllCall("DeleteObject", UInt,MemBM)
Return

UpdateScreen:
DllCall("BitBlt"
  ,Uint,ScreenDC,uint,_xx,uint,_yy,uint,_ww,uint,_hh
  ,Uint,MemDC,uint,0,uint,0,Uint
  ,0x00CC0020) ;; Srccopy As Is
Return



InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
; The caller must ensure that pDest has sufficient capacity.
; To preserve any existing contents in pDest,
; only pSize number of bytes starting at pOffset are altered in it.
{
   Loop %pSize% 
   DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index-1
   , UInt, 1, UChar, pInteger >> 8*(A_Index-1) & 0xFF)


}


Transparenz:

goto START

Hilfe:

Exit:
  ExitApp
Nach oben
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe! Alle Zeiten sind GMT
Seite 1 von 1

 
Gehe zu:  
Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.


Powered by phpBB © 2001, 2005 phpBB Group
Deutsche Übersetzung von phpBB.de