Resize Browse For Folder Window

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Resize Browse For Folder Window

Post by CyberCitizen » Tue Jun 05, 2012 3:28 am

Image

Image Link Explains What I Am After. Trying To Resize The Browse For Folder Size. Normally Windows Sets This Box Quite Small
Unless You Resize It Manually. I Was Wanting To Set The Size Or Resize It Once It Was Opened.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jun 05, 2012 4:07 am

One way would be to spawn a seconday script that waits for the browse window to open and resizes it when it does. The following is nearly the file browse sample script provided with Macro Scheduler. the only changes are to make it open folders and then the labeltovar> and executefile> parts.

Hope this is helpful.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 469
  Top = 146
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'File Browse Example'
  ClientHeight = 288
  ClientWidth = 308
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesigned
  ShowHint = True
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 16
    Width = 53
    Height = 13
    Caption = 'Enter a file:'
  end
  object Edit1: TEdit
    Left = 16
    Top = 41
    Width = 248
    Height = 21
    TabOrder = 8
  end
  object MSButton1: tMSButton
    Left = 269
    Top = 41
    Width = 21
    Height = 21
    DoubleBuffered = True
    Glyph.Data = {
      F6000000424DF600000000000000760000002800000010000000100000000100
      0400000000008000000000000000000000001000000010000000000000000000
      80000080000000808000800000008000800080800000C0C0C000808080000000
      FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
      77777777777777777777000000000007777700333333333077770B0333333333
      07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
      77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
      7007777777770777070777777777700077777777777777777777}
    ParentDoubleBuffered = False
    TabOrder = 9
    DoBrowse = False
    Filter = 'Text files (*.txt)|*.TXT|Any file (*.*)|*.*'
    BrowseStyle = fbFolder
  end
  object MSMemo1: tMSMemo
    Left = 16
    Top = 72
    Width = 273
    Height = 161
    ScrollBars = ssBoth
    TabOrder = 10
  end
  object MSButton2: tMSButton
    Left = 215
    Top = 247
    Width = 75
    Height = 25
    Caption = 'Close'
    DoubleBuffered = True
    ModalResult = 2
    ParentDoubleBuffered = False
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,DoBrowse

Show>Dialog1,r

SRT>DoBrowse
  LabelToVar>ReSizeBrowseForFolder,RSBFFdata
  WriteLn>%temp_dir%ReSizeBrowseForFolder.scp,wres,RSBFFdata
  ExecuteFile>%temp_dir%ReSizeBrowseForFolder.scp
  SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
  GetDialogProperty>Dialog1,MSButton1,Filename,strFileName
  SetDialogProperty>Dialog1,Edit1,Text,strFileName
  ReadFile>strFileName,strFileData
  SetDialogProperty>Dialog1,MSMemo1,Text,strFileData
  DeleteFile>%temp_dir%ReSizeBrowseForFolder.scp
END>DoBrowse


/*
ReSizeBrowseForFolder:
WaitWindowOpen>Browse For Folder
ResizeWindow>Browse For Folder,300,500
MoveWindow>Browse For Folder,100,100
*/

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Tue Jun 05, 2012 5:03 am

Thanks JRL,

That's a great solution, didn't think of spawning a secondary script.

Edit: That Didn't Work. Note This Is For A Compiled Script.

I Tried The Below.

Secondary Macro Waited Until Window Appeared, But Wouldn't Continue First Script.

Code: Select all

WriteLn>%TEMP_DIR%ResizeScript.scp,RESIZE,WaitWindowOpen>Folder To Browse*%CRLF%ResizeWindow>Folder To Browse*,100,100
Macro>%TEMP_DIR%ResizeScript.scp
Opened File In Notepad

Code: Select all

WriteLn>%TEMP_DIR%ResizeScript.scp,RESIZE,WaitWindowOpen>Folder To Browse*%CRLF%ResizeWindow>Folder To Browse*,100,100
ExecuteFile>%TEMP_DIR%ResizeScript.scp
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jun 05, 2012 2:52 pm

Opened File In Notepad
Sorry... Should never assume a particular file extension is assigned to a particular application.

In any case, you can dynamically create and run an independent secondary script from a compiled script its just a tad more complicated. You have to use the technique demonstrated in the Happy Button script.

See comments.

Code: Select all

///////////// Happy Button Technique ///////////////

//Determine if this process is a script or an exe
//Set mProcessor variable accordingly
StringReplace>COMMAND_LINE,",,COMMAND_LINE
LowerCase>COMMAND_LINE,COMMAND_LINE
ExtractFileName>COMMAND_LINE,value
Trim>value,value
If>value=msched.exe
  Let>mProcessor=%COMMAND_LINE%%SPACE%
Else
  Let>mProcessor=%COMMAND_LINE% /Script=
EndIf


//If the variable "Script" has a value, then this executable has been
//invoked by itself as a script processing agent.  Run the script then exit.
If>Script<>{"Script"}
  Macro>Script
  Exit>0
EndIF


//This cannot come before the variable "script" test above.
//Define the name of the secondary script and delete it if it exists.
Let>macrofile=%TEMP_DIR%ReSizeBrowseForFolder.scp
IfFileExists>%macrofile%
  DeleteFile>%macrofile%
EndIf

//Create the secondary script. One easy way is to use LabelToVar>
LabelToVar>ReSizeBrowseForFolder,RSBFFdata
WriteLn>%macrofile%,wres,RSBFFdata

/*
ReSizeBrowseForFolder:
WaitWindowOpen>Browse For Folder
ResizeWindow>Browse For Folder,300,500
MoveWindow>Browse For Folder,100,100
*/



/////////////  Main Script ///////////////

Dialog>Dialog1
object Dialog1: TForm
  Left = 469
  Top = 146
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'File Browse Example'
  ClientHeight = 288
  ClientWidth = 308
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesigned
  ShowHint = True
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 16
    Width = 53
    Height = 13
    Caption = 'Enter a file:'
  end
  object Edit1: TEdit
    Left = 16
    Top = 41
    Width = 248
    Height = 21
    TabOrder = 8
  end
  object MSButton1: tMSButton
    Left = 269
    Top = 41
    Width = 21
    Height = 21
    DoubleBuffered = True
    Glyph.Data = {
      F6000000424DF600000000000000760000002800000010000000100000000100
      0400000000008000000000000000000000001000000010000000000000000000
      80000080000000808000800000008000800080800000C0C0C000808080000000
      FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
      77777777777777777777000000000007777700333333333077770B0333333333
      07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
      77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
      7007777777770777070777777777700077777777777777777777}
    ParentDoubleBuffered = False
    TabOrder = 9
    DoBrowse = False
    Filter = 'Text files (*.txt)|*.TXT|Any file (*.*)|*.*'
    BrowseStyle = fbFolder
  end
  object MSMemo1: tMSMemo
    Left = 16
    Top = 72
    Width = 273
    Height = 161
    ScrollBars = ssBoth
    TabOrder = 10
  end
  object MSButton2: tMSButton
    Left = 215
    Top = 247
    Width = 75
    Height = 25
    Caption = 'Close'
    DoubleBuffered = True
    ModalResult = 2
    ParentDoubleBuffered = False
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,DoBrowse

Show>Dialog1,r

SRT>DoBrowse
  //Use the mProcessor variable to run the secondary script
  Run>%mProcessor%%macrofile%
  /////////////////////////////////////////////////////////
  SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
  GetDialogProperty>Dialog1,MSButton1,Filename,strFileName
  SetDialogProperty>Dialog1,Edit1,Text,strFileName
  ReadFile>strFileName,strFileData
  SetDialogProperty>Dialog1,MSMemo1,Text,strFileData
  DeleteFile>%temp_dir%ReSizeBrowseForFolder.scp
END>DoBrowse

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts