anyone know how to get a webpage and display it in an applescript studio app, if so how?
It’s called a webview, and can be found in IB under the “Graphics Views” palette (it’s got a safari icon). There are lots of posts here at macscripter covering webviews and displaying web content.
ok, i’m really confused, how would i get a webpage and display it in a window
Quoted because if you’re just going to post the same question twice, you may as well get the answer twice.
i’m kinda new to applescript so none of that is help, i need it to be straight foreward
Webviews don’t have much AppleScript support at this point in time. You have to use the call method
command to call some Obj-C methods.
call method "URLWithString:" of class "NSURL" with parameter "http://www.google.com/"
call method "requestWithURL:" of class "NSURLRequest" with parameter (result)
call method "loadRequest:" of (call method "mainFrame" of (view "something" of window "whatever")) with parameter (result)
If you don’t know what to do with that, then you need to ask a different question.
None of that is help? That’s everything! That’s all there is to it! It’s just a webview and a few lines of code, and BAM!.. you’re done. It doesn’t really get any more straightforward than what we’ve given you reference to. I’m not going to write and re-write the same posts and tutorials over and over again because you don’t want to take the time to a) learn how to do something as fundamental as drag a webview into your window, and b) how to implement a simple bit of code like this…
set URLWithString to call method "URLWithString:" of class "NSURL" with parameter "http://blah.com/"
set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
set mainframe to call method "mainFrame" of webView
call method "loadRequest:" of mainframe with parameter requestWithURL
… which can be found here, here, here, here, here, here… the list goes on. This is fundamental stuff, and you’re going to have to put in some hours learning about how Interface Builder and Xcode work. While we all want to help, I don’t see how I can be any more explanatory than I’ve been in those other posts. I don’t have the time to explain to you how to drag a webview into a window, how to size it, name it, connect handlers to it, and to cut and paste code into your script. If these things are above you, you should be spending a LOT more time practicing and experimenting on test projects before getting so ambitious. I’ve posted this same code over and over, and all I ask is that you do a little research and spend the two seconds that it takes to find it. If you can’t drag and drop a webview into your project, and set up a button that executes a few lines of code… especially with the abundance of reference you’ll find here and in the search link I posted above, then you’re in way over your head. We’re not asking much of you by giving you reference to specific pages that highlight exactly where to find answers. Beyond this, you’ll have to learn to help yourself.
j
ok, but how do i get that to show up in a window?
In Interface Builder, drag a webview to your window and name it appropriately.
ok cool i feel stupid
wait if this is what i put
set URLWithString to call method "URLWithString:" of class "NSURL" with parameter "http://blah.com/"
set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
set mainframe to call method "mainFrame" of webView
call method "loadRequest:" of mainframe with parameter requestWithURL
what do i call the webview?
Name it whatever you want and put that in the code. Let’s say you call it “web” and the window is called “main”. You would change this line.
set mainframe to call method "mainFrame" of webView
to this.
set mainframe to call method "mainFrame" of (view "web" of window "main")
still the webview just shows a white box
What handler you did you put that code in? Where is the URL coming from?
this is what i have
set URLWithString to call method "URLWithString:" of class "NSURL" with parameter "http://googles.com/"
set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
call method "loadRequest:" of mainframe with parameter requestWithURL
set mainframe to call method "mainFrame" of (view "web" of window "main")
whoa didnt see that…but yeah i still just get a white box
Is that all you have? You don’t just paste code into a Studio app. You must connect event handlers in Interface Builder, and then put your code inside the handlers in your script.
What are you trying to do with this anyway?
yeah i’m really new to applescript, so could you help me out with what i need to put in it. and this is just an app my friend requested that will get sports scores, starting lineups for baseball and stuff like that