Trouver le handle du bureau

Programmation d'applications complexes
Avatar de l’utilisateur
Chris
Messages : 3731
Inscription : sam. 24/janv./2004 14:54
Contact :

Message par Chris »

Pourquoi une horreur?

Tu veux le handle de la zone qui affiche les icônes? Tu l'as!

Maintenant, Monsieur le SUPER GENIE, si ca ne te plait pas, tu ne l'utilises pas. Point-barre !!!

Chris
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Message par nico »

ça, c'est tout lui!
Il pose une question, tu lui donne une réponse...
et en retour t'as droit a une remarque.. 8O
pas content il est, pas content il restera :x
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

mais si, je suis content d'avoir une réponse mais j'aimerai avoir une expliction sur ta méthode car je ne la comprends pas :cry:
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
Chris
Messages : 3731
Inscription : sam. 24/janv./2004 14:54
Contact :

Message par Chris »

Ah, bon!

Ben la prochaine fois, explique toi plus clairement. Parce que moi, quand je vois ça,
c'est quoi, cette horreur, tu peux expliquer comment tu as fait pour pondre ce truc, que je comprenne comment tu as fait, parce que la .... merci
j'ai tendance à trouver ça un peu aggressif. Mais, après tout, je suis peut-être le seul.

Je te signale, en passant, que ça m'a pris en gros 2 heures, (eh, oui, je ne suis pas rapide, je le sais...:lol:), pour "pondre" cette "horreur", comme tu l'appelles.

Pour ce qui est de la méthode, je me suis servi du petit prog que j'ai fait et qui donne le handle, le nom de classe, et tout un tas de renseignements, (taille, position, parents, etc...), sur l'objet qui est survolé par le pointeur de la souris, et du sdk de microsoft pour trouver des fonctions qui pourraient coller.

C'est tout!

Chris :)
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

oui, je l'ai et j'ai d'ailleurs essayer de sortir le handle du bureau avec le système de ton code mais sans succès.
j'avais essayé de choper de handle de la fenêtre sous la souris vu que j'ai forcément le bureau sous la souris mais sans succès.
d'ailleurs, en y réfléchissant, on peut aussi bien avaoir le handle de la barre des tâches, ç n'aurai jamais marché mon truc :?

merci, je vais reregarder ton code car visiblement, y'a un truc qui m'avait échappé.
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

La barre de rire avec ce code et ce sujet ! :D

On reconnait l'âme du breton :wink:

Mise à jour PB4.10

Code : Tout sélectionner

#Taille = 200 

NewList hWndList.l() 


; taille de la zone de l'écran utilisable (sans la barre des taches) 
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @Taille_Ecran.RECT, 0) 
Largeur_Ecran = Taille_Ecran\Right - Taille_Ecran\Left 
Hauteur_Ecran = Taille_Ecran\Bottom - Taille_Ecran\Top 

If OpenWindow(0, Taille_Ecran\Left, Taille_Ecran\Top, Largeur_Ecran, Hauteur_Ecran, "Affiche bureau", #PB_Window_Invisible | #PB_Window_BorderLess) 
  
  DC = GetDC_(0) 
  CreateImage(0, Largeur_Ecran, Hauteur_Ecran) 
  Dessin = StartDrawing(ImageOutput(0)) 
    BitBlt_(Dessin, 0, 0, Largeur_Ecran, Hauteur_Ecran, DC, 0, 0, #SRCCOPY) 
  StopDrawing() 
  ReleaseDC_(0, DC) 
  
  SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) ; choix de la barre d'outil réduite 
  ShowWindow_(WindowID(0), #SW_SHOW) ; montre la fenêtre 
  SetWindowPos_(WindowID(0), -1, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE) 
  
  If CreateGadgetList(WindowID(0)) 
    ImageGadget(0, 0, 0, Largeur_Ecran, Hauteur_Ecran, ImageID(0)) 
  EndIf 
  
  UpdateWindow_(WindowID(0)) 
  
  ; On pousse les fenêtres 
  hWnd.l = FindWindow_(0, 0) 
  While hWnd <> 0 
    If GetWindowLong_(Hwnd, #GWL_STYLE) & #WS_VISIBLE = #WS_VISIBLE 
      If GetWindowLong_(Hwnd, #GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW 
        GetWindowRect_(Hwnd, @Fen.RECT) 
        MoveWindow_(Hwnd, Fen\Left + Largeur_Ecran + 50, Fen\Top, Fen\Right - Fen\Left, Fen\Bottom - Fen\Top, #True) 
        AddElement(hWndList()) 
        hWndList() = Hwnd 
      EndIf 
    EndIf 
    hWnd = GetWindow_(hWnd, #GW_HWNDNEXT) 
  Wend 
  
  Timer = SetTimer_(WindowID(0), 0, 15, 0) 
  
  #HotKeyID = 45 
  RegisterHotKey_(WindowID(0), #HotKeyID, 0, #PB_Shortcut_Escape) 
  
  Bureau = 0 
  
  Repeat 
    Event = WaitWindowEvent() 
    Win = GetForegroundWindow_() 
    
    If Event = #WM_TIMER 
      ; position de la souris 
      GetCursorPos_(CursorPos.POINT) 
      
      Region1 = CreateRectRgn_(Taille_Ecran\Left, Taille_Ecran\Top, Taille_Ecran\Right, Taille_Ecran\Bottom) 
      Region2 = CreateEllipticRgn_(CursorPos\x - #Taille, CursorPos\y - #Taille, CursorPos\x + #Taille, CursorPos\y + #Taille) 
      
      CombineRgn_(Region1, Region1, Region2, #RGN_DIFF) 
      
      SetWindowRgn_(WindowID(0), Region1, #True) 
      UpdateWindow_(WindowID(0)) 
      
      DeleteObject_(Region1) 
      DeleteObject_(Region2) 
    EndIf 
    
    If Event = #WM_HOTKEY ; si on appui sur Echap 
      If EventwParam() = #HotKeyID 
        Win = -1 
      EndIf 
    EndIf 
    
    If Bureau = 0 And Win <> WindowID(0) 
      GetCursorPos_(CursorPos.POINT) 
      If CursorPos\x >= Taille_Ecran\Left And CursorPos\x <= Taille_Ecran\Right And CursorPos\y >= Taille_Ecran\Top And CursorPos\y <= Taille_Ecran\Bottom 
        Bureau = Win 
      EndIf 
    EndIf 
    
  Until (Win <> WindowID(0) And Win <> Bureau) Or Win = -1 
  
  UnregisterHotKey_(WindowID(0), #HotKeyID) 
  KillTimer_(WindowID(0), Timer) 
  
  ; On remet les fenêtres 
  ResetList(hWndList()) 
  While NextElement(hWndList()) 
    GetWindowRect_(hWndList(), @Fen.RECT) 
    MoveWindow_(hWndList(), Fen\Left - Largeur_Ecran - 50, Fen\Top, Fen\Right - Fen\Left, Fen\Bottom - Fen\Top, #True) 
  Wend 

EndIf
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

excellent ! :D

faudrai asservir cette effet a une touche clavier
ce pourrai etre un utilitaire interressant alors !! :D
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Avec AddKeyboardShortCut, non ?
Avatar de l’utilisateur
Chris
Messages : 3731
Inscription : sam. 24/janv./2004 14:54
Contact :

Message par Chris »

Dobro a écrit :excellent ! :D

faudrai asservir cette effet a une touche clavier
ce pourrai etre un utilitaire interressant alors !! :D
Serait peut-être temps de t'en apercevoir. Il y a déjà plus de trois ans qu'il est là, ce code! (8 avril 2004) :lol:
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

(J'ai mis un peu de son - merci dobro :wink: - parce que je m'y perdais avec sa capture!)

Code : Tout sélectionner

; Code du soldat inconnu bidouillé pour être activé/désactivé avec un double-clic sur F11
; 

Global m_hMidiOut,m_MIDIOpen.b 

Procedure SendMIDIMessage(nStatus.l,nCanal.l,nData1.l,nData2.l) 
  dwFlags.l = nStatus | nCanal | (nData1 << 8 ) | (nData2 << 16) 
  temp.l = midiOutShortMsg_ (m_hMidiOut,dwFlags) ; 
   If temp<>0 
     MessageRequester ( "Problème" , "Erreur dans l'envoi du message MIDI" ,0) 
   EndIf 
EndProcedure 
Procedure MIDIOpen() 
   If m_MIDIOpen = 0 
     If midiOutOpen_ (@m_hMidiOut,MIDIMAPPER,0,0,0) <> 0 
       MessageRequester ( "Problème" , "Impossible d'ouvrir le périphérique MIDI" ,0) 
     Else 
      SendMIDIMessage($C0,0,0,0) 
      m_MIDIOpen = 1 
     EndIf 
   EndIf 
EndProcedure 
Procedure PlayNoteMIDI(Canal.b,Note.b,VelociteDown.b,VelociteUp.b) 
   If m_MIDIOpen 
    SendMIDIMessage($80 | Canal,0,Note,VelociteDown) 
    SendMIDIMessage($90 | Canal,0,Note,VelociteUp) 
   EndIf 
EndProcedure 
Procedure ChargeInstrument(Canal.b,Instrument.b) 
   If m_MIDIOpen 
    SendMIDIMessage($C0 | Canal,0,Instrument,0) 
   EndIf 
EndProcedure 
#Taille = 200 

NewList hWndList.l() 


; taille de la zone de l'écran utilisable (sans la barre des taches) 
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @Taille_Ecran.RECT, 0) 
Largeur_Ecran = Taille_Ecran\Right - Taille_Ecran\Left 
Hauteur_Ecran = Taille_Ecran\Bottom - Taille_Ecran\Top 

MIDIOpen()
ChargeInstrument(0, 127)
ChargeInstrument(1, 1)

Repeat

For nq = 1 To 1
  PlayNoteMidi(1, 50, 0, 127)
  Delay(100)
Next
  Repeat
    Delay(5)
    xxx = GetKeyState_(#VK_F11)
  Until xxx = -128
  
For nq = 1 To 3
  PlayNoteMidi(0, 50, 0, 127)
  Delay(100)
Next

If OpenWindow(0, Taille_Ecran\Left, Taille_Ecran\Top, Largeur_Ecran, Hauteur_Ecran, "Affiche bureau", #PB_Window_Invisible | #PB_Window_BorderLess) 
  
  DC = GetDC_(0) 
  CreateImage(0, Largeur_Ecran, Hauteur_Ecran) 
  Dessin = StartDrawing(ImageOutput(0)) 
    BitBlt_(Dessin, 0, 0, Largeur_Ecran, Hauteur_Ecran, DC, 0, 0, #SRCCOPY) 
  StopDrawing() 
  ReleaseDC_(0, DC) 
  
  SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) ; choix de la barre d'outil réduite 
  ShowWindow_(WindowID(0), #SW_SHOW) ; montre la fenêtre 
  SetWindowPos_(WindowID(0), -1, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE) 
  
  If CreateGadgetList(WindowID(0)) 
    ImageGadget(0, 0, 0, Largeur_Ecran, Hauteur_Ecran, ImageID(0)) 
  EndIf 
  
  UpdateWindow_(WindowID(0)) 
  
  ; On pousse les fenêtres 
  hWnd.l = FindWindow_(0, 0) 
  While hWnd <> 0 
    If GetWindowLong_(Hwnd, #GWL_STYLE) & #WS_VISIBLE = #WS_VISIBLE 
      If GetWindowLong_(Hwnd, #GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW 
        GetWindowRect_(Hwnd, @Fen.RECT) 
        MoveWindow_(Hwnd, Fen\Left + Largeur_Ecran + 50, Fen\Top, Fen\Right - Fen\Left, Fen\Bottom - Fen\Top, #True) 
        AddElement(hWndList()) 
        hWndList() = Hwnd 
      EndIf 
    EndIf 
    hWnd = GetWindow_(hWnd, #GW_HWNDNEXT) 
  Wend 
  
  Timer = SetTimer_(WindowID(0), 0, 15, 0) 
  
  #HotKeyID = 45 
  RegisterHotKey_(WindowID(0), #HotKeyID, 0, #PB_Shortcut_Escape) 
  
  Bureau = 0
  
  
  Repeat 
    Event = WaitWindowEvent()
    Win = GetForegroundWindow_() 

    If 1
      If Event = #WM_TIMER 
        ; position de la souris 
        GetCursorPos_(CursorPos.POINT) 
      
        Region1 = CreateRectRgn_(Taille_Ecran\Left, Taille_Ecran\Top, Taille_Ecran\Right, Taille_Ecran\Bottom) 
        Region2 = CreateEllipticRgn_(CursorPos\x - #Taille, CursorPos\y - #Taille, CursorPos\x + #Taille, CursorPos\y + #Taille) 
      
        CombineRgn_(Region1, Region1, Region2, #RGN_DIFF) 
      
        SetWindowRgn_(WindowID(0), Region1, #True) 
        UpdateWindow_(WindowID(0)) 
      
        DeleteObject_(Region1) 
        DeleteObject_(Region2) 
      EndIf
    EndIf
    
    If GetKeyState_(#VK_F11) = -128
      Win = -2
    EndIf
    
    If Event = #WM_HOTKEY ; si on appui sur Echap 
      If EventwParam() = #HotKeyID 
        Win = -1 
      EndIf 
    EndIf 
    
    If Bureau = 0 And Win <> WindowID(0) 
      GetCursorPos_(CursorPos.POINT) 
      If CursorPos\x >= Taille_Ecran\Left And CursorPos\x <= Taille_Ecran\Right And CursorPos\y >= Taille_Ecran\Top And CursorPos\y <= Taille_Ecran\Bottom 
        Bureau = Win 
      EndIf 
    EndIf 
    
  Until (Win <> WindowID(0) And Win <> Bureau) Or Win = -1 Or Win = -2
  
  UnregisterHotKey_(WindowID(0), #HotKeyID) 
  KillTimer_(WindowID(0), Timer) 
  
  ; On remet les fenêtres 
  ResetList(hWndList()) 
  While NextElement(hWndList()) 
    GetWindowRect_(hWndList(), @Fen.RECT) 
    MoveWindow_(hWndList(), Fen\Left - Largeur_Ecran - 50, Fen\Top, Fen\Right - Fen\Left, Fen\Bottom - Fen\Top, #True) 
  Wend 

EndIf

CloseWindow(0)

Until Win <> -2
Répondre