AutoHotkey Community

It is currently May 27th, 2012, 1:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Move desktop icons
PostPosted: January 7th, 2010, 6:26 pm 
Hi I was wondering
(1)
how to move/slide the desktop icons to the left and back in given that the following does not work ( am already aware of the different ways of hidding the desktop icons but I wanted to know how to move the icons)
Code:
WinMove, Program Manager,  ,10, 20


(2)
Why the following does not work


Code:
#Persistent
SetWinDelay, -1
SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos, X, Y, id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
If (%title% := Program Manager) and ( X < 200 )
   
   x = 0
   
   loop, 200
   {
   x := x + 1
   
   winmove, Program Manager, , %x%
   }
   sleep, 5000

   loop, 200
   {
   x := x - 1
   
   winmove, Program Manager, , %x%
   }
   
return



Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 8th, 2010, 4:16 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
I don't know it will work, but at least some errors in the expression:
Code:
If (title = Program Manager) and ( X < 200 )
Namely:
AHK Help file wrote:
Variable names in an expression are not enclosed in percent signs


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 8th, 2010, 8:29 pm 
Thanks Peter,any ideas why the winmove part does not work?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2010, 7:27 am 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
I've missed a third error in your if-expression :oops: .
But I would adapt your code as follows: (I placed Tooltips, safer for my testing)
Code:
   #Persistent
   SetWinDelay, -1
   SetTimer, WatchCursor, 100
return

WatchCursor:
   CoordMode, Mouse, Screen
   MouseGetPos, X, Y, id, control
   WinGetTitle, title, ahk_id %id%
   ; WinGetClass, class, ahk_id %id%
   tooltip %title% %x%
   If (title = "Program Manager") and ( X < 200 ) {
      SetTimer, WatchCursor, off
     
      x = 0
      loop, 200
      {
         x := x + 1
         tooltip WinMove+
         ; winmove, Program Manager, , %x%
      }
      sleep, 5000
   
      loop, 200
      {
         x := x - 1
         tooltip WinMove-
         ; winmove, Program Manager, , %x%
      }
     
      tooltip WinMove End
      SetTimer, WatchCursor, on
   }
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2010, 11:58 am 
Thanks for the 'if' tip.
However, I still cannot find a way to move the icons as "winmove, Program Manager, , %x%" just does not work.

Any ideas?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2010, 1:05 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
I was wondering before also, is your 1-line code working? (I didn't try, because it maybe messes up my desktop.)
Code:
WinMove, Program Manager,  ,10, 20
Just to be sure :) .


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2010, 10:48 pm 
i have tried both
Code:
WinMove, Program Manager,,10, 20
and
Code:
WinMove, Program Manager,  ,10, 20
but neither work!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2010, 2:07 am 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
Very funny :roll: :)
Guest wrote:
(2)
Why the following does not work
Why on earth do you ask this, if (1) is not working :?:
So your problem/question is
Quote:
How to move Desktop window?
I don't know, probably protect Windows it from being moved.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 10:57 pm 
Am I doing something wrong with the exit command?

if I remove the last 3 lines everything works fine!
Code:
   #Persistent
#singleinstance, force
   SetWinDelay, -1
PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
   SetTimer, WatchCursor, 100
return
WatchCursor:
   CoordMode, Mouse, Screen
   MouseGetPos, X, Y, id, control
   WinGetTitle, title, ahk_id %id%
   ; WinGetClass, class, ahk_id %id%
   ;tooltip %title% %x%
   If (title = "Program Manager") and ( X < 200 ) {
      SetTimer, WatchCursor, off
     
      x = 1
      ;loop, 254
      loop, 1
      {
         x := x + 1
         ;tooltip WinMove+
         ; winmove, Program Manager, , %x%
    ;WinSet, Transparent, %x%, Program Manager
    PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
      }
      sleep, 3000
   
      ;loop, 254
      loop, 1
      {
         x := x - 1
         ;tooltip WinMove-
         ; winmove, Program Manager, , %x%
    ;WinSet, Transparent, %x%, Program Manager
    PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
      }
     
      ;tooltip WinMove End
      SetTimer, WatchCursor, on
   }
return

EXIT:
PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
ExitApp


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2010, 9:41 am 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
Guest wrote:
Am I doing something wrong with the exit command? if I remove the last 3 lines everything works fine!
1. What's not working fine if you don't remove them?I can't see a problem.
2. Exit: is a label. You want to jump there on exit of script I guess, so add the Onexit command:
Code:
   #Persistent
#singleinstance, force
   SetWinDelay, -1
   PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
   OnExit Exit
   SetTimer, WatchCursor, 100
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2010, 12:20 pm 
u c, when the program starts it hides the desktop icons.
upon hover, it shows them and then hides them.
the problem is that upon exit, the icons stay hidden.So I was trying on exit command to make the icons appear again.

When I remove the last 3 lines in my previous post the program works fine but on exit does not make the icons appear again.Been messing around with on exit command but no luck

Code:
#Persistent
#singleinstance, force
SetWinDelay, -1
;PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
;PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
OnExit Exit
SetTimer, WatchCursor, 100
return
WatchCursor:
   CoordMode, Mouse, Screen
   MouseGetPos, X, Y, id, control
   WinGetTitle, title, ahk_id %id%
   ; WinGetClass, class, ahk_id %id%
   ;tooltip %title% %x%
   If (title = "Program Manager") and ( X < 200 ) {
      SetTimer, WatchCursor, off
     
      x = 1
      ;loop, 254
      loop, 1
      {
         x := x + 1
         ;tooltip WinMove+
         ; winmove, Program Manager, , %x%
    ;WinSet, Transparent, %x%, Program Manager
    PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
      }
      sleep, 3000
   
      ;loop, 254
      loop, 1
      {
         x := x - 1
         ;tooltip WinMove-
         ; winmove, Program Manager, , %x%
    ;WinSet, Transparent, %x%, Program Manager
    PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
      }
     
      ;tooltip WinMove End
      SetTimer, WatchCursor, on
   }
return

EXIT:
PostMessage, 0x111, 29698,,, ahk_class Progman ; SHOW DESKTOP ICONS (TOGGLE)
ExitApp


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2010, 12:57 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
guest wrote:
u c, when the program starts it hides the desktop icons.
Not anymore, because you made it comment. I uncommented it for testing.
guest wrote:
the problem is that upon exit, the icons stay hidden
I don't have that problem.
But the problem with that hide trick is, that you must exit the script when the icons are hidden, because it toggles the desktop icons.
To test whether you enter OnExit routine, place a MsgBox in it.
And you can clean up your code, especially for posting, 50% of it isn't necessary (from WinMove).

PS: I have the problem that minimizing all windows doesn't show the desktop completely, only when forced a show-desktop. In short, it gives redraw problems of the desktop, also after exit the script. That's why I was afraid to run it at first.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2010, 3:26 pm 
U are right works perfect now.

Thanks a lot Peter.Really appreciate your help. :)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, Ohnitiel and 15 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