AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: November 13th, 2006, 4:10 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
To test it open the TC and execute the script. Press ALT M to open input box. Type a file name in any panel to select it.


Code:
!m::
   InputBox fn, ,type a file name to select
   if errorlevel != 1
      if !SetTCFileName(fn, "right", 1)
         SetTCFileName(fn, "left", 1)
return

;--------------------------------------------------------------------
; PURPOSE: Set the focus to given file name
;
; ARGS:   
;      FN         - file name to set
;      panel      - panel in witch file resides (1=right=default, 2=left)
;       select      - true to select, false=default
;
; RETURNS : true if file was found
;
SetTCFileName( fn, panel="", select=false )
{
   static sss, LB_SETCARETINDEX, LB_GETTEXT
   
   ;initialise
   if LB_SETCARETINDEX=
   {
      LB_SETCARETINDEX   = 0x19E
      LB_GETTEXT      = 0x189
      VarSetCapacity(sss, 512)
   }

   ;check active TC panel
   GetTCPanels( pLeft, pRight)
   cur := GetCurrentTCDir()

   if (cur = pLeft)
      if (panel = "right")
         Send {TAB}
   
   if (cur = pRight)
      if (panel = "left")
         Send {TAB}


   if (panel = "right") or (panel="")
         panel = TMyListBox1
   else   panel = TMyListBox2
   
   loop
   {
      SendMessage LB_GETTEXT, A_Index, &sss,         %panel%, ahk_class TTOTAL_CMD
      if sss=
         return 0

      if (sss = fn)
      {
         SendMessage LB_GETTEXT, A_Index+1, &sss,   %panel%, ahk_class TTOTAL_CMD
         SendMessage, LB_SETCARETINDEX, A_Index, 1,   %panel%, ahk_class TTOTAL_CMD       

         break
      }
   }
   
   if (select)
   {
      Send, {INSERT}
      if sss !=
         Send,{UP}
   }

   return 1
}

;--------------------------------------------------------------------------
; set left and right panel
;
GetTCPanels( ByRef pLeft, ByRef pRight)
{

   ControlGetText pLeft,  TMyPanel5, ahk_class TTOTAL_CMD
   ControlGetText pRight, TMyPanel9, ahk_class TTOTAL_CMD

   StringReplace pLeft, pLeft, \*.*
   StringReplace pRight, pRight, \*.*
}

;--------------------------------------------------------------------------

GetCurrentTCDir()
{
   ControlGetText src, TMyPanel2, ahk_class TTOTAL_CMD
   StringReplace src, src, >
   return src
}

_________________
Image


Last edited by majkinetor on November 14th, 2006, 9:48 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 7:49 pm 
Good idea, but it doesn't work for me with Windows Commander 3.52. (Quite old, I know.)

Where did you get the values for LB_SETCARETINDEX, LB_GETTEXT? Maybe I can get it working with WC 3.52.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 7:53 pm 
Ok, I did it. Here it is if you want to include it in your script to support windows commander too:

ahk_class has to be changed to TWINDOWSCMD.
TMyListBox1/2 is reversed. The right one is TMyListBox1


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 8:28 pm 
Offline

Joined: January 7th, 2006, 1:38 pm
Posts: 47
Location: Oslo, Norway
Anonymous wrote:
Good idea, but it doesn't work for me with Windows Commander 3.52. (Quite old, I know.)

Out of curiousity, why do you use this old version? :?:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 8:46 pm 
Because it's installed on my machine, does what I want and I'm too lazy to download a newer version. :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 8:53 pm 
Offline

Joined: January 7th, 2006, 1:38 pm
Posts: 47
Location: Oslo, Norway
Anonymous wrote:
Because it's installed on my machine, does what I want and I'm too lazy to download a newer version. :)
OK, thanks for satisfying my curiosity. You're missing some cool features though :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 9:47 pm 
Like what? Any examples?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 12:38 am 
Like too many things to be mentiond here

I am not sure how it works for you. This is using feature of TC7. Before v7 TC didn't recognise LM messages.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 9:48 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Function is polished a little

_________________
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: sks, Yahoo [Bot] and 21 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