Hammerspoon: continuously send keystrokes to one application, while using others normally - keystroke

Ok, so I have a script with Hammerspoon that executes key stokes for me. Simple example:
hs.hotkey.bind({'cmd','alt','ctrl'}, "b", function()
hs.eventtap.keyStroke({}, "Left", 200000)
hs.eventtap.keyStroke({}, "Left", 200000)
hs.eventtap.keyStroke({}, "Right", 200000)
hs.eventtap.keyStroke({}, "Right", 200000)
end)
I know I can filter this script to only work in specific applications, but my question is: is it possible to send these key strokes to one application, while using my physical keyboard normally in another application? Like having the key strokes sent 'in the background', so they aren't registered in the application I'm currently using.

You can query the app, store it in a variable and then use that to send those keystrokes to that application:
local myApp = hs.application.applicationsForBundleID('com.apple.finder')[1]
hs.eventtap.keyStroke({"cmd"}, "2", 200, myApp)
This would send CMD + 2 to the Finder app (more precisely: the first app with this bundle id) after a delay of 200 microseconds.
I would probably do the setting of the variable outside the keystroke bind function, so that it does not happen on every keystroke but rather at the beginning.

Related

Cannot get XPath selector to work using Robocorp Selenium library

I am attempting web automation with a platform called Robocorp using the Selenium library.
When I run my program, I have no issues until I encounter this page where I am trying to get the program to click on the icon that says SQL.
I want the <a> element with the #href attribute.
Here are some (of many) XPaths I have tried that have all failed:
xpath://a[contains(#href,'sql_form.jsp')]
xpath://*[text()='SQL']
xpath://a[#target='frame2]
Snapshot of the element:
I circled the element in red ^^^
I cannot get the selector to be recognized on this page. I have tried adding delays, waiting until the element is active, waiting until the element is visible, etc.
Nothing seems to work.
Here is an image of the elements I am trying to select.
(The link in the href element takes me to the page I am trying to access).
I thought that the third one would for sure work but is still failing.
I am using a platform called Robocorp which only needs the raw selector to work (CSS or XPath)
I was unaware that iframe needed to be handled differently or that it even existed
https://robocorp.com/docs/development-guide/browser/how-to-work-with-iframes
I first needed to switch frames.
To identify the element with text as SQL you can use you can use either of the following locator strategies:
Using Wait Until Element Is Visible:
Wait Until Element Is Visible xpath=//a[starts-with(#href, 'sql_form.jsp') and #target='frame2']/font[text()='SQL'] 10 seconds
Using Wait Until Element Is Enabled:
Wait Until Element Is Enabled xpath=//a[starts-with(#href, 'sql_form.jsp') and #target='frame2']/font[text()='SQL'] 10 seconds
References
You can find a couple of relevant detailed discussions in:
How to click a row that has javascript on click event in RIDE
Robot Framework: Wait Until Element Is Visible vs. Element Should Be Visible, which one is better to use?

LogicApps scenario log on, download, zip

I access a 3rd party website using forms authentication (username and password).
Once logged on I make a call to a HTTP endpoint and receive XML in the body. The XML contains 1000 XML elements. Within each element there is a text value, a code.
For each of these codes I make a further call to a different HTTP endpoint. The response is more XML.
When all 1000 responses have been received I would like to add all the XML responses as files to a zip container and make it available for download.
I would like to see how LogicApps could do this as quickly as possible.
Make the call to the first HTTP endpoint (auth set to basic auth with user/pass inputted)
Use the xpath(xml(<body var here>), '//elementNameHere') expression on the Body of the result from the call to get all the elements of the return value that have the code in it
Foreach over this return value and
make the HTTP call
append the result to an array variable, or concat on to a string variable.
Submit this value to blob storage
Because you're messing w/ vars in the foreach loop, though, you'll have to do it sequentially (set concurrency control on the Foreach Loop to 'on' and '1') else you could end up with a bad result.
I don't know of a way to "zip contents" here so you may have to send the result to an Azure Function that uses a .Net zip lib to do the work (or js zip lib, whatever your flavor) and does the put to blob storage for you.
This would also all be much easier in Durable Functions land, I encourage you to look in to that if you're so inclined.
One mild alternative you might consider is for step 3.2, instead upload that result to a blob storage container, then make the entire container available for download via an Azure Function call which gets the container & zips up the contents (or does the Blob Storage URL for a container do this for you already? not sure)

Watin AttachTo: Timeout while waiting for frame document becoming available

I am trying to make WatiN attach to an IE popup window (IE 10).
This popup contains a frameset --> a single frame --> a pdf document.
My goal is to save this pdf to my disk.
Dim winExists = IE.Exists(Of IE)(Find.ByUrl(Function(url) url.Contains("__ADFvDlg")))
If winExists Then 'this evaluates to true
Dim win = IE.AttachTo(Of IE)(Find.ByUrl(Function(url) url.Contains("__ADFvDlg"))) ' Timeout while waiting for frame document becoming available
End If
1) I have tried using the above code inline or in a STA thread
2) When coded inline, its parent thread is also STA
3) I have tried to increase the default timeout to 8 minutes, same result after 8 minutes have passed
There is no other option for me than to parse this particular popup, since it is a site built with Oracle ADF and, apart from the fact that it is A MESS, it is very strange at times...this popup has a URL that somehow works only once. If I try to use it in another window, no pdf is returned. The same happens when I refresh the popup.
I cannot fetch the PDF in the Temporary Internet Files since it is not there (I suppose this is because the website works under SSL).
Any guidelines or solutions even outside WatiN's scope is more than welcome since I've hit a brick wall.
Technologies: VS2012, WPF
Thanks a lot in advance.
I found it easiest when I tried the same thing by making the pop-up show up as a new tab. That way I could attach to it's URL. From there I would use
File.WriteAllText(fileName, responseDownLoad.Content.ReadAsStringAsync().Result);
Where responseDownload will be a HttpResponseMessage

Recording a video with audio using GPUImageMovieWriter without jerkiness at start and end of recording?

I am using GPUImage framework to record multiple videos one after other in close intervals with having various filters enabled in real time using GPUImageVideoCamera and GPUImageMovieWriter.
When I record the video, video starts with a jerk(freeze for half a seconds) and ends with a jerk also. I know the reason behind this are the statements in which I pass the movieWriter object to VideoCamera's audioEncodingtarget.
So In my case when I record multiple videos one after other(with different objects of GPUImageMovieWriter), the video preview view freezes at start and end of each recording.
If I remove the audio encoding target statement, conditions improves significantly but of course I don't get the audio.
Currently I am using a AVAudioRecorder while recording to save audio tracks but I believe this is not a ideal work around.
Is there any way to solve this problem.
-- I looked at the RosyWriter example by Apple, their app work almost similarly but smoothly at almost constant 30 fps. I tried to use the RosyWriter code(after removing the code that add purple effect) to save the required videos while showing GPUImageVideoCamera's filtered view to user but in vain. When applied unmodified rosywriter code just records two videos and rest video fails. I also tried to pass in the rosywriter code the capture session from GPUImageVideoCamera but only gets videos with black frames and no audio.
Please help on how can I can record GPUImage filtered videos with audio without this jerkiness. Thanks in advance
I faced the same issue and here is my workaround.
As you pointed out, this problem happened because setAudioEncodingTarget method internally calls addAudioInputsAndOutputs to set audio in/output to the capture session.
To avoid this issue, I created justSetAudioEncodingTarget method for VideoCamera as below,
(on GPUImageVideoCamera.m)
// just set
-(void)justSetAudioEncodingTarget:(GPUImageMovieWriter*)newValue {
if( newValue == nil ) {
return;
}
addedAudioInputsDueToEncodingTarget = YES;
[super setAudioEncodingTarget:newValue];
}
The following steps is my scenario and I checked out it smoothly worked.
Called VideoCamera's addAudioInputsAndOutputs after the VideoCamera was created.
This is not right before starting the recording. :)
Set MovieWriter to the VideoCamera by justSetAudioEncodingTarget that I made above.

ZK - running on google app engine gives a timeout

I have a test page with a list of 100 items.
When I scroll the list down every time this timeout error pops up.
Is there a fix for this in ZK?
There is nothing else special just a list with 100 test rows.
I'll make an educated guess that this is because you're storing some state (maybe "what page is this user on") in memory and expecting it to be around on the next request. In App Engine, it won't be. There are at least 3 ways around this:
Use memcache
If the data's important, put it in the datastore
If the data's small and non-confidential, send it down to the client and have the client send it back to the server on the next request. In this case, that seems like the correct solution.
UPDATE:
On zk docs it says to use:
<zk>
<!-- clustering environment -->
<system-config>
<disable-event-thread/>
<ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
</system-config>
<!-- GAE doesn't allow user's thread -->
<client-config>
<resend-delay>-1</resend-delay>
</client-config>
</zk>
But when I comment this line out:
<disable-event-thread/>
The error goes away!

Resources