qazwsx Posted October 30, 2007 Share Posted October 30, 2007 I am tryin to make a desktop manager similar to deskspace. This is what i have so far expandcollapse popup#include <A3LScreenCap.au3> #include <A3LClipboard.au3> #include <GUIConstants.au3> Global $Windows[200][6] ; [window number][desktopon] Global $windowcount Global $currentdesktop = 1 ;current desktop HotKeySet("1", "_one") HotKeySet("2", "_two") HotKeySet ("0", "_viewdesktops") $Form1 = GUICreate("Form1", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) $Pic1 = GUICtrlCreatePic("", 40, 40, 492, 468, BitOR($SS_NOTIFY,$WS_GROUP, $WS_CLIPSIBLINGS)) $Pic2 = GUICtrlCreatePic("", 624, 40, 492, 468, BitOR($SS_NOTIFY,$WS_GROUP, $WS_CLIPSIBLINGS)) $Button1 = GUICtrlCreateButton("Button1", 224, 568, 75, 25, 0) $Button2 = GUICtrlCreateButton("Button1", 880, 568, 75, 25, 0) GUISetState(@SW_HIDE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 GUISetState (@SW_HIDE) _gotodesktop (1) Case $Button2 GUISetState (@SW_HIDE) _gotodesktop (2) EndSwitch WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Window Switching Funcs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _getwindows($desktop) $windowlist = WinList() For $i = 0 To $windowlist[0][0] If $windowlist[$i][0] <> "" And $windowlist[$i][0] <> "program manager" And _IsVisible($windowlist[$i][1]) Then $Windows[$i][$desktop] = $windowlist[$i][1] EndIf Next EndFunc ;==>_getwindows Func _hide($desktop) For $i = 0 To 99 If $Windows[$i][$desktop] <> "" Then WinSetState($Windows[$i][$desktop], "", @SW_HIDE) Next EndFunc ;==>_hide Func _show($desktop) For $i = 0 To 99 If $Windows[$i][$desktop] <> "" Then WinSetState($Windows[$i][$desktop], "", @SW_SHOW) Next EndFunc ;==>_show Func _IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsVisible ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;Screen Shot funcs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _getscreen($desktop) Send("{printscreen}") Sleep(100) $Data = _Clip_GetData ($CF_BITMAP) $FileName = @ScriptDir & "\" & $desktop & ".bmp" _ScreenCap_SaveImage ($FileName, $Data) ClipPut("") ;FileSetAttrib($FileName, "+h") EndFunc ;==>_getscreen ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _gotodesktop($desktop) ;to show If $desktop <> $currentdesktop Then _getwindows($currentdesktop) _getscreen ($currentdesktop) _hide($currentdesktop) _show($desktop) $currentdesktop = $desktop EndIf EndFunc ;==>_gotodesktop Func _viewdesktops () _getscreen ($currentdesktop) GUISetState (@SW_SHOW) GUICtrlSetImage ($pic1, @ScriptDir & "\1.bmp") GUICtrlSetImage ($Pic2, @ScriptDir & "\2.bmp") EndFunc Func _one() _gotodesktop(1) EndFunc ;==>_one Func _two() _gotodesktop(2) EndFunc ;==>_two It can switch between 2 desktops. Use the 1 and 2 keys to switch and 0 to bring up screen shots of each desktop. This is more of a proof of concept than the final project. The hiding of windows and showing takes too long. Can anyone think of a better way for me to get the list of windows which are open and to only have my for loops go to the last occupied level? Also is this how most desktop managers work? If not could anyone tell me how they do? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now