OK, I am making a twitter updater and I am having one problem. I can not display the window that tells if the Tweet was sent or not. My issue is that I need to make a window appear. That’s it. I’ve used “makeKeyandOrderFront_(sender)” and so many. I don’t know what to do. Can someone help. Here is the script that I got:
Source Code Offline
Code Offline
makeKeyandOrderFront_ should be makeKeyAndOrderFront_. The easiest way to change it is to set it to | makeKeyAndOrderFront_|
There’s a lot to be said for copying and pasting method names from Help…
Nothing Worked. UGH… Can someone help. Also, Show me an example. (thank for posting so early, Shane)
That’s not very helpful…
Sure:
property secWin : missing value
on hitButton_(sender)
secWin's |makeKeyAndOrderFront_|(me)
end hitButton_
And if you have fixed the name of the method as I suggested earlier, that’s going to be of no help.
Try logging secWin’s class and make sure it’s correct.
I want to be able to make a window pop up with Applescript. Also, show me an example. Please look at the code and see the comment “–EDIT THIS”
I logged the numbers 1,2, and 3. Here’s the code:
--
-- Twitter_UpdaterAppDelegate.applescript
-- Twitter Updater
--
script Twitter_UpdaterAppDelegate
property theTweet : missing value -- the tweet
property theusername : missing value -- the username
property theuserpass : missing value -- the password
property loginwindow : missing value -- the login window
property twitterwindow : missing value -- the twitter window
property sendlabel : missing value -- sending label
property sendwindow : missing value -- sending window
property loadbox : missing value -- the loading box
property spinner : missing value -- the spinner
on awakeFromNib()
theusername's setStringValue_(do shell script "defaults read com.twitter.login User")
theuserpass's setStringValue_(do shell script "defaults read com.twitter.login Pass")
activate
end awakeFromNib
on quit_(sender)
do shell script "defaults write com.twitter.login User " & (theusername's stringValue())
do shell script "defaults write com.twitter.login Pass " & (theuserpass's stringValue())
quit
end quit_
on filter_(sender) -- filter for twitter rules
set Tweet to theTweet's stringValue() as string
set twtcount to count Tweet
if twtcount is greater than 141 then -- twitter's 140 limit rule
display dialog "You have a tryed to send a tweet to twitter that is more than 140 characters. I will ask for your tweet again! (-1)" buttons {"OK"} default button 1
else if twtcount is 0 then
display dialog "You have a tryed to send a tweet to twitter that is 0 characters. I will ask for your tweet again! (-2)" buttons {"OK"} default button 1
else
twitter(Tweet)
end if
end filter_
on twitter(Tweet) -- to twitter it goes
set TwitterUser to name of login()
set TwitterPassword to password of login()
set TwitterUpdate to "/usr/bin/curl" & ¬
" --user " & quoted form of (TwitterUser & ":" & TwitterPassword) & ¬
" --data status=" & quoted form of en(Tweet) & ¬
" [url=http://twitter.com/statuses/update.xml]http://twitter.com/statuses/update.xml"[/url] -- sets the update shell script
set sended to do shell script TwitterUpdate -- sents the tweet
if sended does not contain "Could not authenticate" then
log "1"
sendlabel's setStringValue_("Your tweet has been sent successfully!")
log "2"
sendwindow's makeKeyAndOrderFront_(me) -- EDIT THIS
log "3"
else if sended contains "Could not authenticate" then
sendlabel's setStringValue_("Your tweet was not sent successfully. Check your login info by going to \"File\"→\"Login\"")
sendwindow's makeKeyAndOrderFront_(me) -- EDIIT THIS
end if
end twitter
on login_(sender) -- getting login info
set username to ""
set userpass to ""
try
set loginuser to (do shell script "defaults read com.twitter.login User")
on error F
if F contains " does not exist" then
set username to theusername's stringValue() as string
do shell script "defaults write com.twitter.login User " & username
end if
end try
try
set loginpass to (do shell script "defaults read com.twitter.login Pass")
on error F
if F contains " does not exist" then
set userpass to theuserpass's stringValue() as string
do shell script "defaults write com.twitter.login Pass " & userpass
end if
end try
if username is "" then
set username to loginuser as string
end if
if userpass is "" then
set userpass to loginpass as string
end if
if (theusername's stringValue()) is not username then
set preusername to (theusername's stringValue())
do shell script "defaults write com.twitter.login User " & preusername
end if
if (theuserpass's stringValue()) is not userpass then
set preuserpass to (theuserpass's stringValue())
do shell script "defaults write com.twitter.login Pass " & preuserpass
end if
set returner to {name:username, password:userpass}
return returner
end login_
on login() -- getting login info
set username to ""
set userpass to ""
try
set loginuser to (do shell script "defaults read com.twitter.login User")
on error F
if F contains " does not exist" then
set username to theusername's stringValue() as string
do shell script "defaults write com.twitter.login User " & username
end if
end try
try
set loginpass to (do shell script "defaults read com.twitter.login Pass")
on error F
if F contains " does not exist" then
set userpass to theuserpass's stringValue() as string
do shell script "defaults write com.twitter.login Pass " & userpass
end if
end try
if username is "" then
set username to loginuser as string
end if
if userpass is "" then
set userpass to loginpass as string
end if
if (theusername's stringValue()) is not username then
set preusername to (theusername's stringValue())
do shell script "defaults write com.twitter.login User " & preusername
end if
if (theuserpass's stringValue()) is not userpass then
set preuserpass to (theuserpass's stringValue())
do shell script "defaults write com.twitter.login Pass " & preuserpass
end if
set returner to {name:username, password:userpass}
return returner
end login
on en(URLs)
return do shell script "/usr/bin/python -c '" & ¬
"from sys import argv; " & ¬
"from urllib import quote; " & ¬
"print quote(unicode(argv[1], \"utf8\"))' " & quoted form of URLs
end en
end script
±--------------±--------------±--------------±--------------±--------------±--------------±--------------±--------------±--------------+
This is what I got:
That means you’re sending the command to an NSView, not an NSWindow. I’d guess sendwindow is connected in IB to the window’s content view, not the window itself.
People: if you have a problem and it results in something appearing in the log, please post the log. Posting reams of code is pointless if the problem isn’t in the code.
THANK YOU! FINALLY, I (almost) FINISHED MY APP!
Now I finished. Here is the download for the app.