It's nice that all you need on the client device is a supported web browser. Actually, this is the main reason why I was (an still am) excited about O-S-C: the ability to connect using almost any device.
Over the time though, I've noticed that, on different WI-FI networks, the IP address of the laptop (or any computer, in general) is changed. Most home routers I've connected to will assign the laptop an IP of this form: 192.168.0.x (x is the varied number), while other ones (routers at my University, for example) will assign an IP of this form: 192.168.y.x.
While I know of the possibility that allows you to assign multiple static IPs (both on winOS and macOS), I wonder if it's possible to connect to the server without thinking about the IP address at all. In other words, I wonder if I could just have a bookmark that says: "127.0.0.1/osc" (or something similar) and connect to it successfully, no matter what IP gets assigned to the server computer.
I know that this would require me to install/have additional software on my client devices (windows tablet & android phone), but is there any chance that a configuration like this could be created?
According to this, the port number should also be included when you type the address in the browser.
So, in order work, the address you type should look like this: http://myoscserver:8080/
I believe I can write an AHK script to:
1 — Ping the computer running the server;
2 — Extract the IP address and store it in a variable;
3 — Replace the "192.168.43.2 myoscserver" line in the "hosts" file with this one:
"%new_IP% myoscserver"
@Greenman, your idea turns out to be part of the solution. Thank you!
O-S-C announces itself on the network using bonjour/zeroconf, what would be ideal is a bonjour/zeroconf app on the client side that detects o-s-c and browses to it. The thing is I don't develop native apps for mobile operating system, but it's something worth looking at.
Automatically change the IP address of the osc_server domain name in the hosts file AHK script.
Thank you, @Greenman (for the hosts idea) and @GeneralMidi (for the AHK OSC integration DLL link - posted here)
Now, if I connect my O-S-C server device and my client device to another router, all I have to do is run the script, and my bookmark (http://osc_server:8080) will be automatically linked to the correct IP.
Hurray!
Autohotkey code
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
!z:: Reload
!a::
; Variables
serverComputerName := "aaa" ;
domainName := "osc_server"
; 1) new_ip variale
; (store the IP of the computer named "aaa" into the "%new_ip%" variable)
; Credit goes to mikeyww (https://www.autohotkey.com/boards/memberlist.php?mode=viewprofile&u=59977)
Clipboard =
RunWait, %ComSpec% /c ping -n 1 %serverComputerName% | clip,, Hide
ClipWait, 0
If ErrorLevel {
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Return
} Else RegExMatch(Clipboard, "Reply from \K[\d.]+", new_ip)
; 2) LineNum variable
; (store to a variable the line number in which "osc_server" is contained; this helps in finding which line should be replaced in the next step)
strToFind := %domainName%
Loop, Read, c:\Windows\System32\drivers\etc\hosts
{
IfInString, A_LoopReadLine, %strToFind%
{
LineNum := A_Index
}
}
; 3) Replace the line containing "osc_server"
newLineContent = %new_ip% %domainName%
Loop, Read, c:\Windows\System32\drivers\etc\hosts
{
If A_Index = %LineNum%
FileAppend, %newLineContent%`n, %A_Temp%\Temp.txt
Else
FileAppend, %A_LoopReadLine%`n, %A_Temp%\Temp.txt
}
FileMove, %A_Temp%\Temp.txt, c:\Windows\System32\drivers\etc\hosts, 1
Hey! I would love to try this for myself but I'm having trouble getting this running. I saved your code in a new AutoHotKey script, downloaded OSC2AHK.dll and put in same folder as script and can't get it to work. Any help would be much appreciated as I would love to not worry about inputing a new IP address everytime I open up OSC on my ipad
Hi, @mrkapow !
The script must be run from the client device (in your case, from an iPAD). Now, I don't know much about iPads, but I'm pretty sure you can't run AHK on such a device. Maybe find another scripting solution?
I think you can start here:
Then find a scripting app or find out maybe you can do this in bash (hope iPad has bash...)