Author Topic: Maximize Text Window with Lisp  (Read 6010 times)

0 Members and 1 Guest are viewing this topic.

Harrie

  • Guest
Maximize Text Window with Lisp
« on: May 21, 2011, 08:57:54 AM »
Hello,

Is it possible to Maximize AutoCAD Text Window with Lisp?

Regards.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Maximize Text Window with Lisp
« Reply #1 on: May 21, 2011, 08:58:41 AM »
Code: [Select]
(textscr)

Harrie

  • Guest
Re: Maximize Text Window with Lisp
« Reply #2 on: May 21, 2011, 09:07:15 AM »
Code: [Select]
(textscr)
Lee,

The function (textscr) and (textpage) gives only the text window, but gives not a Maximize text window!

Regards.
« Last Edit: May 21, 2011, 09:22:05 AM by Harrie »

highflyingbird

  • Bull Frog
  • Posts: 415
  • Later equals never.
Re: Maximize Text Window with Lisp
« Reply #3 on: May 22, 2011, 01:47:49 AM »
Maybe like this:
Code: [Select]

(defun c:test(/ wsh title)
  (textscr)
  (setq title "AutoCAD 文本窗口 - Drawing1.dwg")    ;->this is  the title of  your Textscreen
  (setq wsh (vlax-create-object "Wscript.Shell"))
  ;;(vlax-invoke wsh 'AppActivate title)
  ;;(command "delay" 100)
  (vlax-invoke wsh 'Sendkeys "% x")  ;x Maximize;n Minimize
  (vlax-release-object wsh)
  (princ)
)
« Last Edit: May 22, 2011, 01:58:01 AM by highflybird »
I am a bilingualist,Chinese and Chinglish.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Maximize Text Window with Lisp
« Reply #4 on: May 22, 2011, 07:26:44 AM »
Nice idea highflybird  8-)

Using your idea,

Code: [Select]
(defun TextWin ( flag / wsh )
  (cond
    ( flag
      (textscr)
      (setq wsh (vlax-create-object "WScript.Shell"))
      (vlax-invoke wsh 'SendKeys "% x")
      (vlax-release-object wsh)
    )
    ( (graphscr) )
  )
  (princ)
)

Code: [Select]
(TextWin   T) ;; Maximise
(TextWin nil) ;; Minimise

Harrie

  • Guest
Re: Maximize Text Window with Lisp
« Reply #5 on: May 22, 2011, 09:29:33 AM »
Nice idea highflybird  8-)

Using your idea,

Code: [Select]
(defun TextWin ( flag / wsh )
  (cond
    ( flag
      (textscr)
      (setq wsh (vlax-create-object "WScript.Shell"))
      (vlax-invoke wsh 'SendKeys "% x")
      (vlax-release-object wsh)
    )
    ( (graphscr) )
  )
  (princ)
)

Code: [Select]
(TextWin   T) ;; Maximise
(TextWin nil) ;; Minimise
Thanks Lee and Highflybird,

I have some questions:
1) In the program Test from Highflybird, I see no change in the Title of the TextScreen
2) In the program TextWin from Lee Mac, is it not better to change the string "% x"
in "% M".

Code: [Select]
(defun TextWin2 ( flag / wsh )
(if (> (atoi (substr (getvar "ACADVER") 1 2)) 14)
(progn
  (vl-load-com)
  (cond
    ( flag
      (textscr)
      (setq wsh (vlax-create-object "WScript.Shell"))
      (vlax-invoke wsh 'SendKeys "% M"); "% M" Maximize and "% N" Minimize All
      (vlax-release-object wsh)
    )
    ( (graphscr) )
  )
)
(if flag (textscr)(graphscr))
)
)

or

Code: [Select]
(defun TextWin3 (flag / wsh str)
(if flag (setq str "% M")(setq str "% N"))
(if (> (atoi (substr (getvar "ACADVER") 1 2)) 14)
(progn
(vl-load-com)
(if flag (textscr))
(setq wsh (vlax-create-object "WScript.Shell"))
(vlax-invoke wsh 'SendKeys str)
(vlax-release-object wsh)
))
(if flag (textscr)(graphscr))
(princ)
)
Code: [Select]
(TextWin3 T); Maximize Textscreen
(TextWin3 nil); Minimize All

Regards, Harrie.
« Last Edit: May 22, 2011, 10:12:57 AM by Harrie »

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Maximize Text Window with Lisp
« Reply #6 on: May 22, 2011, 10:59:22 AM »
I thought the mnemonic was 'x' for Maximise in the menu that appears when pressing Alt+Space

highflyingbird

  • Bull Frog
  • Posts: 415
  • Later equals never.
Re: Maximize Text Window with Lisp
« Reply #7 on: May 22, 2011, 11:42:30 AM »

I have some questions:
1) In the program Test from Highflybird, I see no change in the Title of the TextScreen
Regards, Harrie.

At the first ,I wanted to use "AppActivate" method to active a window, its title should be "AutoCAD 文本窗口 - Drawing1.dwg",like this.
but later,I found it's not necessary, because (textscr) means you have activated text window.
so actually, (setq title "AutoCAD 文本窗口 - Drawing1.dwg") can be removed. as Lee Mac's.

this article will help you
« Last Edit: May 22, 2011, 11:50:30 AM by highflybird »
I am a bilingualist,Chinese and Chinglish.

HofCAD

  • Guest
Re: Maximize Text Window with Lisp
« Reply #8 on: May 22, 2011, 12:59:00 PM »
Lee and Highflybird,

Is this the right way?
Code: [Select]
(defun TextWin4 (code / wsh str)
  (cond ((= code 0) (graphscr))
((= code 1) (setq str "% M"))
(T (setq str "% N"))
  )
  (if (> (atoi (substr (getvar "ACADVER") 1 2)) 14)
    (progn
      (if (/= code 0)
(progn
 (vl-load-com)
 (if (= code 1)
   (textscr)(graphscr)
 )
 (setq wsh (vlax-create-object "WScript.Shell"))
 (vlax-invoke wsh 'SendKeys str)
 (vlax-release-object wsh)
)
      )
    )
    (if (= code 1)
      (textscr)
      (graphscr)
    )
  )
  (princ)
)
(princ "\nTextWin4.lsp loaded.")
(defun C:Info ()
  (TextWin4 1)
  (mapcar
    '(lambda (x) (princ X))
    '(
      "\nType (TextWin4 0) for displaying the AutoCAD graphics screen."
      "\nType (TextWin4 1) for displaying the maximized AutoCAD text screen."
      "\nType (TextWin4 2), (TextWin4 nil) or (TextWin4 T) for minimized AutoCAD."
      "\n************************Type INFO for this screen************************"
     )
  )
  (princ)
)
(c:INFO)
(princ)

HofCAD

highflyingbird

  • Bull Frog
  • Posts: 415
  • Later equals never.
Re: Maximize Text Window with Lisp
« Reply #9 on: May 22, 2011, 01:11:38 PM »
Lee and Highflybird,

Is this the right way?
Code: [Select]
(defun TextWin4 (code / wsh str)
  (cond ((= code 0) (graphscr))
((= code 1) (setq str "% M"))
(T (setq str "% N"))
  )
  (if (> (atoi (substr (getvar "ACADVER") 1 2)) 14)
    (progn
      (if (/= code 0)
(progn
  (vl-load-com)
  (if (= code 1)
    (textscr)(graphscr)
  )
  (setq wsh (vlax-create-object "WScript.Shell"))
  (vlax-invoke wsh 'SendKeys str)
  (vlax-release-object wsh)
)
      )
    )
    (if (= code 1)
      (textscr)
      (graphscr)
    )
  )
  (princ)
)
(princ "\nTextWin4.lsp loaded.")
(defun C:Info ()
  (TextWin4 1)
  (mapcar
    '(lambda (x) (princ X))
    '(
      "\nType (TextWin4 0) for displaying the AutoCAD graphics screen."
      "\nType (TextWin4 1) for displaying the maximized AutoCAD text screen."
      "\nType (TextWin4 2), (TextWin4 nil) or (TextWin4 T) for minimized AutoCAD."
      "\n************************Type INFO for this screen************************"
     )
  )
  (princ)
)
(c:INFO)
(princ)

HofCAD

Good job!
by the way,  if you want maximize Application window or VBIDE window or  Document window,
just change the property of  windowState , like that :
Code: [Select]
(setq app (vlax-get-acad-object))
(vla-put-windowstate app 3)
« Last Edit: May 22, 2011, 10:29:19 PM by highflybird »
I am a bilingualist,Chinese and Chinglish.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Maximize Text Window with Lisp
« Reply #10 on: May 22, 2011, 01:20:17 PM »
Lee and Highflybird,

Is this the right way?

I didn't think it needed to be that complicated (as per my earlier example), but since you asked, I would write your code in the following way:

Code: [Select]
(defun TextWin ( code / wsh )
  (if (> (atoi (getvar 'ACADVER)) 14)
    (cond
      ( (= code 0) (graphscr) )
      ( (= code 1)
        (textscr)
        (setq wsh (vlax-create-object "WScript.Shell"))
        (vlax-invoke wsh 'SendKeys "% x")
        (vlax-release-object wsh)
      )
      (t(graphscr)
        (setq wsh (vlax-create-object "WScript.Shell"))
        (vlax-invoke wsh 'SendKeys "% n")
        (vlax-release-object wsh)
      )
    )
    (if (= 1 code) (textscr) (graphscr))
  )
  (princ)
)

(princ "\nTextWin.lsp loaded.")
(defun c:Info nil
  (mapcar 'princ
   '("\nType (TextWin 0) for displaying the AutoCAD graphics screen."
     "\nType (TextWin 1) for displaying the maximized AutoCAD text screen."
     "\nType (TextWin 2) for minimized AutoCAD."
     "\n-------------------- Type INFO for this screen -------------------- "
    )
  )
  (TextWin 1) (princ)
)
(c:INFO) (princ)

HofCAD

  • Guest
Re: Maximize Text Window with Lisp
« Reply #11 on: May 22, 2011, 02:55:18 PM »
Thanks Lee and Highflybird,

I made a small change.

Regards.

Harrie

  • Guest
Re: Maximize Text Window with Lisp
« Reply #12 on: May 29, 2011, 03:08:33 PM »
Thanks Lee, Highflybird and HofCAD.

laidbacklarry

  • Guest
Re: Maximize Text Window with Lisp
« Reply #13 on: May 29, 2011, 05:11:25 PM »
I almost always want the Acad text window maximized so I mapped a revised version of Lee Mac's first code to the F2 key and life is good. Thanks Lee and others...