AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiple virtual desktops
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
dash



Joined: 29 Nov 2006
Posts: 53

PostPosted: Wed Jan 24, 2007 8:02 pm    Post subject: Reply with quote

Very handy script!

Thanks for sharing
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 43

PostPosted: Tue Mar 20, 2007 10:21 pm    Post subject: Reply with quote

I love this script, I made a a GUI indicator (which shows which desktop is selected for 1 second) that fades out, so it really looks nice.

I have a major problem with it though.
Sometimes when repeatedly changing desktops, when I switch back some weird shades appear on my screen. I can't really describe it without a picture. But to see what I am saying just press the right button mouse somewhere on the screen to bring the context menu, and while the context menu is visible change to another desktop. When you return to the previous desktop you will see what I am talking about.

The annoying thing is that I can't make them disappear except if I kill the explorer.exe process (via task manager).

This is a picture of google with that weird window shade I get. (it is alwas on top):

_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
didier69



Joined: 21 Mar 2007
Posts: 11
Location: Lyon (France)

PostPosted: Thu Mar 29, 2007 8:20 am    Post subject: Reply with quote

Hello,

I really love this script. It's light and do exactely what I want.

I added two functions to go to the next desktop or to the back desktop:

Code:

NextDesktop()
{
   global
   
   if (curDesktop <= 3) {
      SwitchToDesktop(curDesktop+1)
   }

   else {
      SwitchToDesktop(1)
   }
   
}

BackDesktop()
{
   global
   
   if (curDesktop >= 2) {
      SwitchToDesktop(curDesktop-1)
   }

   else {
      SwitchToDesktop(4)
   }
   
}


But I have an issue with one application. I use slickrun to run all my applications. Yes I'm a command line addict user Smile. I would like to have slickrun on all my desktop and not only the one where it is launched.

Arrow Do you see how I can do this ?

Regards.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Musicwizard
Guest





PostPosted: Mon Apr 09, 2007 2:48 am    Post subject: Reply with quote

XavierGr wrote:
I love this script, I made a a GUI indicator (which shows which desktop is selected for 1 second) that fades out, so it really looks nice.


Could you give us that script I think it would be a really useful contribution to this project script.

And a really well done to WileECoyote for developing this script. It is really unique and very useful Very Happy

Thank you for your hard efforts
Back to top
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Mon Apr 09, 2007 4:53 am    Post subject: Reply with quote

XavierGr:
They are tooltip / window shadows.
Cool
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2219

PostPosted: Mon Apr 09, 2007 5:16 am    Post subject: Reply with quote

XavierGr wrote:
The annoying thing is that I can't make them disappear except if I kill the explorer.exe process (via task manager).

You may close it using this:

Code:
WinClose, ahk_class SysShadow
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 43

PostPosted: Sun Apr 15, 2007 2:44 am    Post subject: Reply with quote

Sean wrote:
XavierGr wrote:
The annoying thing is that I can't make them disappear except if I kill the explorer.exe process (via task manager).

You may close it using this:

Code:
WinClose, ahk_class SysShadow


Ah! Thank you Sean, once again you are a life saver. Very Happy

Now for the little GUI fading effect, this is my version.

Code:

; DesktopSwitch
;
; AutoHotkey Version: 1.0.40.00 (that's at least the version I'm using)
; Language:       English
; Platform:       Win9x/NT/XP
; Author:         Christian Sch?c_schueler@gmx.at>
; last changes:   22. Nov. 2005
;
; Script Function:
;
; A small tool for switching between multiple virtual desktops.
; Use Alt-<desktop index> (e.g. Alt-2) to switch between desktops and
; Alt-0 to quit the script, showing all windows on all virtual desktops
; at once. Currently, 4 desktops are supported, because more will start
; to confuse me...
;
; Version history:
;
; v1.11, 22. Nov. 2005
; Fixed bug: windows are now corrrectly activated after switching/sending
;
; v1.1, 05. Nov. 2005
; Added feature: pressing Ctrl/Alt-<index> sends the active window to the desktop <index>.
;
; v1.0, 04. Nov. 2005
; It works!
; Switching can be done using Alt-<desktop index>, e.g. Alt-1. Pressing
; Alt-0 will exit the script and show all windows from all virtual desktops
; at once.


; ***** initialization *****

SetBatchLines, -1   ; maximize script speed!
SetWinDelay, -1
OnExit, CleanUp      ; clean up in case of error (otherwise some windows will get lost)

numDesktops := 4   ; maximum number of desktops
curDesktop := 1      ; index number of current desktop

WinGet, windows1, List   ; get list of all currently visible windows

; Transparent Banner GUI
Gui, -Caption +ToolWindow +LastFound +AlwaysOnTop
Gui, Add, Picture, x0 y0, C:\Program Files\Autohotkey\Scripts\banner.png
Gui, Add, Text, x15 y5 w70 +BackgroundTrans vString

; ***** hotkeys *****

#MaxThreadsPerHotkey 6
!1::SwitchToDesktop(1)
!2::SwitchToDesktop(2)
!3::SwitchToDesktop(3)
!4::SwitchToDesktop(4)
#MaxThreadsPerHotkey 1

^!1::SendActiveToDesktop(1)
^!2::SendActiveToDesktop(2)
^!3::SendActiveToDesktop(3)
^!4::SendActiveToDesktop(4)

!0::ExitApp


; ***** functions *****

; switch to the desktop with the given index number
SwitchToDesktop(newDesktop)
{
   global

   if (curDesktop <> newDesktop)
   {
      GetCurrentWindows(curDesktop)

      ;WinGet, windows%curDesktop%, List,,, Program Manager   ; get list of all visible windows

      ShowHideWindows(curDesktop, false)
      ShowHideWindows(newDesktop, true)

      curDesktop := newDesktop

      Send, {ALT DOWN}{TAB}{ALT UP}   ; activate the right window
   }
   
   WinClose, ahk_class SysShadow
   ShowBanner("Desktop: " newDesktop)

   return
}

; sends the given window from the current desktop to the given desktop
SendToDesktop(windowID, newDesktop)
{
   global
   RemoveWindowID(curDesktop, windowID)

   ; add window to destination desktop
   windows%newDesktop% += 1
   i := windows%newDesktop%

   windows%newDesktop%%i% := windowID
   
   WinHide, ahk_id %windowID%

   Send, {ALT DOWN}{TAB}{ALT UP}   ; activate the right window
}

; sends the currently active window to the given desktop
SendActiveToDesktop(newDesktop)
{
   WinGet, id, ID, A
   SendToDesktop(id, newDesktop)
}

; removes the given window id from the desktop <desktopIdx>
RemoveWindowID(desktopIdx, ID)
{
   global   
   Loop, % windows%desktopIdx%
   {
      if (windows%desktopIdx%%A_Index% = ID)
      {
         RemoveWindowID_byIndex(desktopIdx, A_Index)
         Break
      }
   }
}

; this removes the window id at index <ID_idx> from desktop number <desktopIdx>
RemoveWindowID_byIndex(desktopIdx, ID_idx)
{
   global
   Loop, % windows%desktopIdx% - ID_idx
   {
      idx1 := % A_Index + ID_idx - 1
      idx2 := % A_Index + ID_idx
      windows%desktopIdx%%idx1% := windows%desktopIdx%%idx2%
   }
   windows%desktopIdx% -= 1
}

; this builds a list of all currently visible windows in stores it in desktop <index>
GetCurrentWindows(index)
{
   global
   WinGet, windows%index%, List,,, Program Manager      ; get list of all visible windows

   ; now remove task bar "window" (is there a simpler way?)
   Loop, % windows%index%
   {
      id := % windows%index%%A_Index%

      WinGetClass, windowClass, ahk_id %id%
      if windowClass = Shell_TrayWnd      ; remove task bar window id
      {
         RemoveWindowID_byIndex(index, A_Index)
         Break
      }
   }
}

; if show=true then shows windows of desktop %index%, otherwise hides them
ShowHideWindows(index, show)
{
   global

   Loop, % windows%index%
   {
      id := % windows%index%%A_Index%

      if show
         WinShow, ahk_id %id%
      else
         WinHide, ahk_id %id%
   }
}

ShowBanner(Text)
{
    global
    Trans := 255
   
    GuiControl, Text, String, % Text
    Gui, Show, x895 y677 h24 w92 NoActivate, MyTransparentBanner
    WinSet, Transparent, %Trans%, MyTransparentBanner
    Sleep 500
   
    Loop
    {
        if(Trans <= 0)
        {
            Trans := 0
            WinSet, Transparent, %Trans%, MyTransparentBanner
            break
        }
               
        WinSet, Transparent, %Trans%, MyTransparentBanner
        Trans := Trans - 5
        Sleep, 10
    }
   
    return
}

; show all windows from all desktops on exit
CleanUp:
Loop, %numDesktops%
   ShowHideWindows(A_Index, true)
ExitApp


The #MaxThreadsPerHotkey is used to enable fast desktop switching because without it you have to wait for the "fade out" to change to a new desktop.

On the GUI initialization, (line 46) change the path to a picture of your choice, the picture I used was captured from Microsoft's Intellitype crappy software.


Also change line 186 to place the little icon where ever you like on the screen.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
ToastBreak



Joined: 06 Sep 2007
Posts: 1

PostPosted: Thu Sep 06, 2007 2:28 pm    Post subject: Reply with quote

Firstly, awsome script! I have been trying to use the mess that comes with googDesktop and have been suffering. This is fast and efficient!

Really quick though, I actually have a problem where if I (accidentally) send a window to the current desktop I have to switch and switch back in order to see my window. Your code looks like it does a really nice job of keep track of things, so rather than change anything I simply added the same logical gate that is at the top of your SwitchToDesktop function, where:
Code:

if(curDesktop<>newDesktop)
{
   ;code
}


Also I really like to have the added functionality of being able to hold alt and hit the numberpad digits instead of the toprow numbers.

Just my two cents! Thanks again!

-T
Back to top
View user's profile Send private message
Andreone



Joined: 20 Jul 2007
Posts: 257
Location: Paris, France

PostPosted: Thu Sep 06, 2007 11:23 pm    Post subject: Reply with quote

Indeed it's a nice script.
I will think of using it.

Quote:
Also I really like to have the added functionality of being able to hold alt and hit the numberpad digits instead of the toprow numbers.

Put this with the tohers hotkeys:
Code:
!Numpad1::SwitchToDesktop(1)
!Numpad2::SwitchToDesktop(2)
!Numpad3::SwitchToDesktop(3)
!Numpad4::SwitchToDesktop(4)
Back to top
View user's profile Send private message
Trubbleguy



Joined: 20 Jan 2007
Posts: 88
Location: Melbourne

PostPosted: Fri Sep 07, 2007 12:21 am    Post subject: Reply with quote

I use this for onscreen display if im not using any Gui's
Code:

; create visual display
;YOU CAN CLICK THROUGH THIS AS IF IT IS NOT THERE
vkey=This is what im displaying
Progress,x100 y100 zh0 zy1 w300 H300 B c6 CW333333 CT777777 fs24,%vkey%,,Status ;no borders or box or anything but the text %vkey%
WinSet, TransColor,333333,Status ;makes background invisible Ct is the text color setting
;
; the following is used either in a sub replacing %vkey% with normal text, or set as a sub using vkey=text to display   
;and gosub splash
Sleep 2000 ; remove this if inserting into your code, i put this here so you could see the result
ControlSetText,,You can put anything up here,Status ; this updates the txt %vkey%
Sleep 2000 ; remove this if inserting into your code, i put this here so you could see the result
ControlSetText,,I find it very useful for progs without GUI's,Status ; this updates the txt %vkey%
Sleep 5000 ; remove this if inserting into your code, i put this here so you could see the result

splash:  ;this sub changes the txt in the onscreen display
ControlSetText,,%vkey%,Status ; this updates the txt %vkey%
Return
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
RandyTM



Joined: 14 Jun 2006
Posts: 3

PostPosted: Wed Sep 26, 2007 2:55 pm    Post subject: Pretty usefull! Reply with quote

Good work.. this is pretty damn usefull. I am gonna use it, thanx!
Back to top
View user's profile Send private message
tuna



Joined: 03 Oct 2007
Posts: 59
Location: Bristol, England

PostPosted: Tue Oct 09, 2007 9:17 pm    Post subject: Reply with quote

Nice script - just note that detecthiddenwindows, on causes problems with ShowHideWindows function - might be obvious now but it got pretty messy when i did an #include in a script.

Many thanks.
Back to top
View user's profile Send private message
dmsuperman
Guest





PostPosted: Sun Jan 13, 2008 11:02 pm    Post subject: Reply with quote

I have 2 suggestions:

1) Allow for, as an alternative to keycommands, Alt + Scroll Wheel. I've envisioned (but have been unable to produce) a virtual desktop where you hold alt and start scrolling, and an alt + tab-esque window comes up with the available desktops, then scroll to the right one and release alt. This would be amazing, but if you don't want to implement (even as just a mod, not to replace the original) that's alright.

2) The one feature I would really like in either is the ability to define windows that are global to all desktops. For example, my winamp window stays on my right monitor. It would be cool to keep it visible no matter which virtual desktop I'm on.


Other than that, fantastic script! Thanks!
Back to top
Guest






PostPosted: Tue Feb 26, 2008 9:46 pm    Post subject: Reply with quote

try this

step 1
if you're in desk 1, send a window to desk 1. (you now have a missing window. if you reload the script, it comes back)

step 2
switch to desk 2 (or desk 3, or desk 4, etc)

step 3
switch back to desk 1 (if you didn't reload in step1. your window is lost forever... and ever...)
Back to top
Guest






PostPosted: Tue Feb 26, 2008 10:04 pm    Post subject: Reply with quote

anyway to make it so that

Send window to desktop X is not possible when one is currently in desktop x
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group