Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Unofficial scripts collection
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joe  
View profile  
 More options Feb 1 2012, 7:06 pm
From: Joe <jose...@main.nc.us>
Date: Wed, 01 Feb 2012 19:06:35 -0500
Local: Wed, Feb 1 2012 7:06 pm
Subject: Re: Unofficial scripts collection
Haven't had time to play with the delays.  But, I think most delays,
when they occur, are not script-related.  The biggest one is when I get
an info box saying loading page for printing.  That can last from less
than a second to forever.  I have no idea how to detect it and wait for
it to go away.

Joe

On 02/01/2012 08:40 AM, Al wrote:

> Nice work Joe. Now I get what I was missing about what you were
> saying. You have other print dialogs that this macro doesn't work on,
> that also print to the pq folder, so you have to check for the latest
> queued file and make sure you are one beyond it. Curious now, but has
> the responsiveness of the macro improved now that it doesn't have to
> shell out to complete its execution?

> On Jan 31, 5:15 am, Joe<jose...@main.nc.us>  wrote:
>> On 01/30/2012 08:42 PM, Joe wrote:

>>> On 01/16/2012 07:51 AM, Al wrote:
>>>> Joe,
>>>> My modification to your Autokey script eliminated the bash script
>>>> entirely. While it didn't remove how you suggested the hotkey combo or
>>>> window filter should be defined. Except for the part where you can
>>>> reset the count, it is functionally the same. In addition, literally,
>>>> as did your script, it increments the "offline" print que by 1 each
>>>> time it is run.
>>> That's the part that doesn't work for me.  Lots of files get into (and
>>> out of) the print queue without going through this script so a simple
>>> counter stored with the script just won't work.
>>>> This version of the script can create rather large
>>>> numbers.
>>>> Hmmm, if your primary concern is resetting the print que when the
>>>> offline files have been removed for whatever reason, that should be
>>>> rather easy to implement.
>>> I think that would be easy, but unnecessary when the script implements
>>> an algorithm that works.
>>>> I'll leave it to you to figure out. :)
>>>> - Al
>>>> p.s.http://learnpythonthehardway.org/book/
>>> I'm checking that out along with his regex book.  Thanks.
>>> The only problem I have is that I don't like reading hypertext.  I
>>> prefer to print things out and go at it with a highlighter.  It's
>>> pretty tricky to flatten hypertext for printing and I've never quite
>>> figured it out.  I don't know if the pdf version is any better, but if
>>> I like it I may buy it from him.
>>> Eventually, I'll learn how to read a directory in python (it can't be
>>> very hard) and then I can code the rest of my script in python and
>>> eliminate the bash.
>>>> On Jan 14, 8:58 pm, Joe<jose...@main.nc.us>    wrote:
>>>>> It works on<ctrl>+p , but is filtered to only be active on Mozilla
>>>>> windows.  Other applications have different print dialogs and i don't
>>>>> want to (have to) code for each of them.  These two apps cover the bulk
>>>>> of what I print.  The simplest approach is to just read the directory
>>>>> and see what's there and not worry about how it got there.  My bash
>>>>> approach is very simple and works well unless I mistakenly put files in
>>>>> my print queue that don't follow the pattern. Then it does weird things
>>>>> because it's not currently defended.
>>>>> Joe
>>>>> On 01/14/2012 09:20 PM, Al wrote:
>>>>>> Joe,
>>>>>> Is your script intended to work across all printing functions or just
>>>>>> when you do ctrl+p? If it is just one you initiate the hotkey combo
>>>>>> then the internal counter method should be work great. And as far as
>>>>>> resetting goes, I'm sure we can figure out something to that end. I
>>>>>> really don't know alot about python, I just chose to use a function
>>>>>> that the great and most awesome Chris put into Autokey.
>>>>>> - Al
>>>>>> On Jan 14, 5:19 pm, Joe<jose...@main.nc.us>      wrote:
>>>>>>> On 01/14/2012 12:14 PM, Al wrote:>      Joe,
>>>>>>>> What would you say, if I eliminated your bash script and it all
>>>>>>>> wored
>>>>>>>> within your autokey script?
>>>>>>> I'd say you know python and I don't (yet) ... and Thank you.
>>>>>>> I'm not entirely sure what you did, but it looks like you're just
>>>>>>> keeping a counter saved with the script.
>>>>>>> If that's the case, it won't work because the script only works for
>>>>>>> Firefox and Thunderbird and
>>>>>>> lots of other programs can put things in the print queue (or remove
>>>>>>> them).  That's why the bash script actually reads
>>>>>>> the directory and finds out what the last file name/number was.  Of
>>>>>>> course, that can be done in python, if you know how.
>>>>>>> Also, I have no idea when/if the counter gets reset.  When I clear
>>>>>>> the
>>>>>>> print queue (after printing), it needs to be reset - and that can
>>>>>>> be on
>>>>>>> another day after one or more reboots (My computer is a notebook and
>>>>>>> gets turned off frequently.  Also, there is not always a printer
>>>>>>> attached.)   My bash script is not affected by this.
>>>>>>> Joe
>>>>>>>> - Al
>>>>>>>> Try:
>>>>>>>> # print2file
>>>>>>>> import time
>>>>>>>> import subprocess
>>>>>>>> ## Copyleft 2012/01/12 - JPmicrosystems GPL
>>>>>>>> ## Change<ctrl>+p for Firefox and Thunderbird
>>>>>>>> ## to print to file in a special print queue using
>>>>>>>> ## numbered file names, 01, 02, ... so the print jobs stay in order
>>>>>>>> ## Intended for use with duplexpr
>>>>>>>> ##http://sourceforge.net/projects/duplexpr/
>>>>>>>> ## Depends on the bash script pqnext_py being in you PATH
>>>>>>>> ## and executable.
>>>>>>>> ## User must manually create print queue folder (~/pq)
>>>>>>>> ## Hotkey<ctrl>+p
>>>>>>>> ## Window Filter .*Mozilla.*
>>>>>>>> ## Changes<ctrl>+p to
>>>>>>>> ## Print to file and looks at the print queue (~/pq)
>>>>>>>> ## Finds the last print file number and increments it by one
>>>>>>>> ## Using pqnext_py and puts that in the Print to file name field
>>>>>>>> ## Doesn't send final<Enter>        so additional options like Print
>>>>>>>> Selection
>>>>>>>> ## can be set by the user
>>>>>>>> ##Fails if Loading file to print takes longer than the second delay
>>>>>>>> ## Open the File menu
>>>>>>>> ## (can't use<ctrl>+p because that's the hotkey)
>>>>>>>> keyboard.send_keys("<alt>+f")
>>>>>>>> time.sleep(1.0)
>>>>>>>> ## Select Print
>>>>>>>> keyboard.send_keys("p")
>>>>>>>> time.sleep(2.0)
>>>>>>>> ## tab to the printer selection list, then to the top of the list
>>>>>>>> ## which is the Print to File selection
>>>>>>>> keyboard.send_keys("<tab><home>")
>>>>>>>> time.sleep(2.0)
>>>>>>>> ## tab to the file name field and enter the print queue directory
>>>>>>>> path
>>>>>>>> keyboard.send_keys("<tab>pq/")
>>>>>>>> # we will store a number inside the scripts persistent memory to
>>>>>>>> # represent the number that was being previously written by the
>>>>>>>> # bash script, initiliazing to 0 if necessary
>>>>>>>> if not store.has_key("print_queue"):
>>>>>>>>         store.set_value("print_queue",0)
>>>>>>>> # now pull and use the print_queue variable
>>>>>>>> pq = store.get_value("print_queue")
>>>>>>>> # you can use format codes to pad in 0's if required.
>>>>>>>> # using the stored internal number you can easily get more than
>>>>>>>> 99 if
>>>>>>>> not more 9999
>>>>>>>> # if so desired.
>>>>>>>> output = "subprocess.Popen([%d],stdout =
>>>>>>>> subprocess.PIPE).communicate()
>>>>>>>> [0]" % pq
>>>>>>>> # increment the print queue and store it
>>>>>>>> pq = pq + 1
>>>>>>>> store.set_value("print_queue",pq)
>>>>>>>> ## add the file name to the path and then press enter to complete
>>>>>>>> the
>>>>>>>> dialog
>>>>>>>> keyboard.send_keys(output)
>> Here's my latest version that works in python only - no bash script needed.

>> I'm sure someone who knows python will get a good laugh at the way it's
>> implemented (because I coded it using Google searches for syntax since I
>> still don't know python), but it works.

>> # print2file

>> import time
>> import os

>> ## Copyleft 2012/01/31 - JPmicrosystems GPL
>> ## Change<ctrl>+p for Firefox and Thunderbird
>> ## to print to file in a special print queue using
>> ## numbered file names, 01, 02, ... so the print jobs stay in order
>> ## Intended for use with duplexpr
>> ##http://sourceforge.net/projects/duplexpr/
>> ## User must manually create print queue folder (~/pq)

>> ## Hotkey<ctrl>+p
>> ## Window Filter .*Mozilla.*

>> ## Changes<ctrl>+p to
>> ## Print to file and looks at the print queue (~/pq)
>> ## Finds the last print file number and increments it by one
>> ## Doesn't send final<Enter>  so additional options like Print Selection
>> ## can be set by the user
>> ##Fails if Loading file to print takes longer than the second delay

>> ## Open the File menu
>> ## (can't use<ctrl>+p because that's the hotkey)
>> keyboard.send_keys("<alt>+f")
>> time.sleep(1.0)
>> ## Select Print
>> keyboard.send_keys("p")
>> time.sleep(2.0)
>> ## tab to the printer selection list, then to the top of the list
>> ## which is the Print to File selection
>> keyboard.send_keys("<tab><home>")
>> time.sleep(2.0)
>> ## tab to the file name field and enter the print queue directory path
>> keyboard.send_keys("<tab>pq/")
>> ## Set path to print queue
>> path = os.getenv("HOME") + '/pq'
>> ## Get all the files in the print queue in a list
>> dirList=os.listdir(path)
>> ## And sort it in reverse order
>> ## So the largest numbered file is first
>> dirList.sort(reverse=True)

>> ## If there aren't any files then
>> ## Set last file to 0
>> ## else, set it to the last file
>> if len(dirList) == 0:
>>     output = '0'
>> else:
>>     output = dirList[0]

>> ## Increment the file number
>> output = str(int(output) + 1)

>> ## If it's less than 2 characters long,
>> ## Left pad it with a zero
>> ## To maintain the sorting order
>> if len(output)<  2:
>>     output = '0' + output

>> ## complete the file name field in the print dialog
>> ## But don't send an enter so the user can select
>> ## options before printing
>> keyboard.send_keys(output)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.