#include #include #include #include #include #include #include ;################################################# Décalaration des variables ####################################################################### _GDIPlus_Startup() ; Initialize Microsoft Windows GDI+ ;WinMove($hGUI, "", 0, 0, 200, 200) Global $AppTitle = "Mini-Win v0.3.3 Beta" Global $iWidth = 640 Global $iHeight = 480 Global $Longueur = 640 Global $Hauteur = 480 Global $Refresh = 1000 Global $Xoffset = 0, $Yoffset = 0 Global $XoffsetSCR = 0, $YoffsetSCR = 0 Global $Zoom Global $var, $MyListAppli = "" Global $MonHandle = 0 ;################################################# GUI principale Mini-Win ######################################################## $hParent = GUICreate($AppTitle, 640, 480,-1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) ; Création de la fenetre (GUI) de l'application ;$Menu_Config = GUICtrlCreateMenu("Configuration") ;$Menu_Config_Diplay = GUICtrlCreateMenuItem("Afficher", $Menu_Config) ;$Menu_Config_Hide = GUICtrlCreateMenuItem("Masquer", $Menu_Config) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent) ; Création d'un objey graphique a partir du handle de la fenetre GUISetState(@SW_SHOW, $hParent) ;################################################# GUI Secondaire config & reglage de Mini-Win ##################################### $GUI_Config = GUICreate("Configuration", 238, 440) ; , 268, 139 $Label_AppList = GUICtrlCreateLabel("Liste des Applications : ", 16, 8, 115, 17) $Combo_AppList = GUICtrlCreateCombo($MyListAppli, 24, 32, 161, 25) $Button_AppList_init = GUICtrlCreateButton("Re-innit", 144, 8, 73, 17, $WS_GROUP) $Label_SpeedDisplay_txt = GUICtrlCreateLabel("Vitesse de rafraichissement :", 16, 64, 138, 17) $Label_SpeedDisplay = GUICtrlCreateLabel("", 160, 64, 68, 17) $Slider_SpeedDisplay = GUICtrlCreateSlider(8, 80, 200, 25) GUICtrlSetLimit($Slider_SpeedDisplay, 200, 0) ; change min/max value GUICtrlSetData($Slider_SpeedDisplay, 100) $Label_Zoom_txt = GUICtrlCreateLabel("Zoom : ", 16, 112, 40, 17) $Label_Zoom = GUICtrlCreateLabel("", 64, 112, 84, 17) $Slider_Zoom = GUICtrlCreateSlider(8, 128, 200, 25) GUICtrlSetLimit($Slider_Zoom, 350, 1) ; change min/max value GUICtrlSetData($Slider_Zoom, 100) ; set cursor $Label_OffsetOri_txt = GUICtrlCreateLabel("Offset Orizontal : ", 16, 160, 85, 17) $Label_OffsetOri = GUICtrlCreateLabel("Offset", 112, 160, 60, 17) $Slider_OffsetOri = GUICtrlCreateSlider(8, 176, 200, 25) GUICtrlSetLimit($Slider_OffsetOri, 200, 0) ; change min/max value GUICtrlSetData($Slider_OffsetOri, 0) $Label_OffsetVer_txt = GUICtrlCreateLabel("Offset vertical : ", 16, 208, 78, 17) $Label_OffsetVer = GUICtrlCreateLabel("Offset", 112, 208, 60, 17) $Slider_OffsetVer = GUICtrlCreateSlider(8, 224, 200, 25) GUICtrlSetLimit($Slider_OffsetVer, 200, 0) ; change min/max value GUICtrlSetData($Slider_OffsetVer, 0) $CheckB_OnTop = GUICtrlCreateCheckbox("Fenetre Mini-Win au premier plan", 16, 264, 193, 17) $Label_WinSize = GUICtrlCreateLabel("", 16, 296, 200, 17) ;$Label_WinSize_scr = GUICtrlCreateLabel("", 16, 316, 200, 17) $Button_Quit = GUICtrlCreateButton("Quitter", 136, 400, 89, 25, $WS_GROUP) GUISetState(@SW_SHOW, $GUI_Config) ;################################################# Coeur du programme ############################################################# InitListAppli() While 1 $nMsg = GUIGetMsg() ; Gestion des evenement If $nMsg = $Button_AppList_init Then InitListAppli() ; condition pour ajuster le composant graphique si la taille change If $Longueur <> _WinAPI_GetWindowWidth($hParent) - 16 OR $Hauteur <> _WinAPI_GetWindowHeight($hParent) - 38 Then $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent) ; la taille du composant graphique se base sur la taille de la fenetre principale EndIf ;Pour que la fenetre MiniWin soit au premier plan ou pas If GUICtrlRead($CheckB_OnTop) = 1 Then WinSetOnTop($AppTitle, "", 1) Else WinSetOnTop($AppTitle, "", 0) EndIf ; permet de recuperer la taille exacte du composant graphique $Longueur = _WinAPI_GetWindowWidth($hParent) - 16 ;(suppression de la bordure sur le coté ) $Hauteur = _WinAPI_GetWindowHeight($hParent) - 38 ;(suppression de la bordure en haut et en bas) $hGUI = ListAppli(GUICtrlRead($Combo_AppList)); Recupere le handle d'une fenetre en fonction du nom selectione dans la Combobox If $nMsg = $Button_Quit Then Exit ; condition pour sortir du programme ; Lecture des differant Slider $Zoom = GUICtrlRead($Slider_Zoom)/100 ; Réglage du Zoom $Refresh = GUICtrlRead($Slider_SpeedDisplay)*10 ; reglage du rafraichissement de l'image ;$XoffsetSCR = GUICtrlRead($Slider_OffsetOri) ; lecture de l'offset horiziontal GUICtrlSetData($Label_SpeedDisplay,$Refresh/1000 & " sec"); affichage de la vitesse de rafraichissement GUICtrlSetData($Label_Zoom,Round(1/$Zoom,2) & " X") ; Affichage du Zoom GUICtrlSetData($Label_WinSize,"WinSize : " & $Longueur & " x " & $Hauteur) ;GUICtrlSetData($Label_WinSize_scr,"CheckBox : " & GUICtrlRead($CheckB_OnTop)) ; label de test _Display($hGUI, $iWidth * $Zoom , $iHeight * $Zoom ,$Xoffset, $Yoffset, $Refresh) ; Affichage d'une mini fenetre WEnd ;################################################# Functions ####################################################################### Func _Display($hGUI, $iWidth , $iHeight , $Xoffset, $Yoffset,$Refresh) ; permet d'afficher une fenetre capturé If $GUI_EVENT_CLOSE = GUIGetMsg() Then ; une autre condition pour sortire du programme Exit Endif Sleep($Refresh) ; temporisation , rafraichissement de l'image capturer $hBMP = _WinCapture($hGUI, $iWidth , $iHeight) ; fonction capturer une fenetre $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ; Création d'un objet Bitmap a partir du Handle ;_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight , $Xoffset, $Yoffset, 640 , 480) ; Creation d'un objet image _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, $XoffsetSCR, $YoffsetSCR, $iWidth, $iHeight , $Xoffset, $Yoffset, $Longueur , $Hauteur) _GDIPlus_ImageDispose($hImage) ; Affichage de l'image capturer _WinAPI_DeleteObject($hBMP) ; Destruction de l'objet Bitmap Endfunc Func _WinCapture($hWnd, $iWidth = -1, $iHeight = -1 ) ; permet de capturer une fenetre en fonction de son handle Local $iH, $iW, $hDDC, $hCDC, $hBMP ; initialisation des variables pardefaut If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) Return $hBMP EndFunc ;==>_WinCapture ; fonction pour initialiser et gere la liste des application Func ListAppli($Search = 1) For $i = 1 to $var[0][0] ; Recherche seulement les application visible qui on un titre If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then If $Search = 1 Then $MyListAppli = $var[$i][0] & "|" & $MyListAppli ; initialisation de la liste des applications ouverte ElseIf $Search = $var[$i][0] Then Return $var[$i][1] ; Retourne le handle d'une fenetre EndIf EndIf Next $MyListAppli = StringRight($MyListAppli,StringLen($MyListAppli) - 16) EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc ; Réinitialisation et/ou mise a jours de la liste des applications Func InitListAppli() $MyListAppli = "" GUICtrlSetData($Combo_AppList, $MyListAppli,"") $var = WinList() ; récupére la liste des Applications ouverte ListAppli() ; Creation de la liste des appli --> $MyListAppli GUICtrlSetData($Combo_AppList, $MyListAppli,"") ; initialisation de la Combo list EndFunc