I use a global shortcut to popup a dialog.
But I would like to fill the dialog depending on the application having the focus at the moment the shortcut is triggered.
But I can not find a way to do it. I read the extension code here
but it's hard to know how to modify the code, and how to recompile electron.
If someone have a pointer, that will be greatly appreciated :)
I couldn't find a way to know which app had the focus before, but I was able to hide my app and return the focus to the previous one, simulating clicking the 'hide' option from the view menu:
const menu = require('electron').Menu;
menu.sendActionToFirstResponder('hide:');
I hope it helps.
I found an answer myself, it looks that the frontmost app (at least on OSX) it still the app that had the focus before the invokation.
Here is my ClojureScript code to find the app info
(defn- get-current-app-info-osx
"Return info about the current frontmost application on OSX"
[]
(let [remote (js/require "remote")
nodobjc (js/require "nodobjc")]
(.framework nodobjc "AppKit")
(let [workspace (.NSWorkspace nodobjc "sharedWorkspace")
app (workspace "frontmostApplication")
app-name (str (app "localizedName"))
app-id (str (app "bundleIdentifier"))]
{:name app-name
:id app-id})))
Related
I'm trying to use NSWorkspace.openURL to open a url with a custom scheme.
If that application exists on the Mac, that method returns true and it opens the app just fine.
If that application does not exist on the machine, it returns false, but it also pops up what looks to be a Mac window saying "There is no application set to open the URL {my url}" and then gives the option to search in the Mac app store.
Is there any way to prevent this popup from happening? Since my application can handle the return false value from the method, and that popup is sending the user down the wrong path.
Something similar to UIApplication.canOpenUrl (UIApplication is only available in ios, not osx)
Any help greatly appreciated.
Should be able to use LaunchService. Documentation here: https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/index.html
In my app's main menu I have a menu item that I'd like to set to the shortcut alt+"minus sign". I was able to set the key equivalent in IB, and it triggers as expected, but it's really ugly when running the app:
Even though in Interface Builder it's fine:
Do you have any idea why it's like that? Thanks!
This seems to be an OS X problem, here's a screenshot from Pixelmator:
And even Preview.app has the same problem/bug (View menu):
I'm new into this.. trying to create a simple app for macosx, basically I want this app to startup right after the user login with username/password..
and it's just a simple app has a window & that window displays a warning message and then have two buttons "agree" & "decline"
if the user hit agree then it will continue to the login process.. works as "LOG IN button"
if the user hit Decline then it will go back to the loginwindow..works like "CANCEL button"
but since am new into Xcode.. I have already created the app with both buttons.. but don't know how to add IBAction and Outlets!..
Any ideas?..
Thanks
This should give you an idea. Also, since you are new to ios/mac dev, I would suggest you to read the documents from Apple that will provide you with a wealth of information. Additionally, read the FAQ of the site to get a better understanding how SO functions.
I'm new to the testing world, so my question might seem a lil' bit too naive and stupid. At risk of looking/sounding stupid, my question is this:
I've been trying to test the contents in a pop-up window on my company's web app. I've figured out how to detect the pop-up window for now, but i can't get selenium to 'click' on the link inside of that pop-up window. there are multiple pop-ups in this web app so it's really difficult for a newbie like to create a test case.
I tried the click, clickAndWait, mouseDown and mouseKey as an option but it is still not working. can somebody guide me through this?
TIA,
Angela
When the popup appears you will need to move the context of the script over to the window.
You can do this by using the selectWindow | window_ID_from_the_link and then do the clicking.
If that doesn't work you may need to use the openWindow command to create the popup and then start testing against that.
Use getConfirmation/getassert/getprompt according to the type of the pop up you use .....By default they will be clicked with ok option by the server and you have to consume the message from the pop up for the other selenium commands to work correctly.............
The above suggestion is given from my experience in working with selenium RC used with perl..........
Perhaps you can try the FireFox Plugin. You can click through your application and record your steps. After recording the steps you can easily save it as some sort of file or unittest.
I'm not sure about the command you should use for the popups, maybe the firefox plugin will help in this manner (it will create your commands).
If you created the popup with a div tag, U can use following code to stop the selenium server until the popup opens.
int second = 0;
while(!selenium.IsElementPresent(mylink))
{
if(second >= 5)
break;
Thread.Sleep(1000);
second++;
}
After a popup opens, Now you can click on any link inside the popup.You have to use the below code.
selenium.click("id=popup_link"); (popup_link is the id of the link present on the popup)
Good Luck.
Not sure if this is what you are looking for, but if you want to click on something specific that Selenium is not able to handle - like browser pop-ups or other pop-ups, you can use Sikuli Script. Sikuli does an image comparison and clicks on the same - this is very powerful.
Here is the link: http://www.sikuli.org/
I've got a code that lists the running application on a win32 box, and then displays theirs icons.
So far so good, I get the hwnd of the app, then call for GetClassLong(hwnd,GCL_HICONSM), and everything's fine.
But the case of a java apps is a pain to deal with, as the process answering to my calls is javaw.exe, and not the shiny-pimpy java application, who's got a so beautiful icon...
I gave a shot at GetWindowThreadProcessId also, but alas, it's the PID of javaw that's returned...
There's a way to do this though, as the task manager (alt+tab) displays the good icon.
I answer to my own question, thanks to PhiLho who put me on the right track: an article from Codeproject with the right algorithm to get a window icon (wether it's java or not):
//first, try:
SendMessageTimeout(WM_GETICON)
//if no icon found, try
GetClassLong(GCL_HICONSM)
//if still no icon, try
SendMessageTimeout(WM_WM_QUERYDRAGICON)
//if still no icon, you're doomed, return an error, or a void icon
For some reason a java app answers to the first call, but not to the others, which seems to be handled by javaw.exe.
Thanks again PhiLho.
Mmm, it can be done, because Process Viewer has a Show Applications button which does that (even if the main view shows the Java's icon). Alas this freeware isn't open source, so it won't tell its secret... :-(
Sysinternals' ProcMon doesn't do that, alas.
I will dig a bit more... :-)
[EDIT] Both a MS KB article and a Code Project article recommend using WM_QUERYDRAGICON if GCL_HICON fails...