Noch etwas ist seltsam: Befinden sich die fenster über jaPBe, flackert dieser und die Fenster! Auch geht die CPU auslastung von jaPBe hoch. Woran liegt das?
Achso, auch die Forensuche hat mir kein wirkliches Ergebniss zum thema always on top geliefert... Das Funktioniert bisher nicht so, wie´s soll
(Wie funktioniert das beim 40pix Player?)
Und noch eine Frage: Kann man direkt im Programm eine neue Liste erstellen, also
Code: Alles auswählen
For x=1 to 10
NewList "List"+str(x).type()
next
Code: Alles auswählen
Structure Windows
x.w
y.w
id.w
title.s
button.b
target.s
EndStructure
Global sini.w
Enumeration
#Winwin
#image
EndEnumeration
NewList Win.Windows()
Procedure.f GSin(winkel.f,speed.w)
preturn.f=Sin(winkel*(speed*3.14159265/360))
ProcedureReturn preturn
EndProcedure
Procedure.f GCos(winkel.f,speed.w)
preturn.f=Cos(winkel*(speed*3.14159265/360))
ProcedureReturn preturn
EndProcedure
Procedure SetWinTransparency(win,level)
If level>=0 And level<101
hLib = LoadLibrary_("user32.dll")
If hLib
adr = GetProcAddress_(hLib,"SetLayeredWindowAttributes")
If adr
SetWindowLong_(WindowID(win),#GWL_EXSTYLE,GetWindowLong_(WindowID(win),#GWL_EXSTYLE)|$00080000) ; #WS_EX_LAYERED = $00080000
CallFunctionFast(adr,WindowID(win),0,255*level/100,2)
EndIf
FreeLibrary_(hLib)
EndIf
EndIf
EndProcedure
Procedure.s GetAssociatedProgram(Extension.s)
Global AssociatedProgram$
hKey.l = 0
KeyValue.s = Space(255)
datasize.l = 255
AssociatedProgram$ = ""
If RegOpenKeyEx_(#HKEY_CLASSES_ROOT, "." + Extension, 0, #KEY_READ, @hKey) = #ERROR_SUCCESS
If RegQueryValueEx_(hKey, "", 0, 0, @KeyValue, @datasize) = #ERROR_SUCCESS
KeyNext.s = Left(KeyValue, datasize-1)
hKey.l = 0
KeyValue.s = Space(255)
datasize.l = 255
If RegOpenKeyEx_(#HKEY_CLASSES_ROOT, KeyNext + "\Shell\Open\Command", 0, #KEY_READ, @hKey) = #ERROR_SUCCESS
If RegQueryValueEx_(hKey, "", 0, 0, @KeyValue, @datasize) = #ERROR_SUCCESS
AssociatedProgram$ = Left(KeyValue, datasize-1)
EndIf
EndIf
EndIf
EndIf
Pos = FindString(LCase(AssociatedProgram$), ".exe", 1)
If Pos <> 0
AssociatedProgram$ = Left(AssociatedProgram$, Pos + 4)
AssociatedProgram$ = RemoveString(AssociatedProgram$, Chr(34), 1)
EndIf
ProcedureReturn AssociatedProgram$
EndProcedure
Procedure newWindow(x,y,name$,target$)
If AddElement(Win())
Win()\x=x
Win()\y=y
Win()\id=ListIndex(Win())+1
Win()\title=name$
Win()\button=100+ListIndex(Win())
Win()\target=target$
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure
CreateImage(0,40,40)
OpenWindow(#Winwin,1,1,1,1,#PB_Window_Invisible,"WinButtler")
newWindow(100,100,"TestWin",GetAssociatedProgram("html"))
newWindow(200,200,"TestWin2",GetAssociatedProgram("mp3"))
newWindow(300,300,"TestWin3",GetAssociatedProgram("doc"))
ForEach Win()
OpenWindow(Win()\id,Win()\x,Win()\y,40,40,#PB_Window_BorderLess,Win()\title,WindowID(#Winwin))
SetWinTransparency(Win()\id,60)
CreateGadgetList(WindowID(Win()\id))
ButtonImageGadget(Win()\button,0,0,40,40,0)
SHAppBarMessage_(#ABS_ALWAYSONTOP ,Win()\title)
Next
CreatePopupMenu(0)
MenuItem(1,"Test")
MenuItem(2,"Ende")
LoadImage(1,"buttler.ico")
AddSysTrayIcon(1,WindowID(#Winwin),UseImage(1))
Procedure ButtlerCallback(WindowID, Message, wParam, lParam)
result = #PB_ProcessPureBasicEvents
ForEach Win()
If WindowID(Win()\id)=WindowID
Break
EndIf
Next
WindowEvent()
Select Message
Case #WM_COMMAND
Select lParam
Case GadgetID(Win()\button)
MessageRequester("Fenster "+Str(Win()\id),Win()\target)
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
callback=SetWindowCallback(@ButtlerCallback())
Repeat
Delay(10)
If sini<360:sini+1:Else:sini=0:EndIf
lastmouseposX=DesktopMouseX()
lastmouseposY=DesktopMouseY()
;Goto weiter
UseWindow(#Winwin)
Event=WindowEvent()
If Event=#PB_EventSysTray
EventType=EventType()
If EventType=#PB_EventType_RightClick
DisplayPopupMenu(0,WindowID())
ElseIf EventType=#PB_EventType_LeftClick
ForEach Win()
win=UseWindow(Win()\id)
SetForegroundWindow_(win)
Next
EndIf
EndIf
;weiter:
ForEach Win()
;UseGadgetList(WindowID(Win()\id))
;win=UseWindow(Win()\id)
;SHAppBarMessage_(#ABS_ALWAYSONTOP,win)
;Debug win
;winevent=WindowEvent()
;If winevent<>#PB_Event_MoveWindow
; EGID=EventGadgetID()
; EWID=EventWindowID()
;EndIf
;Event=WindowEvent()
If Event=#WM_LButtonDown
move=0
Else
move=1
EndIf
UseWindow(Win()\id)
If move=1
;MoveWindow(DesktopMouseX()+(GCos(sini-(ListIndex(Win())*(360/CountList(Win()))),2)*50) ,DesktopMouseY()+10+(GSin(sini-(ListIndex(Win())*(360/CountList(Win()))),2)*50))
;move=0
;Else
;move=1
EndIf
;UseWindow(#Winwin)
;If winevent<> #PB_Event_MoveWindow And winevent<>#PB_Event_Repaint
; Debug "nicht bewegt?"
; Debug winevent
; Goto nomove
;EndIf
;test=WindowEvent()
;If test=#PB_Event_Gadget
; winevent=test
; EGID=EventGadgetID()
; EWID=EventWindowID()
;EndIf
;SkinWin(WindowID(Win()\id),ExtractIcon_(GetModuleHandle_(0), @FileName$, 0))
Win()\x=WindowX()
Win()\y=WindowY()
UseImage(0)
StartDrawing(ImageOutput())
FileName$=Win()\target
Box(0,0,40,40,RGB(200,200,255/Win()\id))
DrawImage(ExtractIcon_(GetModuleHandle_(0), @FileName$, 0),1,1,GadgetWidth(Win()\button)-1,GadgetHeight(Win()\button)-1)
StopDrawing()
SetGadgetState(Win()\button,UseImage(0))
;WindowEvent()
;If
; ForEach Win()
;win=UseWindow(Win()\id)
; If EWID
; win1=GetForegroundWindow_()
; SetForegroundWindow_(WindowID(EWID))
; Else
; SetForegroundWindow_(win1)
; EndIf
;Next
;EndIf
;winevent=WindowEvent()
; nomove:
;If EventWindowID()=Win()\id
; If winevent=#PB_Event_Gadget
; ;If Event = #PB_EventGadget
; SetWinTransparency(Win()\id,100)
; SetForegroundWindow_(WindowID())
; GadgetID=EventGadgetID()
;Debug GadgetID
; If GadgetID=Win()\button
; MessageRequester("Info","Auf Fenster "+Str(WindowID(Win()\id))+" geklickt!")
; EndIf
;Else
; SetWinTransparency(Win()\id,60)
;EndIf
;EndIf
;WindowEvent()
;If winevent<>#PB_Event_MoveWindow And winevent=#PB_Event_Gadget
; If EWID=Win()\id ; Event auf Fenster win()\id
; If EGID; Gadget gedrückt?
; Select EGID
; ; Hier die buttons von Fenster win()\id abfragen...
; Case Win()\button
; MessageRequester("Fenster "+Str(Win()\id),Win()\target)
; Delay(100)
; EndSelect
;EndIf
;While WindowEvent() : Wend ; Warten, damit Fenster korrekt wieder aufgebaut wird
;EndIf
; Etwa Fenster geschlossen?
; EndIf
If Event=#WM_RButtonDown
DisplayPopupMenu(0,WindowID(Win()\id));,DesktopMouseX(),DesktopMouseY())
EndIf
Next
If DesktopMouseX()-lastmouseposX >50 And DesktopMouseX()-lastmouseposX <200 And Int(erkenn/2)=erkenn/2
erkenn+1
ElseIf DesktopMouseX()-lastmouseposX < -50 And DesktopMouseX()-lastmouseposX >-200 And Int(erkenn/2)<>erkenn/2
erkenn+1
EndIf
;Debug DesktopMouseX()-lastmouseposX
If erkenn =>6
Debug "Erkannt!"
erkenn=0
ForEach Win()
win=UseWindow(Win()\id)
SetForegroundWindow_(win)
Next
EndIf
;Event=WindowEvent()
Until GetAsyncKeyState_(27)
KillThread(callback)
End