This is the error that pops up when I try my script out:
Script Error ---- Can’t make {button returned:"Enter", text returned:"testing"} into type Unicode text.
I'm trying to have users enter a Username so that they that have their Documents folder be linked to a file server.
I have that part separate but now on this part of having the user input their username so when I have ln -s /Volumes/Drive/Documents Documents the username will automatically pull from the script and input it by itself so the Documents folder and File server could be linked.
Basically trying to make it to where the user doesn't have to go into the terminal and link the two together. I'm not sure why the error code is popping up other than it is probably having to deal with the set Username part of the script so not completely sure.
set Username to (display dialog "Enter your NetID Username" default answer "" buttons {"Cancel", "Enter"} default button 2)
tell application "Terminal"
activate
do script "'ln -s /Volumes/Drive/Documents Documents'" & Username
end tell
return input
The error message
Can’t make {button returned:"Enter", text returned:"testing"} into type Unicode text.
is pretty clear.
display dialog returns a record, not a string so you have to write
set Username to text returned of (display dialog "Enter your NetID Username" default answer "" buttons {"Cancel", "Enter"} default button 2)
Or if you need to handle the button and the returned text write
set {button returned:buttonReturned, text returned:textReturned} to display dialog "Enter your NetID Username" default answer "" buttons {"Cancel", "Enter"} default button 2
Related
I noticed that the command line 'zip' tool and Mac OS X's 'Compress XXX' option (available via right click in finder) are giving different output files. Not only is the size of the file a few hundred bytes bigger but the content is significantly different as well.
How can I find out what command the Finder is using for compression?
The answer is in man ditto:
The command:
ditto -c -k --sequesterRsrc --keepParent src_directory archive.zip
will create a PKZip archive similarly to the Finder's Compress function-
ality.
Take a look at An AppleScript to compress a Finder selection article.
try
tell application "Finder"
set theSelection to the selection
set selectionCount to count of theSelection
if selectionCount is greater than 1 then
error "Please select only one Finder item before running this script."
else if selectionCount is less than 1 then
error "Please select one Finder item before running this script."
else
set theItem to (item 1 of theSelection) as alias
set destFolder to (container of theItem) as alias
set itemName to name of theItem
end if
end tell
do shell script ("ditto -c -k --sequesterRsrc --keepParent " & quoted form of POSIX path of theItem & space & quoted form of (POSIX path of destFolder & itemName & ".zip"))
on error theError
tell me
activate
display dialog "Error: " & theError buttons {"OK"} default button 1 with icon stop
end tell
end try
I can get my script to sent a pictures by email, its sending the text of the files instead the real files (Hello, here is the screenshot of iLog :~:ilogscreenshot.png)
Plus for sone raison , when I take the first screenshot , nothing happen until I change the windows, and then I have the dialog "are you happy with the screenshot"
Any idea where I should change the code?
Many thanks
-- Start of screenshot
display dialog "You will have to select the screenshot area you want when you see the cross cursor" buttons {"OK"} default button 1
-- Select the aera :
tell application "iLog" to activate
delay 1
do shell script "screencapture -i ~/ilogscreenshot.png"
--" & winID
display dialog "Are you happy with the selected aera ?" buttons {"Yes", "No"} default button 2
if the button returned of the result is "Yes" then
-- action for Yes
display dialog "Ok we gonna no sent this by email " buttons {"OK"} default button 1
else
-- action for NO
display dialog "No worry, we gonna try again then" buttons {"OK"} default button 1
tell application "iLog" to activate
delay 1
do shell script "screencapture -i ~/ilogscreenshot.png"
--" & winID
end if
-- end of screenshot
-- sceenshot saved files
set theAttachment1 to POSIX file "~/ilogscreenshot.png"
-- end of screenshot saved files
display dialog "Sent to which email" default answer "#apple.com" buttons {"OK"} default button 1
set recipientAddress to text returned of result
set theSubject to "iLog Sceenshot!"
(* This will past the clopboard on the content
*)
set theContent to "Hello, here is the screenshot of iLog " & theAttachment1
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {address:recipientAddress}
##Send the Message
end tell
end tell
I can't test it with iLog, but the screenshot part works like this:
set screenShot to ((path to desktop) as text) & "ilogscreenshot.png"
# it's easier to check the Screenshot on the Desktop
set happyUser to "No"
repeat until happyUser is "Yes"
tell application "iLog" to activate
do shell script "screencapture -i " & quoted form of POSIX path of screenShot
display dialog "Are you happy with the selected aera ?" buttons {"Yes", "No"} default button 2
set happyUser to button returned of the result
end repeat
Adding the screenshot to an Outgoing Message (here is a good guide):
set theSubject to "iLog Sceenshot!"
set theContent to "Hello, here is the screenshot of iLog:" & return & return
set recipientAddress to "test#test.de"
tell application "Mail"
set theMessage to make new outgoing message with properties {visible:true, subject:theSubject, content:theContent}
tell theMessage to make new to recipient with properties {address:recipientAddress}
tell content of theMessage to make new attachment with properties {file name:file screenShot} at after last paragraph
--send theMessage
end tell
i'm writing a script that needs to copy and paste text from an entry in a dialogue box
set query to text returned of (display dialog "Enter Text" default answer "" buttons {"Input", "Cancel"} default button 1)
query
tell application "System Events"
keystroke "c" using command down
keystroke "v" using command down
end tell
when i run this script it copies and pastes "set query to text..."
how can I copy the query that I entered ? i'm going to paste the text somewhere else later but I need to figure out how to actually copy the text. I was using keystroke query but that was taking a long time when the strings were long
Use set the clipboard:
display dialog "" default answer ""
set the clipboard to text returned of result
If others get here searching for how to for example copy a long error message from a dialog shown by OS X, you can use Accessibility Inspector, which is in /Applications/Xcode.app/Contents/Applications/.
is it possible to put a password on a single word inside a word document?
What I want is to write a system documentation from our IT structure. I want to put the passwords in the document as well. Now I want that you have to enter a "MASTER" password in order to unlock to passwords inside the document. If you do not enter the password, the passwords inside the document should be invisible or something like that.
Is that possible?
Yes, this is possible. To make this work we have to use a combination of Word's inherent document protection, its hidden text attribute, and a couple of VBA tricks.
First, format all the passwords in the document as hidden text. (For those who are unfamiliar, hidden text is only visible when the Show/Hide function is set to true.)
Then add code to make sure that the hidden text will not display and also to protect the document from being edited whenever the document is opened:
Private Sub Document_Open()
AddProtection
End Sub
Sub AddProtection()
With ActiveDocument
.ActiveWindow.View.ShowAll = False
.ActiveWindow.View.ShowHiddenText = False
.Application.Options.PrintHiddenText = False
.Protect Type:=wdAllowOnlyReading, NoReset:=True, Password:="DesiredPassword"
End With
End Sub
Because Word users can normally display hidden text at any given time, we also need to take control of this function. Most menu and Ribbon commands can be intercepted by creating a module containing subroutines named for the intercepted commands. Naming a Sub ShowAll will allow us to control this function and only display hidden text when a password is entered:
Sub ShowAll()
If ActiveDocument.ProtectionType = wdAllowOnlyReading Then
'Do nothing
Else 'restore the Ribbon's toggle function
If ActiveDocument.ActiveWindow.View.ShowAll = True Then
ActiveDocument.ActiveWindow.View.ShowAll = False
Else
ActiveDocument.ActiveWindow.View.ShowAll = True
End If
End If
End Sub
Finally, we add some code to prompt the user for a password and, if entered correctly, display the text that was formerly hidden:
Sub RemoveProtection()
Dim strPassword As String
strPassword = InputBox("Enter document password.")
ActiveDocument.Unprotect Password:=strPassword
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
End If
End Sub
Once all the VBA code is entered, right-click on the module in the IDE, select Project Properties, and assign a separate password on the Protection tab. This will stop power users from getting to the embedded password or changing the code.
All that's left to do is create a QAT button in Word (that is only visible for this document) and assign the RemoveProtection sub to it. Whenever the document is opened the passwords will be hidden and protected from editing, but can then be revealed by clicking on the QAT button and entering the correct password.
EDIT
When I first answered this question, I failed to consider that Word has a hidden text option that can be turned on separateley from the Show All option. Additionally, hidden text can be printed via a printing option. I have added code in AddProtection above to turn off these settings.
Further testing also revealed that a user in Word 2007 could manually go into Office Orb|Options|Display to reveal the hidden text by changing the Show all formatting marks or Hidden text options manually. To avoid this, a Ribbon customization would need to be created and loaded with the document.
Finally, it is worth noting that although it is great fun to bend Word to one's will in order to make it accomplish tasks like this, the level of protection is not as good as encrypting the passwords separately and then unecrypting before revealing the contents or even using Word's document password feature to encrypt the document's entire contents.
I've settings bundle in my iPhone application. How can I right align the PSTextFieldSpecifier value?
This worked for me. If you open the property list (Root.plist) file as a source and paste the following for each entry you want right-aligned:
<key>IASKTextAlignment</key>
<string>IASKUITextAlignmentCenter</string>
Have the same desire. What I currently do is to put some space bars after my title. So I have to text fields in my settings, Account and Password:
Account TheName
Password *****
now I would count the chars that I need to get the same length of both strings. In this case the "Account" label has one char less then the "Password" label. So I would put the remaining characters count twice and append them to the label. In this case the label would be "Account " (2x " ")
following I will replace the " " with "_" so that you can see the difference
Account__ TheName
Password *****
It looks different sized in your XCode Settings Bundle but on the device or in Simulator it will be fine