Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

LOVEFIRE

Suspended
Original poster
Jan 16, 2023
6
0
can't find a better place to post this but my issues is ... that I have this program that needs to be manually run and I want to have a function of the app run automaticly everytime I login. I have no experience with AppleScrit, shells scripts, I have used Automator a few times for stuff. I lost a lot of my knowledge from a bad head injury so any help would be great.
Details: When I login to my account I want to either (1) have a keyboard shortcut automatically run (2) have the function inside the app run, which might be more complex to achieve.
 

Attachments

  • Customize.png
    Customize.png
    251.1 KB · Views: 137
  • Auto hoykey.png
    Auto hoykey.png
    285.3 KB · Views: 67

arw

macrumors 65816
Aug 31, 2010
1,094
857
Welcome!
cmd + down is used in Finder to open the selected file/folder, so a more complex shortcut (like additionally shift) would be advisable.
I‘m currently away from a Mac but pressing the arrow down in combination with shift and command should be:
AppleScript:
tell application "System Events"
    key code 125 using {shift down, command down}
end tell
Is this already enough or do you want a more elegant way?
Do you need to start the app or bring it to the front first?:
AppleScript:
tell application "WiFiSpoof" to activate
Getting the group/number of the correct button is a bit of a hassle.
Do you want the app window to be closed or minimized afterwards?

I think you can directly put the AppleScript in login items but it definitely works if you save it as an application.
 
Last edited:

SYCAMOREGRAD

macrumors regular
May 23, 2006
145
81
Indianapolis
I’ve not had a Mac in the last few years. I thought there was a startup items option in system preferences. But I know Apple has changed so much stuff at the base level. Good luck!
 

LOVEFIRE

Suspended
Original poster
Jan 16, 2023
6
0
@LOVEFIRE What's the point of a randomized MAC address on Ethernet?
Apple’s reason for Wi-FI https://support.apple.com/guide/security/wi-fi-privacy-secb9cb3140c/web
I wasn't always, but I'm disabled fighting for disability (which is a corrupt system) and they hire companies to hack a claimants computer to monitor them to use dirt on them to deny them. I already caught them once a year ago since I have heavy network monitors on my Mac. It's a pain in my ass to be honest. But I need to hide the identity of my device and name on the network. simple explanation. also I don't use wifi in my house, not reliable.
 

LOVEFIRE

Suspended
Original poster
Jan 16, 2023
6
0
Welcome!
cmd + down is used in Finder to open the selected file/folder, so a more complex shortcut (like additionally shift) would be advisable.
I‘m currently away from a Mac but pressing the arrow down in combination with shift and command should be:
AppleScript:
tell application "System Events"
    key code 125 using {shift down, command down}
end tell
Is this already enough or do you want a more elegant way?
Do you need to start the app or bring it to the front first?:
AppleScript:
tell application "WiFiSpoof" to activate
Getting the group/number of the correct button is a bit of a hassle.
Do you want the app window to be closed or minimized afterwards?

I think you can directly put the AppleScript in login items but it definitely works if you save it as an application.

Hey Thank for this! Unfortunately none of these work for me. (1) the first didn't work bc I got errors saying keystrokes are not allowed to be run by automator. and my script app I made. I Mae it an app so I could throw it in login items if it worked. but since I can't use keystrokes that is out ....

I've read stuff online about different approaches but without explanation (making a custom launch agent that runs a script at set location) idk if that is more complex. I was hoping this would be a simple process lol. but how hard would it be to find the group/number? also any other ideas?
 

Attachments

  • Screenshot 2023-01-17 at 12.22.29 PM.png
    Screenshot 2023-01-17 at 12.22.29 PM.png
    213.4 KB · Views: 55
  • Screenshot 2023-01-17 at 12.18.14 PM.png
    Screenshot 2023-01-17 at 12.18.14 PM.png
    212.8 KB · Views: 53

bogdanw

macrumors 603
Mar 10, 2009
5,702
2,740
I will not comment on your motives, but I’ll offer an alternative solution.

1. Install macchanger https://github.com/shilch/macchanger/ , from Terminal

Code:
sudo sh -c "curl https://raw.githubusercontent.com/shilch/macchanger/master/macchanger.sh > /usr/local/bin/macchanger && chmod +x /usr/local/bin/macchanger"

2. Create a read-only app to change the MAC address to a random one. In Script Editor (/Applications/Utilities/Script Editor.app ) copy-paste

Code:
do shell script "sudo /usr/local/bin/macchanger -r en0" user name "YourUserName" password "YourPassword" with administrator privileges

edit YourUserName & YourPassword with your macOS user name and password

Save it as a Run-only app from File > Export (Don’t Code Sign) https://support.apple.com/guide/script-editor/save-a-script-as-an-app-scpedt1072/mac

Your user name and password can not be recovered from this app.

Any time you start the created app, the MAC address for Ethernet en0 will be changed to a random one.

You can run the app at login by simply adding it as a login item https://support.apple.com/guide/mac...tically-when-you-log-in-mh15189/13.0/mac/13.0

You can check the current MAC from Terminal with:

Code:
sudo macchanger -s en0
 

LOVEFIRE

Suspended
Original poster
Jan 16, 2023
6
0
I will not comment on your motives, but I’ll offer an alternative solution.

1. Install macchanger https://github.com/shilch/macchanger/ , from Terminal

Code:
sudo sh -c "curl https://raw.githubusercontent.com/shilch/macchanger/master/macchanger.sh > /usr/local/bin/macchanger && chmod +x /usr/local/bin/macchanger"

2. Create a read-only app to change the MAC address to a random one. In Script Editor (/Applications/Utilities/Script Editor.app ) copy-paste

Code:
do shell script "sudo /usr/local/bin/macchanger -r en0" user name "YourUserName" password "YourPassword" with administrator privileges

edit YourUserName & YourPassword with your macOS user name and password

Save it as a Run-only app from File > Export (Don’t Code Sign) https://support.apple.com/guide/script-editor/save-a-script-as-an-app-scpedt1072/mac

Your user name and password can not be recovered from this app.

Any time you start the created app, the MAC address for Ethernet en0 will be changed to a random one.

You can run the app at login by simply adding it as a login item https://support.apple.com/guide/mac...tically-when-you-log-in-mh15189/13.0/mac/13.0

You can check the current MAC from Terminal with:

Code:
sudo macchanger -s en0

Thanks for taking the time to share all this, though terminal say I can't find directory ... when copying and pasting the macchager install code, I double checked it an it was right so no sure why it won't work. I am on 13.1 macOS.
```sh: /usr/local/bin/macchanger: No such file or directory```
 

bogdanw

macrumors 603
Mar 10, 2009
5,702
2,740
Run
Code:
sudo mkdir -p /usr/local/bin
to create the folder, if it doesn't exist.
 

LOVEFIRE

Suspended
Original poster
Jan 16, 2023
6
0
Run
Code:
sudo mkdir -p /usr/local/bin
to create the folder, if it doesn't exist.

so apparently the script is causing my Mac to have and endless loop of CPU kernel panics. so I had to remove it from my login items .... welp
 

LOVEFIRE

Suspended
Original poster
Jan 16, 2023
6
0
Welcome!
cmd + down is used in Finder to open the selected file/folder, so a more complex shortcut (like additionally shift) would be advisable.
I‘m currently away from a Mac but pressing the arrow down in combination with shift and command should be:
AppleScript:
tell application "System Events"
    key code 125 using {shift down, command down}
end tell
Is this already enough or do you want a more elegant way?
Do you need to start the app or bring it to the front first?:
AppleScript:
tell application "WiFiSpoof" to activate
Getting the group/number of the correct button is a bit of a hassle.
Do you want the app window to be closed or minimized afterwards?

I think you can directly put the AppleScript in login items but it definitely works if you save it as an application.


sorry for the delayed response, so I tried putting a script in login items, I got kernel panics with two versions the simple one above and someone elses using gidhubs macchanger. so .... since my Mac doesn't like scripts in login items ... and applications can't use keyboard shortcuts apparently not allowed by macOS -_- ... I'm left with finding the group key and using it as an application .... I hope I'm not diving into Dantes inferno here lol. but would be nice to learn how to do this if you're up for it. if not no worries. thanks again for all your help!
 

arw

macrumors 65816
Aug 31, 2010
1,094
857
the first didn't work bc I got errors saying keystrokes are not allowed to be run by automator. and my script app I made.
Yeah, that's a security setting of macOS. You have to allow apps (in this case Script Editor) to send keystrokes:
- Go to: System Settings > Security & Privacy > Accessibility
- click the lock on the bottom left, enter your password
- and tick Script Editor
If it is not listed, you can add it from here Applications/Utilities/Script Editor.app
(non-English screenshot from settings in Big Sur)

Here I added opening and minimizing your application:
AppleScript:
tell application "WiFiSpoof"
    activate --open app / bring app to front
    tell application "System Events"
        key code 125 using {shift down, command down} --simulate cmd+shift+arrow down
    end tell
    set miniaturized of window 1 to true --minimize app
end tell
 

Attachments

  • Accessibility.png
    Accessibility.png
    211.2 KB · Views: 46
Last edited:

bogdanw

macrumors 603
Mar 10, 2009
5,702
2,740
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.