AutoHotkey Community

It is currently May 27th, 2012, 11:51 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: August 26th, 2010, 11:29 am 
Offline

Joined: March 27th, 2008, 7:46 pm
Posts: 129
Location: France
very kool, simple and very pratice :) i LOve this script .... thank's ...WileECoyote


Little-note> on my pc, for resolving the default of screen (spcified byXavierGr) ,
the code giving by Sean must be at the beginning of scipt (before the hotkeys),
not in the function SwitchToDesktop (newDesktop)

XavierGr wrote:
The annoying thing is that I can't make them disappear except if I kill the explorer.exe process (via task manager).
Sean wrote:
You may close it using this:
Code:
WinClose, ahk_class SysShadow


XavierGr wrote:
Ah! Thank you Sean, once again you are a life saver. :D


:D Me too great thank's for that
Code:
; ***** initialization *****
#WinActivateForce
; #NoTrayIcon
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
USE_PAUSE = 1000         ; Tray Tip Pause Length
lock = 0               ; lock to prevent running both hotkeys at same time
; AT the BEginning
   WinClose, ahk_class SysShadow
; ***** hotkeys *****

_________________
with ahk, all is different!...<img>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2010, 3:48 pm 
Offline

Joined: August 30th, 2010, 9:05 pm
Posts: 21
I have a proposition to make a new thread with this modifications, because author of main version is not interested (i think) in improving his version, and these modification of you are cool.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2010, 8:43 pm 
Offline
User avatar

Joined: December 5th, 2010, 7:19 pm
Posts: 311
yeah sure that a good idea.

Mabey a gui or a tray menu

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 1st, 2011, 3:48 pm 
I know this is thread is old and a new thread should be created but I'm lazy...

Anyway, a few people asked if a feature could be added to allow you to show particular windows on all desktops so here we go. Press Alt+v when on the window you want on all desktops, pressing Alt+v again will make it show only on the current desktop.

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Auto timers, usefull when debugging  ;
; turn off or set high to save cpu     ;
; when debug is done                   ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;SetTimer,AutoReloadScript,1000

; ***** initialization *****
#WinActivateForce

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
USE_PAUSE = 1000          ; Tray Tip Pause Length
lock = 0                  ; lock to prevent running both hotkeys at same time
ToolTipX = -1000          ; Tool Tip X position
ToolTipY = -1000          ; Tool Tip Y position

; ***** hotkeys *****
#v::
   AlwaysShowWindow()
return

#1::
   if(lock = 0)
   {
      lock = 1
      SwitchToDesktop(1)
   }
return

#2::
   if(lock = 0)
   {
      lock = 1
      SwitchToDesktop(2)       
   }
return

#3::
   if(lock = 0)
   {
      lock = 1
      SwitchToDesktop(3)       
   }
return

#4::
   if(lock = 0)
   {
      lock = 1
      SwitchToDesktop(4)       
   }
return

^!1::
   if(lock = 0)
   {
      lock = 1
      SendActiveToDesktop(1)       
   }
return

^!2::
   if(lock = 0)
   {
      lock = 1
      SendActiveToDesktop(2)
   }
return

^!3::
   if(lock = 0)
   {
      lock = 1
      SendActiveToDesktop(3)
   }
return

^!4::
   if(lock = 0)
   {
      lock = 1
      SendActiveToDesktop(4)             
   }
return

#0::goto, cleanup

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; AutoScriptReload/Suspend ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AutoReloadScript:
   FileGetAttrib,attribs,%A_ScriptFullPath%
   IfInString,attribs,A
   {
      FileSetAttrib,-A,%A_ScriptFullPath%
      ToolTip, %A_ScriptName% updated AutoHotkey script, %ToolTipX%, %ToolTipY%
      SetTimer, AutoReloadScriptToolTip, 2000
   }
return
AutoReloadScriptToolTip:
    SetTimer, AutoReloadScriptToolTip, Off
    ToolTip
    Reload
return

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

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

   WinGetActiveTitle, curWin   
   
   sleep, 200             
   
   ; Removes the chance of getting Start Menu Shadow Frozen on Screen
   if(curWin = "")
      WinActivate, Program Manager
       
   ; Removes the chance of getting Tray or Tooltip shadows frozen on screen
   ToolTip
   TrayTip
   WinClose, ahk_class SysShadow
       
   sleep, 200
   
   if (curDesktop <> newDesktop)
   {
      GetCurrentWindows(curDesktop)
      ShowHideWindows(curDesktop, false)
      ShowHideWindows(newDesktop, true)
      activate_window := % active_id%newDesktop%
      WinActivate, ahk_id %activate_window%
      ToolTip,  Switching to desktop %newDesktop%, %ToolTipX%, %ToolTipY%
      curDesktop := newDesktop
   }
   
   SetTimer, RemoveToolTip, %USE_PAUSE%
   sleep, 1000
   lock = 0
   
   return
}

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

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

   windows%newDesktop%%i% := windowID
   
   WinHide, ahk_id %windowID%
   ToolTip, Window sent to desktop %newDesktop%, %ToolTipX%, %ToolTipY%
   Send, {ALT DOWN}{TAB}{ALT UP}   ; activate the right window
   }
   
   SetTimer, RemoveToolTip, %USE_PAUSE%
}

; sends the currently active window to the given desktop
SendActiveToDesktop(newDesktop)
{

   global

   WinGet, id, ID, A
   
   WinGetActiveTitle, curWin   
   
   sleep, 200             
   
   ; If Window Does not have a title, do not send it
   if( (curWin = "") || (curWin = "Program Manager"))
   {
      lock = 0
      sleep, 1000
      return       
   }
   
   SendToDesktop(id, newDesktop)
   sleep, 1000
   lock = 0
}

; removes the given window id from the desktop <desktopIdx>
RemoveWindowID(desktopIdx, ID)
{
   global   
   Loop, % windows%desktopIdx%
   {
      if (windows%desktopIdx%%A_Index% = ID)
      {
         windows%desktopIdx%%A_Index%=      ;Emiel: just empty the array element, array will be emptied by next switch anyway
         Break
      }
   }
}

; this builds a list of all currently visible windows in stores it in desktop <index>
GetCurrentWindows(index)
{
   global
   WinGet, active_id%index%, ID, A                      ; get the current active window
   emptyString =
   StringSplit, windows%index%, emptyString             ; delete the entire windows_index_ array
   WinGet, windows%index%, List,,, Program Manager      ; get list of all visible windows

   ; remove windows which we want to see on all virtual desktops
   Loop, % windows%index%
   {
      id := % windows%index%%A_Index%
      WinGetClass, windowClass, ahk_id %id%
      if windowClass = Shell_TrayWnd     ; remove task bar window id
           windows%index%%A_Index%=      ; just empty the array element, array will be emptied by next switch anyway
      if windowClass = #32770            ; we also want multimontaskbar on all virtual desktops
           windows%index%%A_Index%=      ; just empty the array element, array will be emptied by next switch anyway
      if windowClass = cygwin/x X rl-xosview-XOsview-0   ; xosviews e.d.
           windows%index%%A_Index%=     
      if windowClass = cygwin/x X rl-xosview-XOsview-1   ; xosviews e.d.
           windows%index%%A_Index%=     
      if windowClass = MozillaUIWindowClass              ; Mozilla thunderbird
      {
        WinGet, ExStyle, ExStyle, ahk_id %id%
          if (ExStyle & 0x8)  ; 0x8 is WS_EX_TOPMOST.
           windows%index%%A_Index%=     
      }
      if alwaysShow%id% = 1
           windows%index%%A_Index%=
   }
}

; 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%
   }
}

AlwaysShowWindow()
{
    global
    WinGet, activeWindow, ID, A
    If alwaysShow%activeWindow%
    {
       alwaysShow%activeWindow%=
       ToolTipMessage := "Active window will no longer be shown on all desktops"
    }
    else
    {
       alwaysShow%activeWindow% := 1
       ToolTipMessage := "Active window will be on all desktops"
    }
    ToolTip, %ToolTipMessage%, %ToolTipX%, %ToolTipY%
    SetTimer, RemoveToolTip, %USE_PAUSE%
}

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

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return


I also added the code to remove the shadows (it may not have been the best place to do it but it works) and created variables for the X and Y positions of the Tooltips. I have my taskbar on the left side and find it annoying when things pop-up over my start button (I didn't move the tooltips on this script but they have been moved on the script I actually run).

By the way, I am new to AHK so if there is a better way to do this, please post it.

Great script by the way, thanks.


Report this post
Top
  
Reply with quote  
PostPosted: September 1st, 2011, 11:15 pm 
CelticSquirrel wrote:
Press Alt+v when on the window you want on all desktops, pressing Alt+v again will make it show only on the current desktop.


bahhh...Win+v not Alt+v, sorry.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2012, 11:43 am 
Offline

Joined: November 26th, 2010, 5:19 pm
Posts: 23
Oh how much i love AHK!!!!!

Thx for this wonderful Script.

_________________
Win 7 64bit
AHK 1.1.07.03 64bit Unicode


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, rrhuffy and 36 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group