This application runs on startup and gives me 60 seconds to confirm I’m connected to the correct wifi before connecting to my server. If I fail to make a decision in 60 seconds the app should attempt to connect to my server by default.
I’m getting closer, but several things still not working.
I am getting the SSID displayed in the dialog box and it’s configured properly.
However, here is a list of issues I cannot seem to resolve. It’s after midnight and I’m calling it a day.
- Refresh time is taking 60 seconds to go from 60 to 55 seconds remaining. It appears to be shorter intervals as it approaches 5 second remaining but it’s not clocking properly.
- Selecting the 'Connect Now' button does not run script.
- Failing to make a selection does not run script.
- Cancel works
MacBook Pro M3 Max
Most of this script with the exception of your input comes from my older application. My older original is working with the exception of getting and displaying the SSID of the connected wifi.
Thanks for all your help.
Here is what I have so far.
use framework "CoreWLAN"
use scripting additions
property ca : current application
# property dialog_icon : "Macintosh SSD:Users:user:Automator Custom Icons:Synology 5 bay DiskStation DS1512+.icns"
property app_icon : "Macintosh SSD:Users:user:Automator Custom Icons:Synology 5 bay DiskStation DS1512+.icns" as text
set Refresh_time to 5 as integer
set wait_time to 60 as integer
set Decision to 0 as integer
repeat until (Decision > 0) or (wait_time = 0)
set Decision to my Get_User_Feedback(wait_time, Refresh_time)
set wait_time to wait_time - Refresh_time
end repeat
log (Decision) as integer
# the rest of your Decision if tests after this comment
return
# display alert "Decision is " & Decision
# 0 means no answer - Should connect without input after 60 seconds
# 1 means Connect Now
# 2 means Don't Connect
if Decision is 2 then
quit
else if Decision is 1 then
tell application "Finder"
try
mount volume "smb://VS/home/Drive"
delay 1
end try
end tell
tell application "Finder"
try
mount volume "smb://VS/Movies"
delay 1
end try
end tell
tell application "Finder"
try
mount volume "smb://VS/music"
delay 1
end try
end tell
tell application "Finder"
try
mount volume "smb://VS/photo"
delay 1
end try
end tell
tell application "Finder"
try
mount volume "smb://VS/TV Shows"
delay 1
end try
end tell
tell application "Finder"
try
mount volume "smb://VS/video"
delay 1
end try
end tell
end if
on Get_User_Feedback(Remain_time, Step_delay)
set mySSID to (ca's CWWiFiClient's sharedWiFiClient)'s interface()'s ssid()
try
# AppleScript needs the option+L line continuation ( ¬ ) character as text does not flow from one line to the next without it.
set {gave up:gaveUP, button returned:buttonReturned} to display dialog ("You are currently connected to WiFi SSID: " & mySSID as text) & return & return & ¬
"You will be connected to the VS Server in " & Remain_time & ¬
" seconds. If your are not on VS Local Area Network, please select 'Don't Connect'." buttons {"Don't connect", "Connect Now"} default button ¬
"Connect Now" with icon app_icon as alias giving up after Remain_time
if gaveUP then
return 0
else if buttonReturned is "Connect Now" then
return 1
else
return 2
end if
end try
end Get_User_Feedback