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 

Problem: #IfWinActive with Locate
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Mon Nov 13, 2006 12:51 pm    Post subject: Reply with quote

You can alternatively do the following. This is adaptation of Quick View script for TC to work with Locate. For more details see its code witch is much more robust. Here I just provide possible workaround with some parts from QV script.

The script will rearange the Locate window and place it on top TC thus simulating the TC panel.

Code:
SetKeyDelay, -1
SetBatchLines -1

#IfWinActive, Locate ahk_class #32770

^f::
   hwnd := WinExist("Locate:")
   QV_TCGetControls()
   SetLocateWindow()
   QV_rect := QV_GetViewDestination()
   QV_AdjustViewerPosition( QV_rect )

   sFileName := ""
   sPath := ""
   ControlGet, sActiveRow, List, Selected, SysListView321
   StringSplit, aRowElements, sActiveRow, %A_Tab%
   sFileName := aRowElements1
   sPath := aRowElements2

   If (sFileName)
   {
     SetTCPath( sPath )
     WinWaitActive, ahk_class TTOTAL_CMD

     Loop
     {
        ControlGetText, ActivePath, TMyPanel2
        StringTrimRight, ActivePath, ActivePath, 1
        If (ActivePath = sPath)
         Break
     }

     PostMessage, 1075, 2915
     WinWaitActive, ahk_class TQUICKSEARCH
     ControlSetText, TTabEdit1, %sFileName%
     ControlSend, TTabEdit1, {Down}{Esc}
   }
return

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

SetLocateWindow()
{
   global hwnd

   DllCall("SetMenu", "uint", hwnd, "uint", 0)
   Control, Hide,, #327703      , ahk_id %hwnd%
   Control, Hide,, Presets      , ahk_id %hwnd%
   Control, Hide,, Tab         , ahk_id %hwnd%
   Control, Hide,, Ne&w Search   , ahk_id %hwnd%
   Control, Hide,, Sto&p      , ahk_id %hwnd%
   Control, Hide,, F&ind Now   , ahk_id %hwnd%
   ControlMove, SysListView321, 0, 0,,, ahk_id %hwnd%

   WinGetPos, x, y, w, h, ahk_id %hwnd%
   WinMove, ahk_id %hwnd%, , x, y, w+1, h+1
   WinSet, AlwaysOnTop, On, ahk_id %hwnd%
}

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

QV_TCGetControls()
{
   global QV_TCActivePanel, QV_TCCurentDir, QV_TCHeader, QV_host

   ControlGetText pLeft,    TMyPanel5, ahk_class TTOTAL_CMD
   ControlGetText pCurrent, TMyPanel2, ahk_class TTOTAL_CMD

   StringReplace pCurrent, pCurrent, >
         

   StringGetPos idx, pLeft, \, R
   StringMid  pLeft, pLeft, 1, idx

   if StrLen(pLeft) = 2
      pLeft = %pLeft%\

   if (pLeft = pCurrent)
      QV_TCActivePanel := "TMyListBox1"
   else
      QV_TCActivePanel := "TMyListBox2"


   QV_TCCurentDir   := "TMyPanel5"
   QV_TCHeader      := "THeaderClick1"
   if QV_TCActivePanel = TMyListBox1
   {
      QV_TCCurentDir   := "TMyPanel9"
      QV_TCHeader      := "THeaderClick2"
   }
}

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

QV_GetViewDestination()
{
   global QV_mode, QV_Options_Width, QV_TCActivePanel, QV_TCCurentDir, QV_TCHeader, QV_host

   rect =

   ControlGetPos,  ,   ,   , hh, %QV_TCHeader%,      ahk_class TTOTAL_CMD
   ControlGetPos cx, cy, cw, ch, %QV_TCCurentDir%,      ahk_class TTOTAL_CMD
   ControlGetPos,  ,   , pw, ph, %QV_TCActivePanel%,   ahk_class TTOTAL_CMD
   WinGetPos x, y, , , ahk_class TTOTAL_CMD
      
   vX := x + cx
   vY := y + cy
   vW := pw
   vH := ph + ch + hh
   rect = %vX%,%vY%,%vW%,%vH%

   return rect
}

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

QV_AdjustViewerPosition( rect )
{
   global hwnd

   loop, parse, rect, `,
   {
      p_%A_Index% := A_LoopField
   }


   WinMove, ahk_id %hwnd%, ,%p_1%,%p_2%,%p_3%,%p_4%
}

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

SetTCPath(path)
{
   if !WinExist("ahk_class TTOTAL_CMD")
   {
      Run, %COMMANDER_PATH%\TOTALCMD.EXE
      WinWait ahk_class TTOTAL_CMD
   }

   WinActivate ahk_class TTOTAL_CMD

   path := path "`r"
   VarSetCapacity( CopyDataStruct, 12 )
   InsertInteger( Asc( "C" ) + 256 * Asc( "D" ), CopyDataStruct )
   InsertInteger( StrLen( path ) + 5, CopyDataStruct, 4 )
   InsertInteger( &path, CopyDataStruct, 8 )
   InsertInteger( Asc( "S" ), path, StrLen( path ) + 1, 1)
   InsertInteger( Asc( "T" ), path, StrLen( path ) + 2, 1)
   SendMessage, 0x4A, , &CopyDataStruct, , ahk_class TTOTAL_CMD

}

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

SendTCCommand(cmd, wait=1)
{
   if (wait)
      SendMessage 1075, cmd, 0, , ahk_class TTOTAL_CMD
   else
      PostMessage 1075, cmd, 0, , ahk_class TTOTAL_CMD
}

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

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
  mask := 0xFF
  Loop %pSize%
  {
    DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1, UChar, (pInteger & mask) >> 8 * (A_Index - 1))
    mask := mask << 8
  }
}

_________________


Last edited by majkinetor on Mon Nov 13, 2006 1:04 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Icfu



Joined: 24 Jul 2005
Posts: 27
Location: Rheinland

PostPosted: Mon Nov 13, 2006 12:58 pm    Post subject: Reply with quote

@majki:
Command line can be activated also when it's disabled!
Try 4003. Wink

Icfu
Back to top
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Mon Nov 13, 2006 1:02 pm    Post subject: Reply with quote

Oh, yeah... forgot that Smile
_________________
Back to top
View user's profile Send private message MSN Messenger
Icfu



Joined: 24 Jul 2005
Posts: 27
Location: Rheinland

PostPosted: Mon Nov 13, 2006 2:03 pm    Post subject: Reply with quote

Quote:
Now, if we only can find a way to select a file name without quick search....

You can get rid of quicksearch box as TC 7 supports several listbox commands now, all hidden in this changelog entry:
TC 7 Changelog wrote:
15.09.06 Added: Support for accessibility tools (e.g. for blind users) to main lists+separate tree+sync+CD-Tree, allows to retrieve current line via LB_GETTEXT


To name a few:
LB_GETTEXT
LB_SETCARETINDEX <- Wink
LB_SETSEL
etc...

Icfu
Back to top
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Mon Nov 13, 2006 2:54 pm    Post subject: Reply with quote

Indeed Very Happy

Code:
   SetTCFileName("Windows")
return


SetTCFileName( fn )
{
   static sss, LB_SETCARETINDEX, LB_GETTEXT

   if LB_SETCARETINDEX=
   {
      LB_SETCARETINDEX = 0x19E
      LB_GETTEXT = 0x189
      VarSetCapacity(sss, 512)
   }

   loop
   {
      SendMessage LB_GETTEXT, A_Index, &sss, TMyListBox1, ahk_class TTOTAL_CMD
      if (sss = fn) or (sss="")
      {
         SendMessage, LB_SETCARETINDEX, A_Index, 1, TMyListBox1, ahk_class TTOTAL_CMD      
         break
      }
   }
}

_________________
Back to top
View user's profile Send private message MSN Messenger
Guest






PostPosted: Mon Nov 13, 2006 3:01 pm    Post subject: Reply with quote

Icfu wrote:
Quote:
Any way to script that?

Nope, there's no way to script that as TC doesn't support feeding a list with items from the outside.

@majki:
You are right when TC is started already of course, but I don't expect others to have TC always started, at least not in this forum here... Wink


Ahh, too bad about feeding a list. And yes, I like this better because I'm not always running TC.
Back to top
Guest






PostPosted: Fri Jan 05, 2007 7:04 pm    Post subject: Reply with quote

Is there away to adopt the script as follows:

If the locate32 window IS active the scripts runs in
its current state.

If the locate32 window IS NOT active, assume that the
clipboard contains either fullpath + filename or just filename
and try to locate the file in the current panel of TC

See also this thread http://www.ghisler.ch/board/viewtopic.php?t=13571
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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