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 

redirect
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
olaf
Guest





PostPosted: Wed Mar 16, 2005 9:22 am    Post subject: redirect Reply with quote

this script stolen and uglified from Dhanish's pdftk gui script.

tryin to make a simple gui. why doesn't this work?
And can ahk run something like %PATH%dir ?

Code:
Gui, Add, Radio, vOpt, Diff 2 files
Gui, Add, Radio, , Do Nothing
Gui, Add, Radio, , About this Gui
Gui, Add, Button, ,OK
Gui, Show, x250 y150, DiffGoo
Return

ButtonOK:
Gui, Submit

if Opt=1
  {
  FileSelectFile, in1,,,"Choose From file",*.*
  FileSelectFile, in2,,,"Choose To file",*.*
  FileSelectFile, out1,,,"Choose output file",*.txt
  RunWait, C:\pathto\diff.exe -u %in1% %in2% > %out1%.txt
  }
else if Opt=2
  {
  MsgBox, This didn't do anything!
  }
else
  {
  MsgBox, This script was stolen and mutilated
  }
GuiClose:
GuiEscape:
ExitApp
Back to top
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Wed Mar 16, 2005 10:15 am    Post subject: Reply with quote

What doesn't work? Please be more specific.

You can use "Loop, FilePattern" to get a list of files/folders. This nicer then getting the outout of "dir" ,e.g. with cb.exe. Have look at the manual.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Mar 16, 2005 12:50 pm    Post subject: Reply with quote

One problem is the lack of a "return" at the end of your "ButtonOK" subroutine. Without the return, execution "falls through" into the GuiClose label, which exits the script instantly when you press the OK button.
Back to top
View user's profile Send private message Send e-mail
olaf
Guest





PostPosted: Sat Mar 19, 2005 3:38 am    Post subject: Re: redirect Reply with quote

I'm trying something simple to learn ahk.
I don't know how to assign a value to a variable name, and then
add that value to the command line if Checkbox is checked.
In this case, I want the value of "lopt" to be "-l",
and the value of "Ropt" to be "-R".

this currently does not work.
Code:

Gui, Add, Radio, vlsit, ls
Gui, Add, Checkbox, vlopt, -l
Gui, Add, Checkbox, vRopt, -R
Gui, Add, Button, ,OK
Return

ButtonOK:
Gui, Submit

if lsit=1
  {
  FileSelectFile, out1,,,"Choose output file",*.txt
    GuiControlGet, lopt1
    GuiControlGet, Ropt1
  RunWait, C:\pathto\ls.exe %lopt% %Ropt%  > %out1%.txt
  }
else
  {
  RunWait, C:\pathto\ls.exe  > %out1%.txt
  }
GuiClose:
GuiEscape:
ExitApp
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Sat Mar 19, 2005 6:20 pm    Post subject: Reply with quote

Code:
Gui, Add, Radio, vlsit, ls
Gui, Add, Checkbox, vlopt, -l
Gui, Add, Checkbox, vRopt, -R
Gui, Add, Button, ,OK
Gui, Show, w120 h100, test  ; show the GUI window
Return

ButtonOK:
Gui, Submit, NoHide ; Remove NoHide if you want to hide the GUI here

if lsit=1
  {
  FileSelectFile, out1,,,"Choose output file",*.txt

    ; The GuiControlGet lines are not necessary since Gui, Submit was used
    ; GuiControlGet, lopt1
    ; GuiControlGet, Ropt1

  ; since lopt & Ropt return 1 or 0 not -l or -R we need to use additional variables
  if lopt = 1
    {
    lopt1 = -l
    }
  else
    {
    lopt1 =
    }

  if Ropt = 1
    {
    Ropt1 = -R
    }
  else
    {
    Ropt1 =
    }
 
  MsgBox, C:\pathto\ls.exe %lopt1% %Ropt1%  > %out1%.txt ; change MsgBox back to RunWait
  }
else
  {
  MsgBox, C:\pathto\ls.exe  > %out1%.txt ; change MsgBox back to RunWait
  }

; remove the Return line if you want to exit the app after pressing Ok
Return

GuiClose:
GuiEscape:
ExitApp
Back to top
View user's profile Send private message Visit poster's website
olaf
Guest





PostPosted: Sat Mar 19, 2005 9:25 pm    Post subject: Reply with quote

wow, thanks corrupt. exactly what was needed. the extra if statements is what I couldn't figure out for some reason, and now i see it makes total sense.
Back to top
olaf
Guest





PostPosted: Sat Mar 19, 2005 9:46 pm    Post subject: Reply with quote

And now for something else.
I've read through the "Gui Add" section of the manual, but the placement of variables, along with xywh coordinates, is a little unclear
( Add, ControlType [, Options, Text] ).
I want to combine these two lines into one line. Where is vMyvar placed?

Gui, Add, Radio, x26 y27 w60 h30, Label
Gui, Add, Radio, vMyvar, Label
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Sat Mar 19, 2005 10:12 pm    Post subject: Reply with quote

olaf wrote:
wow, thanks corrupt. exactly what was needed. the extra if statements is what I couldn't figure out for some reason, and now i see it makes total sense.

You're welcome. I'm glad to hear that it made sense to you Smile.

olaf wrote:

I want to combine these two lines into one line. Where is vMyvar placed?

Gui, Add, Radio, x26 y27 w60 h30, Label
Gui, Add, Radio, vMyvar, Label

Code:
Gui, Add, Radio, x26 y27 w60 h30 vMyvar, Label
Back to top
View user's profile Send private message Visit poster's website
olaf
Guest





PostPosted: Tue Apr 05, 2005 8:05 pm    Post subject: Reply with quote

Is it possible to redirect the output of a command line (stdout) to an editbox, or some other text box
like Gui, Add, Edit, vMainEdit x200 y200 ?

For a simple example, is it possible to redirect the output of:
Run, %comspec% /c dir, C:\My Documents

so that the output is displayed in an text or editbox, NOT in a MsgBox?
The idea is to make a simple gui that emulates a terminal, that would output stdout to the edit area, and then also to have the option to save the output to a file.
Back to top
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Tue Apr 05, 2005 9:23 pm    Post subject: Reply with quote

Olaf, you may not have heard of it, but I've already made a script like that! Here it is. I made it to be extensible, and it shouldn't be hard to add saving abilities to it. Actually, I could add it for you if you want. Some of the links in that post might be old, so tell me if you can't get gclip and I'll point you to a fresher link.
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Wed Apr 06, 2005 5:52 am    Post subject: Reply with quote

Quote:
The idea is to make a simple gui that emulates a terminal, that would output stdout to the edit area, and then also to have the option to save the output to a file.
To use DOS's redirection doesn't make sense to you?

Run, %COMSPEC% /K dir C:\*.dir > MyCDriveIndex.txt

1) saves to a file
2) output is easy to edit (ie Notepad)
3) combined with "tail -f" you've a "terminal" in place.
Back to top
olaf
Guest





PostPosted: Wed Apr 06, 2005 10:42 am    Post subject: Reply with quote

BoBo wrote:
To use DOS's redirection doesn't make sense to you?

Run, %COMSPEC% /K dir C:\*.dir > MyCDriveIndex.txt

1) saves to a file
2) output is easy to edit (ie Notepad)
3) combined with "tail -f" you've a "terminal" in place.


Bobo, I already have that in a script. I'm finding that I don't want to have to always save the output to a file, and then delete it afterwards. I know I could put a line at the end like FileDelete, MyCDriveIndex.txt, but rather have the output displayed in a text type or edit type box, and then have an option to save to a text file or otherwise quit.

jonny, thanks for the link, I'll check them out.
p.s. where do i find gclip?
Back to top
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Wed Apr 06, 2005 9:19 pm    Post subject: Reply with quote

You can get it at http://unxutils.sourceforge.net/. There are a lot of other nice utilities in the package provided there, but if you're interested in them, you'd probably like http://gnuwin32.sourceforge.net/ more. It has more and newer utilities, but unfortunately does not include gclip or pclip.
Back to top
View user's profile Send private message
olaf
Guest





PostPosted: Thu Apr 07, 2005 9:40 pm    Post subject: Reply with quote

jonny wrote:
You can get it at http://unxutils.sourceforge.net/


I think I'll try to find a work around. I could not find the source for gclip or pclip in the repository, and would rather work with something that is being maintained. unx looks defunx
Back to top
olaf
Guest





PostPosted: Sat Apr 09, 2005 11:32 pm    Post subject: Reply with quote

basic question but i can't seem to get it right.

How do you assign text typed in an edit box to a variable.
i.e. if I have:
Gui, Add, Edit, vtextbox

I want to assign whatever is typed there into it's own variable.
I believe it's either GuiControl or GuiControlGet, and I've tried both, so
I'm writing it wrong.
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 1, 2  Next
Page 1 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