Beginner question about Applescript

Hello,
I'de like to know two things :
- can I use Applescript on an application which does not have any dictionary ?
- do you think it would be possible to make a script which would detect the opening of a window on this application, and automatically display this new window on the front screen ?

Improved:
set theApp to "yourapp"
set windowcount to (count of windows of application theApp)
repeat
if ((count of windows of application theApp) > windowcount) then
  exit repeat
else if ((count of windows of application theApp) < windowcount) then
set windowcount to (count of windows of application theApp)
end if
end repeat
--actions
display dialog "Hey! A window was opened!"

Similar Messages

  • Beginner question about NetBeans

    I am new to java, which is why I am posting on this forum. I have been messing around with the NetBeans IDE and have made a couple GUI's now. First question is how do I have the window change. For example, if the application opened up and it showed a menu with a couple different buttons you could click to do different things, how would I make it so when you clicked a button the window changed into what was supposed to be on the screen next. Say one of the options was "Calculator", how would I make the window become a calculator after it was clicked? Do I make a new JFrame with the all the calculator stuff? If so, how do I "connect" the two of them? I want it to appear in the same window, not open a new one. My second question was how do I make it so my applications can be run from the desktop without having to build from within NetBeans?
    It was a little difficult to explain what I was asking, but any help is appreciated. I am assuming that what I'm trying to do is pretty basic, sorry I'm newbie.

    mdewaddict11 wrote:
    I am new to java, which is why I am posting on this forum. Let me try to be the first to welcome you to our little corner of the Java world.
    I have been messing around with the NetBeans IDE and have made a couple GUI's now. First question is how do I have the window change. For example, if the application opened up and it showed a menu with a couple different buttons you could click to do different things, how would I make it so when you clicked a button the window changed into what was supposed to be on the screen next. Say one of the options was "Calculator", how would I make the window become a calculator after it was clicked? Do I make a new JFrame with the all the calculator stuff? If so, how do I "connect" the two of them? I want it to appear in the same window, not open a new one. My second question was how do I make it so my applications can be run from the desktop without having to build from within NetBeans?I have a feeling that you are searching for a way to change your GUI "view" on some action, and if so, there are many solutions to do this. Probably one of the more common ways is to use a CardLayout to swap JPanels, but other options including popping up a JDialog, using JTabbedPanes, hiding a JFrame and showing another, ... exist.
    It was a little difficult to explain what I was asking, but any help is appreciated. I am assuming that what I'm trying to do is pretty basic, sorry I'm newbie.You're doing fine, relax.
    Now I need to get on my soap box and discuss another issue that you've not asked about. First off, Java is not like Visual Basic, C#, or other .NET languages (assuming you may be familiar with the MS Visual Studio) in that our programs are not first and foremost GUI's with code tacked on. There's a lot to learn when starting to code in Java, enough that adding Java GUI coding may be a bit overwhelming at the start. I'm going to recommend that you put the GUI stuff to the side for a bit, study the basics of Java, and then later when you're comfortable with the rudiments of Java, start learning Swing coding but without NetBeans code generation. If you learn it through the Sun tutorials, Swing will make a whole lot more sense and even using NetBeans to generate some Swing code will be easier for you. Regardless what you do, best of luck!
    Edited by: Encephalopathic on Jul 7, 2010 2:15 PM

  • Beginner question about CommandListener

    Hi all! I am programming my first cell phone application. Here´s my problem: I have a sequence of menus and all of them use CommandListener to figure out what should be done next. I will put part of my code
    public class Planilha extends MIDlet implements CommandListener {
    private List mList, mListSec, mListMes;
    Form formPerfil,formPagto,fromVis;
    //Here I have declared Commands, etc
    /Construtor
    public Planilha(){
              //THIS IS MY MAIN PANEL. FROM HERE, I HAVE 3 PATHS(3 ANOTHER PANELS)
              mList = new List("Expenses", List.IMPLICIT, stringElements, imageElements);//stringElements and imageElements are initialized
            //Commands are initialized
            mList.addCommand(cFirst);
            mList.addCommand(cSec);
            mList.addCommand(cThird);
           mList.setCommandListener(this);
           //THIS IS ONE OPTION THAT CAN BE ACTIVATED AFTER PANEL mList
           formPerfil = new Form("Budget");
            //Commands are initilized
                formPerfil.addCommand(cBack);
         formPerfil.addCommand(cSave);
         formPerfil.setCommandListener(this);
           //THIS IS A SECOND OPTION THAT CAN BE ACTIVATED AFTER PANEL mList
           mListSec = new List("Expenses", List.IMPLICIT, stringElements1, imageElements1);
           mListSec.addCommand(cBack);
           mListSec.addCommand(cExpense);
           mListSec.setCommandListener(this);
           //STILL GOT A THIRD OPTION BUT I WILL LEFT IT OUT
    public void startApp() {
        Display.getDisplay(this).setCurrent(mList);
    //HERE IS MY PROBLEM. ONLY FIRST OPTION IS BEING REACHED
    public void commandAction(Command c, Displayable s) {
        if (c == cFirst || c == List.SELECT_COMMAND) {
          //HERE I CALL THE FIRST POSSIBLE PATH
             Display.getDisplay(this).setCurrent(formPerfil);
        else if(c == cSec){
             //HERE I CALL THE SECOND OPTION
             Display.getDisplay(this).setCurrent(mListSec);
        else if(c == cThird){
             //A THIRD OPTION FROM PANEL mList
            Display.getDisplay(this).setCurrent(mListMes);
        else if(c == cExpense){
        //HERE A COMMAND COMMING FROM THE SECOND PANEL. ITS NEVER CALLED
         //ANOTHER COMMAND THAT DOES NOT COME FROM MAIN PANEL (mList)
        //IS THIS CORRECT TO PUT THIS COMMAND IN THE SAME COMMAND LISTENER?
        else if(c == cSave){ }So my problem is: even if I choose option 2 or 3 from mList, only the first option is selected. In other words, only formPerfil is being called.
    My second question is that I have some command listeners on the other panels but mList. Is this correct to add in the same method CommandAction? For example, I added "cSave" and "cExpense". Is there any problem with it?
    Thx in advance

    ThomYork wrote:
    ...So my problem is: even if I choose option 2 or 3 from mList, only the first option is selected. In other words, only formPerfil is being called.
    My second question is that I have some command listeners on the other panels but mList. Is this correct to add in the same method CommandAction? For example, I added "cSave" and "cExpense". Is there any problem with it?I can't point exactly but the way how you "mix" select command with cFirst, cSec and cThird just doesn't feel right.
    To handle selection in implicit list, neither of added commands is necessary. It is sufficient to just detect select command in the list and then use [getSelectedIndex() method|http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/List.html#getSelectedIndex()|javadoc] to figure which item was selected.
    Another thing that looks suspicious is that commandAction does not check the displayable parameter ('s'). Say, without checking this paramenter, one will never know if SELECT_COMMAND comes from mList or mListSec.
    Regarding your questions on handling "cSave" and "cExpense" commands in mList's comandAction, the way you do it is legal.
    By the way, it is equally legal to do it the other way - ie provide dedicated listener for formPerfil and handle its commands in that dedicated listener. It is a matter of your personal preference, which way to choose. Myself, I more often use dedicated listeners, about like like this:
    // assuming that list is implicit and that no commands are added
    //   to mList, ie only select command is available by default...
    mList.setCommandListener (new CommandListener() {
      public void commandAction(Command c, Displayable s) {
        // here,
        //  - I don't check c since I expect only SELECT_COMMAND
        //  - I don't check s since I expect only mList
        switch (mList.getSelectedIndex()) {
          // do things depending on list selection
    });

  • Question about AppleScript command.

    I am looking for a command in AppleScript that will Operate a Key Binding. For example, I want to, in my script, have the computer use "Command-Shift-Z" without me touching the keyboard. I have looked through the entire AppleScript PDF from Apple and found nothing that could help me. I have considered using Terminal to create a script that fires the key binding, but I know very little about how to use Terminal. I have also played around with X11, (for about an hour and knowing nothing about what it is,) and that got me nowhere. There was a "bind" command in X11, but like I said, I have no idea what X11 is.
    If AppleScript can't do this for me, could someone suggest a way of scripting that command some other way, then importing\implementing it in AppleScript?
    I am basically trying to automate my dictation program by using Mac's built in "Speech" to start the program, then turn off "Speech" then turn on the microphone in the other program and open a new notepad to dictate to.
    I have every part of the script down but the parts that require input from the keyboard....
    Any help is GREATLY appreciated!

    Thank you again for the help! I have figured it all out, thank god for apple having an easy laungage to understand! I'll post my script here and in the other forums, just incase someone is looking for something like this. I have kind of taken it upon myself to set my mac up to run, nearly, or totally, from voice commands.
    Thank you again!
    tell application "MacSpeech Dictate.app"
    activate
    end tell
    tell application "System Events"
    if UI elements enabled then
    tell process "MacSpeech Dictate"
    set frontmost to true
    tell menu bar 1
    tell menu "File"
    click menu item "New Note Pad"
    end tell
    tell menu "Speech"
    click menu item "Microphone On"
    end tell
    end tell
    end tell
    tell process "Finder"
    key down {command, shift}
    keystroke "z"
    key up {command, shift}
    end tell
    tell process "MacSpeech Dictate"
    set frontmost to true
    end tell
    end if
    end tell
    -------

  • Beginner question about installing 1.5 on new machine

    I signed up for a Creative Cloud account when Edge Animate 1.0 was released and installed it on my laptop.  I am finally going to set aside some time to learn the software, but I have a better, new laptop now.
    It was my understanding at the time, and I have read about this recently too, that Adobe was being gracious enough to offer versions 1.0 and 1.5 indefinitely for free.
    My problem is that on my new laptop I can't install the software.  I found links for the Adobe Application Manager and people saying you could get it through there.  But when I open AAM there is no option to download the software.  I also installed the Creative Cloud software, but can't download 1.5 from there either, only the 30 day trial version (not what I was looking for).
    I was hoping to get the one that will work indefinitely at version 1.5 like I had previously, on my new computer (except I actually have 1.0 on my old computer).
    Any tips?
    I apologize if this has already been covered, I searched extensively through the forums to see if there was already an answer to my question.

    Hi, Jason-
    I want to clarify that we are not offering 1.0 and 1.5 indefinitely for free; we are offering 1.x in a perpetual license for a promotional price of free.  The first statement implies that we will always offer 1.5, no matter what happens with the HTML world.  The latter means that once you download 1.x, we won't expire the version you download.  Just wanted to clarify your statement.
    Thanks,
    -Elaine

  • Another beginner question about targeting functions

    I've read what I thought was an excellent thread about scope in EA, but I'm still not getting some of the basics (btw the thread was http://forums.adobe.com/message/5287753#5287753).
    I have "slides" in the symbol library and in the main composition compositionReady script I've set up a generic script for playing back sound. That script works fine when I bind it within the compositionReady script to a symbol and click, so I know the funciton itself is fine. My question, I'm programmatically loading the slides from the library as I go along and want to use the generic function I created in the compositionReady script, but I can't seem to create the proper syntax to call the script. Here's some that I have tried. What is the correct syntax? The script is on frame inside the slide symbol.
    //sym.getComposition().getStage().playSound();
    //sym.getComposition().playSound();
    //Edge.getComposition("CER_1").playSound();

    Thanks for having a look. Yea, it's getting to the script fine but it doesn't like the syntax. Console always indicates javascript error, which is what happens when Edge throws an exception because it doesn't know what to do. The article that Elaine posted on above gives me the sense that it might be best to change the function to a variable, then it would be in scope to call but I have parameters I'd like to pass with it and I don't think  I can pass a parameter with to a variabalized (word?) function. I know it's just me moving from ActionScript to Edge JavaScript and scope. Whereas I could always find a homebase in ActionScript with the stage, it seems that the stage in Edge is just another symbol and calling a function within the stage is never getting there. Elaine hints at putting outside the stage closure and it would be accessible, which, of course, has led me to start readying JavaScript books and learning more about scope etc. It seems like that is life as a developer. I  dont' get that, oh, better take a day or two to  understand that concept, oh, that function works now, next problem. ;-)

  • Beginner question about granting access rights

    Hi, am a total beginner, just a very simple question. I have created a number of tables with my admin account that I would like user accounts to be able to see (they should only be allowed to see these few tables)
    I then created a user account called EDWARD with just the basic connect access right (I don't want them to be able to create/delete tables etc, just to be able to query the tables I have created above and to add rows to these tables)
    Google searching has lead me to the grant statement, so I tried this from the admin account:
    grant select, update, insert on CUSTOMERS to EDWARD;
    This statement executes correctly but when I log in the EDWARD account I cannot do any of these things, instead I get the error: ORA-00942: table or view does not exist
    Any ideas?
    Thanks

    >>Would it be better to create a separate account called 'ADMIN' perhaps that I use for
    my application admin and then grant them appropriate access to confidential tables
    rather than logging them in as the SYSTEM?
    Yes, this is what I would advise, since SYSTEM (like SYS and several others...) is not user like other, it's better do not work and create object under this one. Keep it for Oracle administration usage only, not for application administration, create your own schema for this.
    Nicolas.

  • Two questions about AppleScript

    Hey,
    Just wondering:
    i) is there a way to make AppleScript wait for a certain amount of time?
    ii) is there a way to repeat the script over and over again?
    Cheers, Ricky.

    If you do just want a pause in the middle of a script, delay is the command you want:
    <pre class=command>delay 10</pre>
    However, I'm guessing your two questions are related - you want to run a piece of code periodically.
    In that case, the easiest way is to write an idle handler. This is called automatically, as often as you define:
    <pre class=command>on idle
    -- your code here
    return 60
    end idle</pre>
    If you save this as a 'Stay Open' script the code will run your code, then wait 60 seconds and run it again, and again, and again, until quit/cancelled.
    The return value indicates how long to wait before calling the idle handler again.

  • Beginner question about prepared statements...PLEASE help! :-)

    First let me say thanks for the assistance. This is probably really easy to do, but I'm new to JSP and can't seem to figure it out.
    I want to dynamically populate a table that shows whether a particular person has an appointment at a given date and time with a user. To do this, I want to query the MySQL database for the lastname of the person with the appointment that occurs with the user at the year, month, date, and time, in question.
    THE CODE BELOW DOESN'T WORK (obviously) BUT SOMEWHAT ILLUSTRATES WHAT I'M TRYING TO ACCOMPLISH:
    <%
    Driver DriverTestRecordSet = (Driver)Class.forName(MM_website_DRIVER).newInstance();
    Connection ConnTestRecordSet = DriverManager.getConnection(MM_website_STRING,MM_website_USERNAME,MM_website_PASSWORD);
    PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id='<%=(((Recordset1_data = Recordset1.getObject(user_id))==null || Recordset1.wasNull())?"":Recordset1_data)%>' AND year='<%= yy %>' AND month='<%= months[mm] %>' AND date='<%= dates[dd] %>' AND appttime='16:15:00'");
    ResultSet TestRecordSet = StatementTestRecordSet.executeQuery();
    boolean TestRecordSet_isEmpty = !TestRecordSet.next();
    boolean TestRecordSet_hasData = !TestRecordSet_isEmpty;
    Object TestRecordSet_data;
    int TestRecordSet_numRows = 0;
    %>
    The real problem comes in the prepared statement portion. If I build the prepared statement with static values like below, EVERYTHING WORKS GREAT:
    PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id='1' AND year='2002' AND month='October' AND date='31' AND appttime='16:15:00'");
    But when I try to use dynamic values, everything falls apart. It's not that the values aren't defined, I use the user_id, year <%= yy %>, month <%= months[mm] %>, etc. elsewhere on the page with no problems. It's just that I can't figure out how to use these dynamic values within the prepared statement.
    Thanks for reading this far and thanks in advance for the help!!!!

    Hi PhineasGage
    You are little bit wrong in your
    your preparedStatement.
    Expression tag within scriptlet tag is invalid.
    Whenever you are appending the statement with
    expression tag, append it with "+" and remove
    expression tag.
    Hopefully it will work
    ThanksThanks for the response!
    I know that the expression tag within scriptlet tag is invalid. I just need a workaround for what I want to do.
    I'm unclear what you mean by "Whenever you are appending the statement with expression tag, append it with a "+" and remove expression tag".
    Could you give an example?
    In the meantime, I've been trying to digest the docs on prepared statements and have changed the code to look like:
    PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id= ? AND year= ? AND month= ? AND date= ? AND appttime='13:15:00'");
    StatementTestRecordSet.setInt(1,1);
    StatementTestRecordSet.setInt(2,2002);
    StatementTestRecordSet.setString(3,"October");
    StatementTestRecordSet.setInt(4,31);
    Again, WITH THE STATIC VALUES, THIS WORKS FINE...but when I try to use expressions or variables like below, things don't work:
    StatementTestRecordSet.setInt(2,<%= yy %>);
    Obviously, I'm doing something wrong, but there has to be a way to use variables within the prepared statement.
    ALSO, the values are being passed to this page via URL in the form:
    samplepage?user_id=1&year=2002&month=October&date=31
    Based upon this information, is there another way (outside of stored procedures in the db) to do what I want to do? I'm open to ideas.

  • Beginner Question about Substitution in 0kem

    Good morning everyone,
    I'm new to ABAP and have been assigned a project with using a substitution for the Profit Center. I've been looking around and can't seem to find an answer to a basic question - does a substitution only work if a sales order is created in VA01 or does it also activate when a sales order is modified? I can't seem to activate the substitution rule even though I have gone through all the correct steps to create one. I'm wondering if it's because the test data only has me modify a previously created profit center when I need to create a new one? Sorry if this question has been asked before but I couldn't find it with all my googling.

    Hi,
    It only works at the time of sale order creation.
    Regards,
    Mukthar

  • A question about applescript

    Hi:
         I am learning applescript and trying to follwo example in books. I found that I can not change the width of name column under list view of Finder just as the examples. My script is as below:
    tell application "Finder"
      activate
              tell list view options of the front Finder window
                        tell column name column
                                  set its width to 2000
                        end tell
              end tell
              tell the front Finder window
                        set current view to list view
              end tell
    end tell
    tell application "Finder"
      activate
              tell list view options of the front Finder window
                        tell column name column
                                  get its width
                        end tell
              end tell
    end tell
    ==> I can set the value of "width". But I can find any change in the finder window.
                                                  Thanks!!!

    There is a problem with Finder windows reflecting scripted changes.
    You can get around this by closing and then re-opening the window after you make the change.  Something like this for the first part of your script.
    tell application "Finder"
      activate
              set thisFolder to target of front Finder window --<-- store the window
              tell list view options of the front Finder window
                        tell column name column
                                  set its width to 2000
                        end tell
              end tell
              tell the front Finder window
                        set current view to list view
      close --<-- close the window
              end tell
      open thisFolder --<-- re-open the window
    end tell

  • Quick beginner question about Applications folder

    I have a really simple basic question: Can I organize my computer's applications folder anyway I want? I don't want to move anything out of the apps folder but I do want to group my apps by a few different categories using folders. I don't see why this would be a problem but I wanted to be sure before I fouled anything up. (Time Machine will be nice).

    Create an Applications folder in your home folder and fill it with aliases to the real applications. You can organise these into sub-folders as you wish, without affecting the real applications. Moving the real applications can make updates fail. Different users can have different arrangements of applications.

  • Beginner question about using selection tools (Mac OS X 10.6 user)

    I click on, say, Magnetic Lasso and it does its thing. But, in true Sorcerer's Apprentice fashion, it keeps on going and going. Two questions: how to stop the tool, and how to correct the deviant strokes? To stop ML, I click Command + D and nothing happens. I choose Deselect and nothing happens. Also, I am trying to select 2 discontinuous regions in the photo. How to do that? Thanks!

    When you double click, it should finish up the selection. You can use the selection brush to tidy up (Option-drag to remove areas.)
    To add more areas hold down shift as you select or turn on the add to selection square in the options bar if the tool has it.

  • Quick question about AppleScript and "current playlist."

    I have a few scrips that I'd like to have operate on whatever playlist is selected at the moment. The script dictionary has a "current playlist" object for iTunes, but it references the playlist the currently playing song is in, not the currently selected playlist. This is not what I want.
    I suppose I could make iTunes play, pause, then stop in my script, but it seems like there has to be an easier way. Suggestions?

    Hi,
    Someone in the Applescript Forum might be able to help:
    http://discussions.apple.com/forum.jspa?forumID=724
    Regards,
    Colin R.

  • Simple beginner question about default tables (LOGMNR, etc.)

    Hi all, I just installed SQL Developer and the Express server. I have worked with other SQL databases and with remote Oracle databases. But never been a DBA for an Oracle DB. I tried searching on LOGMNR and AQ$_, but couldn't find anything, hence this question.
    If there is some online documentation that covers these particular tables and my question, then a pointer to that would be appreciated.
    Anyway, I created a connection per the instructions and it seemed to work. But when I look at tables listview, I see a whole slew of tables. I assume these are all housekeeping/meta data tables (eg. information_schema in MySQL). Is this correct?
    Also, short of manually creating a filter for each of the file types ("%$%"help", "LOGMNR%", "SQLPLUS%", etc.), is there an easy way to ignore these tables and just see the tables I want to create for testing purposes?
    And I am curios why these all show up by default. Could it be that I am expecting something because of experience with other databases and am actually doing things the "wrong" way? Or is this just because I am using the Express Server? Or is there another (very good) reason for these tables to exist?
    Thanks,
    justme

    The complete oracle documentation is at http://tahiti.oracle.com. There is a lot of it, but Log Miner and Advanced Queuing have their own manuals. You should also consider starting with the Concepts Manual followed by one of the "2-day" tutorials such as "2-Day DBA"
    What user are you connecting as? It sounds as if you are connecting as SYS or SYSTEM if you can see the dictionary tables.
    You should create a separate user to connect as.
    (create user myuser identified by mypassword;
    grant connect,resource to myuser;)

Maybe you are looking for

  • How to loop through the "On My Mac" folders in mail?

    Hi there - i am new to applescript, but am slowly working out how to use it. I am stumped on how to write a rule that will move a message to a folder identified by a tag in a message (I am using MailTags). I have script that will take the first tag a

  • How to get the tld value in jsp

    Hi Folks, i want to call the tld value in my jsp page. here is my tld: <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>search</shortname> <info>TagLib for the regain search engine</info> <tag> <info> Writes a link to t

  • Dealing with inherited xml facts in business rules

    Hello Everyone, I encountered a problem while writing business rules for an xml input message which is of abstract type. The schema follows the xml inheritance and the structure is somewhat like - Document (abstract) *|* Message (abstract) *|* Notifi

  • Credit note adjustment against invoice

    Hi Gurus, We have an issue for adjustment of credit memo amount against invoice in F110.  User is not maintaining invoice reference number in credit memo. At the time of F110, credit memo is getting adjusted against invoice for certain company codes

  • RTFTemplateGenerator  - migraton Utility

    Hi All, I am trying to convert my existing 10g reports to BIP 11g. Is there a conversion utility for this? I am familiar with the conversion utility for BIP10g but from my understanding abt 11g, it cannot be reused. Am I correct? When I use the RTFTe