Elegant workaround for Safari print without print dialog bug? - printing

The AppleScript standard suite has a command that will print from an application, allowing for the specifying of certain options and printing without displaying a dialog box. For example:
tell application "Safari"
print document 1 with properties {copies:3} without print dialog
end tell
However, there appears to be a bug in the current version of Safari that prevents this from happening like it's supposed to.1 When specifying without print dialog, a sheet pops up in the window that should display progress in processing the print job, but instead of doing so it just hangs with a nondescriptive barberpole.
In trying to work around this, I realize that if I specify with print dialog, everything works as it's supposed to. The script pauses execution on that line after displaying the dialog, and then continues after the user has hit the print button in the dialog. The most elegant workaround for this would be to keystroke return after the dialog is shown, but I don't think this is possible given that the script is paused on that line until the dialog is dismissed.
A much less elegant workaround is this:
on printCopiesOfCurrentPage(copies)
tell application "System Events"
tell application process "Safari"
keystroke "p" using command down
keystroke copies as text
keystroke return
delay 3
end tell
tell
end printCopiesOfCurrentPage
Since there's no way to delay execution until the print job is sent off, we have to guess with a delay 3, which is either going to be inefficient or problematic.
Any other possibilities here? Maybe a way to watch for the print dialog disappearing after using the keystroke method, or a way to kick off the job after print with dialog is invoked?
1. The first time I tried this, it actually printed one and a half pages before kind of flipping out and causing a printer jam, of all things. I haven't been able to replicate it since, so if someone could confirm this bug for me, it would be appreciated.

Related

DOORS DXL Show output during run

While my DXL script is running on a module I have it print "." during each loop.
I would like this to show in the output while it running, to reassure the user it isn't frozen since it takes a long time to run.
Currently the DXL windows is blocked from the moment the script starts, and when the script is completely done it prints everything at once.
Is there a way to overcome this?
you could use a GUI, a progress bar or write something to a file.
you could use timer callbacks to update your screen.

Selenium IDE simulate press ENTER for javascript configmation box

I am looking for allready for hours how to do this. So don't tell me to use search function. I know there are many things related.
There is many stuff on the internet and here, but no one works for me.
And I need a solution for Selenium IDE or something intergrated with it (if there is anything). Not RC and not WebDriver etc.
I need to simulate a key for an JavaScript confirmation popup, which has "OK" and "Cancel" buttons.
The problem is that I cannot select anything.
Popup appears when the site is opened. The Website itself is visible in the background, but no element can be selected (Firebug shows nothing as well, empty html(?)).
If I press ENTER key the confirmation box disappear (so it works fine manually).
This example seems good, but I can't find any interface in Selenium IDE to do this:
driver.switchTo().alert().accept();
(from Click in OK button inside an Alert (Selenium IDE))
I have only the following pattern:
Or write the test in html, which uses the "Command", "Target", "Value" pattern.
Appreciate any help.
EDIT1:
With the link provided by Janesh Kodikara
I have found that my problem is:
Selenium IDE will not be able to handle alerts that are within the page's onload() function. It will only be able to handle alerts that are generated after the page has completely loaded.
There is no "onload" function in my website, but the script part which creates the alert is inside html which is called with page (not in any function). This must be the same as "onload", because the alert comes immediately when the website is opened.
Once you have a confirmation box, you must consume it (Click OK or Cancel button)
You can use "chooseOkOnNextConfirmation" command to instruct Selenium IDE to simulate clicking OK button.
See http://www.guru99.com/enhancing-selenium-ide-script.html for more details.
You will not see the Javascript popup when IDE script is run.
Selenium IDE
Command : runScript
target : {window.onbeforeunload=function(e){};}
Command :click
target : xpath of button.
This will work fine but you are not able to see popup.

Sublime text remove multy cursor selection in windows

Is there a way to remove selection when you use multy cursors. I mean when I use ctrl+d it expandes selection and ctrl+k, ctrl+d to skip selection works, but ctrl+u for removing selection is not working on windows. Is there another shortcut or some snippents to make it work?
It sounds like there is a plugin interfering with the CtrlU undo option. To find it, open the console with Ctrl` and enter the command
sublime.log_commands(True)
This shows what's going on behind the scenes when you press key combinations or use mouse buttons. Test it by making some multiple selections with CtrlD, and you should see
command: find_under_expand
in the console. Now, try to undo one of your selections by hitting CtrlU and see what comes up. If you see
command: soft_undo
then it's not another plugin issue, as that's what you'd expect to see. However, if (as I suspect) another plugin is interfering, you'll see something else there. If you do, hopefully you'll be able to trace it to the plugin it belongs to and disable it.
When you're done, enter
sublime.log_commands(False)
in the console to turn logging off, then close the console by hitting Esc or Ctrl`.

How can I stop executing .wlua files?

Is it possible to force stop a .wlua file? I figured that I would have to use the Lua Command Line to do this, but I can't seem to find out how to stop them.
If it's possible, how can it be done?
Because wlua.exe doesn't open the console window (that's the purpose) and you can't send Ctrl-C, the only way to terminate such application is to use Processes window in Task Manager. Note, however, that the process name will be wlua.exe for every file opened that way.
Of course, it's meant only to be used when the application isn't responding. Your GUI application should provide a way to close it, such as close button, listening for ESC key etc.

Print from Chrome without the print dialogs? Using Greasemonkey userscript maybe?

We're developing a browser-based warehouse app that needs to print labels and invoices regularly. We want to be able to print to the local printer without clicking through the the usual browser print dialogs. Is this possible? Possibly using a greasemonkey userscript? We don't want to have to setup a whole CUPS printer network and deal with all that, but warehouse pickers having to click through a print dialog 1000 times a day isn't an option.
We're printing PDFs, not sure if that matters. If we could do this another way using HTML5 or something else I'm open to course changes or other ideas here.
You can do if you start your chrome (v18+) with the --kiosk --kiosk-printing switches.
You can see it from this video https://www.youtube.com/watch?v=1ewep-ZT64E
You can put a button on the form you are generating, then using embedded javascript in the pdf itself, cause printing to happen silently.
There are various ways to print a
document without requiring user
interaction. One way is to use the
doc object’s print method and set the
bSilent attribute to true, as shown
in “Printing PDF Documents” on page 79
and in the following example:
this.print({bUI: false, bSilent: true,
bShrinkToFit: true});
http://partners.adobe.com/public/developer/en/acrobat/sdk/AcroJSGuide.pdf
Take a look at the silent printing section under Print Production.
Here's a batch file example I've created based on the answer provided by #russenreaktor:
#echo off
start "Chrome" chrome --kiosk --kiosk-printing --url http://www.google.com
There's no way to do this with only JavaScript.

Resources