AutoHotkey Community

It is currently May 26th, 2012, 4:28 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: February 16th, 2009, 9:01 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
Laszlo wrote:
Which version does not work (Recent = ...)? In XP Recent = %HOME%\Recent should work, unless you added (or implicitly included) #NoEnv to your script. In that case you could add a line "EnvGet Home, Home" to the beginning of your script.


this worked in my xp environment:

Code:

#Persistent
CoordMode Mouse, Screen
CoordMode Menu,  Screen
Recent = %USERPROFILE%\Recent
...

________
Video review


Last edited by webber on February 11th, 2011, 5:56 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 10:26 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
Laszlo wrote:
Which version does not work (Recent = ...)? In XP Recent = %HOME%\Recent should work, unless you added (or implicitly included) #NoEnv to your script. In that case you could add a line "EnvGet Home, Home" to the beginning of your script.


just fyi, for me %home%/recent didnt work, I had to change it to
%userprofile%/recent. I'm on winxp sp3.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: use as generic include ?
PostPosted: February 17th, 2009, 12:31 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
how might I alter this so I can use it as a generic include to enable GUI's to slide out from a hot edge ?

Seems like everything is tied to a menu name. Can we work on making this more like a wrapper ?

For example:

i have a GUI window which slides out with a #Tab hotkey.

Is there a way to send that hotkey combo when the mouse is at the left edge of the screen ?
________
TOYOTA P TRANSMISSION


Last edited by webber on February 11th, 2011, 5:56 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2009, 1:25 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
In the last line of the Edge subroutine replace the Menu command with the action you want. Sending a key is probably not a good idea, because AHK does not react to artificial keystrokes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: this is my new include
PostPosted: February 17th, 2009, 5:02 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
my include however, doesn't seem to get called or activated


Code:
#Persistent
CoordMode Mouse, Screen

XX := 0 "," 190 "," A_ScreenWidth -185 "," A_ScreenWidth -2 "," 9999
StringSplit XX, XX, `,              ; Region boundaries
YY := 0 "," 190 "," A_ScreenHeight-185 "," A_ScreenHeight-2 "," 9999
StringSplit YY, YY, `,

Loop 5                              ; MenuXY <- desired menu.
   Menu1%A_Index% = LeftMenu        ; 11 21 31 41 51    Left  1Y
Loop 5                              ; 12 22 32 42 52    Right 5Y
   Menu%A_Index%1 = TopMenu         ; :    ....    :    Top   X1
                                    ; 15 25 35 45 55    Botm  X5

SetTimer Edge, 150
Return

Edge:
   MouseGetPos X, Y
   P0 = %Pos%                       ; Previous mouse position
      msgbox, %PO%

   Loop 5
      If (X <= XX%A_Index%) {
         Pos = %A_Index%            ; X region
         Break
      }
   Loop 5
      If (Y <= YY%A_Index%) {
         Pos = %Pos%%A_Index%       ; Position = XregionYregion
         Break
      }
   Pcount := Pcount*(P0=Pos) + 1    ; How long in this region
   If (Pcount <> 4 or Menu%Pos% = "")
      Return
   gosub, ShowGUI
Return



the hotkey still works but nothing happens when the mouse gets to the left edge of the screen.
________
Iv-2220


Last edited by webber on February 11th, 2011, 5:57 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2009, 12:00 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Code:
#Persistent
CoordMode Mouse, Screen

XX := 0 "," 190 "," A_ScreenWidth -185 "," A_ScreenWidth -2 "," 9999
StringSplit XX, XX, `,              ; Region boundaries
YY := 0 "," 190 "," A_ScreenHeight-185 "," A_ScreenHeight-2 "," 9999
StringSplit YY, YY, `,

Loop 5                              ; MenuXY <- desired menu.
   Menu1%A_Index% = LeftMenu        ; 11 21 31 41 51    Left  1Y
Loop 5                              ; 12 22 32 42 52    Right 5Y
   Menu%A_Index%1 = TopMenu         ; :    ....    :    Top   X1
                                    ; 15 25 35 45 55    Botm  X5
Pcount = 1

SetTimer Edge, 250
Return

Edge:
   MouseGetPos X, Y
   P0 = %Pos%                       ; Previous mouse position
   Loop 5
      If (X <= XX%A_Index%) {
         Pos = %A_Index%            ; X region
         Break
      }
   Loop 5
      If (Y <= YY%A_Index%) {
         Pos = %Pos%%A_Index%       ; Position = XregionYregion
         Break
      }
   Pcount := Pcount*(P0=Pos) + 1    ; How long in this region
   If (Pcount <> 4 or Menu%Pos% = "")
      Return
   GoSub % Menu%Pos%
Return

LeftMenu:
   MsgBox Do LEFT-actions here
Return

TopMenu:
   MsgBox Do TOP-actions here
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2009, 6:55 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
thanks,

I couldn't get it to work as a simple include, but I was able to integrate it into my exisitng script.

Now it pulls my listbox out from the edge with the mouse or by hotkey

:D
________
Medical Marijuana Dispensary


Last edited by webber on February 11th, 2011, 5:57 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2009, 7:06 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You can include the script in the usual way, although it was not written as a module (global variables could conflict with your code):
Code:
GoSub InitEdge

; your auto-execute code here

Return

InitEdge:
#Include Edge.ahk ; give the right filename


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2009, 8:41 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
Laszlo, thanks, this is a cool script. I found it very useful to find applications that I'd opened over different desktops (I use a window manager), without having to hunt for them now.


Some comments/questions:

1. I added some calls in the top menu to open up already opened apps instead of creating new ones, if they exist e.g.

Code:
Menu TopMenu, Add, outlook, outlooksub


outlooksub:
Run, C:\Progra~1\Microsoft Office\OFFICE11\OUTLOOK.EXE /recycle
return


2. #1 is possible for apps from MS that has a /recycle mode, but for those that don't e.g. Firefox/Thunderbird, the subroutines calls existing windows first i.e. winexist, winactivate etc.

3. I don't know how to apply the above techniques and your script to gvim however. At any time, I'll have gvim windows open all over my desktops (these are different files being edited e.g. TXT).
I replaced this line in your code:

,TXT>C:\WINDOWS\NOTEPAD.EXE

with

,TXT>C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk

but it errored out:

Error: Failed attempt to launch program or document:
Action: <C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk "C:\temp\reviewers.txt">
Params: <>

The current thread will exit.

Specifically: The system cannot find the file specified.


Line#
129: {
130: StringTrimRight,file,A_LoopFileName,4
131: Menu,DocMenu,Add,%file%,Open
132: }
133: Menu,DocMenu,Show,0
134: Return
137: FileGetShortcut,%Recent%\%A_ThisMenuItem%.lnk,file
---> 138: Run,App%type% " """ file """"
139: Return
142: Loop,%Recent%\*.lnk
143: {
144: FileGetShortcut,%A_LoopFileFullPath%,file
145: if !FileExist(file)
145: {
146: ToolTip,Deleting %A_LoopFileFullPath%



Code to vim1.ahk:
Code:
; does not work 03/25/2009 :(

SetTitleMatchMode, 2
SetTitleMatchMode, slow
Clipboard =  ; Start blank for ClipWait detection to work.
Send ^c
ClipWait 1
clip := Clipboard
Clipboard = %ClipboardOld%  ; Restore previous contents of clipboard.

  Loop, parse, clip, `n, `r
   {
;      MsgBox Selected file #%A_Index% is %A_LoopField%.
; limit the number of files selectable to 10
maxfiles += 1
; splitting the file to grab it's constituents
SplitPath, A_LoopField, name, dir
SetWorkingDir, %dir%
SelectedFile = %name%
}


IfWinExist, %SelectedFile%
{
    WinActivate  ; Automatically uses the window found above.
    return
}
else
{
edit_this = C:\Documents and Settings\myname\My Documents\MyPrograms\Vim\vim72\gvim.exe
Runwait, %edit_this% "%clip%"
return
}




Thanks in advance for your help


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2009, 10:47 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I am not sure what you wanted to do, and I don’t have vim to test. My guess is that you want to act on each file from the clipboard. In this case you have to move the processing inside the loop. RunWait will stop the script until vim is closed, so you probably want to use Run. You might not need to set the working directory, but give the file with its path to vim. No need for return inside the loop. Something like this:
Code:
SetTitleMatchMode, 2            ; WinTitle anywhere
edit_this = notepad.exe         ; C:\Documents and Settings\myname\My Documents\MyPrograms\Vim\vim72\gvim.exe

SUBROUTINE:
   ClipboardOld := ClipboardAll ; Save old clipboard
   Clipboard =                  ; Start blank for ClipWait detection to work.
   Send ^c
   ClipWait 1
   clip := Clipboard
   Clipboard := ClipboardOld    ; Restore previous contents of clipboard.

   Loop, parse, clip, `n, `r
   {
      SplitPath, A_LoopField, name, dir
      SetWorkingDir, %dir%
      SelectedFile = %name%

      IfWinExist, %SelectedFile%
         WinActivate            ; Automatically uses the window found above.
      else
         Run, "%edit_this%" "%A_LoopField%"
   }
RETURN


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2009, 11:46 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
It didn't work. Restating my needs, I'm trying to use an AHK file to open up a text document, so I changed the Type to
TXT>C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk


I tried your file (saved it and renamed it to vim1.ahk) and it has the same errors.
Is it because this file vim1.ahk is not an application (unlike the winword.exe, iexplore.exe that you have):

Types= AHK>C:\WINDOWS\NOTEPAD.EXE
,DOC>C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe
,MHT>C:\Program Files\Internet Explorer\IEXPLORE.EXE
,PDF>C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe
,PPT>C:\Program Files\Microsoft Office\OFFICE11\POWERPNT.EXE
,RTF>C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe
,XLS>C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
,TXT>C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk




Error: Failed attempt to launch program or document:
Action: <C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk "C:\Documents and Settings\myname\Desktop\Utils\sfk.txt">
Params: <>

The current thread will exit.

Specifically: The system cannot find the file specified.


Line#
126: {
127: StringTrimRight,file,A_LoopFileName,4
128: Menu,DocMenu,Add,%file%,Open
129: }
130: Menu,DocMenu,Show,0
131: Return
134: FileGetShortcut,%Recent%\%A_ThisMenuItem%.lnk,file
---> 135: Run,App%type% " """ file """"
136: Return
139: Loop,%Recent%\*.lnk
140: {
141: FileGetShortcut,%A_LoopFileFullPath%,file
142: if !FileExist(file)
142: {
143: ToolTip,Deleting %A_LoopFileFullPath%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 7:06 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
If AHK was properly installed, "Run path\script.ahk" should work. Try a single line script, with "Run C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk". If you get an error, your path is wrong.

The original script gives the document to the called application in its command line parameter. Instead of the clipboard, you may want to use %1%.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 3:46 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
Thanks for your patience; my AHK install is OK (verified your testcase), so that
wasn't the problem, but it pointed me to the solution. Here's what I changed to fix it:

1. ,TXT>C:\Documents and Settings\myname\Desktop\Utils\AutoHotkey\AutoHotkey.exe C:\DOCUME~1\myname\Desktop\AutoIt\Useful\vim1.ahk

2a. your suggestion to use %1% instead of clip in the vim1.ahk file.

2b. Of interest to VIMers only:

vim1.ahk:
Code:
; fn: 03/27/2009
; this is called by poprecentdocs.ahk
; re-opens up vim edit of file if it is active, else open a new session.

SetTitleMatchMode, 2
SetTitleMatchMode, slow

mywintitle = %1%

   Loop, parse, mywintitle, `n, `r
   {
      SplitPath, A_LoopField, name, dir
      SetWorkingDir, %dir%
      SelectedFile = %name%
     }

IfWinExist, %name%
{
    WinActivate  ; Automatically uses the window found above.
    return
}
else
{
edit_this = C:\Documents and Settings\myname\My Documents\MyPrograms\Vim\vim72\gvim.exe
Run, %edit_this% "%1%"

return
}






Thanks to your help.

Next, I'll look into similar reopens of open explorer sessions.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 4:12 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
you don't need the loop


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 5:47 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
You're right. I removed the loop (it was easier for me to copy/paste everything :) )


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, maul.esel and 17 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