AutoHotkey Community

It is currently May 27th, 2012, 10:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: November 25th, 2007, 8:11 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
This module will allow you to print the text of a Edit box.

Version 2.1
Update Version 2.2 Big - 2007-11-28
This big update is more faster and
reliable
------------------------------------------
Update Version 2.1 - 2007-11-26
Creates A Unique PID to avoid
activating other open notepad windows
------------------------------------------
Update Version 2.0 - 2007-11-25
Print is now out of it beta phase !
There is no need for the print.txt file
-------------------------------------------
Update Version 1.5 Beta - 2007-11-25
Added a checking system to delete
previous print.txt files to avoid
double printing
-------------------------------------------
Version 1.2 - 2007-11-25
Print function is out!


Code:
Print(Edit)
{
   Run notepad.exe,,,PID
   WinWait ahk_pid %PID%
   GuiControlGet, ToPrint,, %Edit%
   ControlSetText Edit1, %ToPrint%, ahk_pid %PID%
   WinMenuSelectItem ahk_pid %PID%,, File, Print
   }


Syntax:
Code:
Print("Edit") ; Edit being the vName of the edit box



Older Versions:
Version 2.1 Download
http://www.autohotkey.net/~desmin88/Printv2.1.ahk

Version 2.0 Download
http://www.autohotkey.net/~desmin88/Printv2.0.ahk

Version 1.5 Download
http://www.autohotkey.net/~desmin88/Printv1.5.ahk

Version 1.2 Download
http://www.autohotkey.net/~desmin88/Printv1.2.ahk[/url]


Last edited by Fry on November 28th, 2007, 2:40 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2007, 10:19 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
i hope people will use this script :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2007, 2:35 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
anybody like this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2007, 2:46 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Are you serious ?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2007, 6:59 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
majkinetor wrote:
Are you serious ?
Why? Although it is simple, it can be useful. You can assign it to a hotkey or add to the context menu for AHK files, etc.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2007, 7:19 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
I don't want to minimise anybodies work, but this is far from the way it should be done. First of all, it opens Notepad processs, and it can even miss the acctuall Notepad if several documents are open. Second of all, Notepad exe may be replaced like some people do (they replace Notepad.exe with some other more useful editor).

I beleive Fry was excited about this and wanted to share his work, but I am also honest about this, so I share my thoughts - this is not the way.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2007, 9:22 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I think it is a bad idea to replace a Windows file (notepad.exe). The next Windows update, or just the regular integrity check, might put the original file back. It is usually safe to assume that notepad.exe is present on the path.

It is another question if WordPad.exe would be a better choice.

Of course, you can improve the script. If you use PID, there will be no conflict between already opened notepad windows. This version prints a file, instead of a string:
Code:
Print(File) {
   Run notepad.exe %File%,,,PID
   WinWaitActive ahk_pid %PID%
   Send ^p
}

Print(A_ScriptFullPath)
If you want, you can close notepad automatically, when the printer accepted the file.

This is what AHK was originally designed for: a few lines of code to control applications to do what you want. I understand that you can do it better, but you can hardly do it simpler.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2007, 10:02 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
update

thanks Laszlo oh and majkinetor

if you have another better way post it :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2007, 4:33 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
version 2.1 download it!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2007, 4:57 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You may not need “Gui, Submit, NoHide”, because the text is already retrieved by the “GuiControlGet, ToPrint,, %Edit%” command.

It might be safer to use ControlSetText instead of SendInput. It is faster, too, and you will not have problems with long texts, if a pop up window steals the focus in the middle of sending keys.

WinMenuSelectItem is another possibility to start the print dialog, which does not have problems with changing active windows, either. This is what I mean, for printing some text:
Code:
Print(Text) {
   Run notepad.exe,,,PID
   WinWait ahk_pid %PID%
   ControlSetText Edit1, %Text%, ahk_pid %PID%
   WinMenuSelectItem ahk_pid %PID%,, File, Print
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2007, 2:41 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
update v2.2


Version 2.2 is the most stable and reliable update so DoWnLoAd iT


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2007, 10:18 pm 
cool i use this in my guis


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2007, 12:26 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Laszlo wrote:
I understand that you can do it better, but you can hardly do it simpler.

Let me surprise you:

Code:
Print( edit ){
 FileAppend %edit%, tmp
 Run %A_Windows%\system32\NOTEPAD.EXE" /p tmp
 FileDelete, tmp
}

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2007, 12:45 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
It suprised me. :D

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2007, 2:14 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
The bug is back, yey :))))

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 10 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