By default, the wallet will ask for the password after 90 seconds of inactivity. You can see this by loading the wallet, then running this command:
Look for the entry for inactivity-lock-timeout.
You can increase the timeout to say 10 minutes like so:
set inactivity-lock-timeout 600
Or disable this functionality like so:
The file you linked is not a Monero library. At most, all it shows is a couple of examples of calling the RPC methods, for which is an easy task in any coding language. Just run the monero-wallet-rpc application and call its HTTP methods.
If you want/need to use a library that wraps that up further, for example because you don't know how to call a HTTP ...
Is there a way to transfer your monero in your own wallet to another subaddress you control?
Yes. Using the usual transfer or any of the sweep_... commands. E.g. transfer <address> <amount>. Though if the destination address is in the same wallet, there's really not much point in doing this.
What @scoobybejesus is hinting at is this: Accounts ...
It sounds like you're asking this question because you think that because XMR was sent to a subaddress that the XMR is sitting "in" that subaddress.
My understanding of subaddresses is that they exist solely for the purpose of classifying deposits when they arrive. They are not intended to act like separate wallets (or like separate bank accounts).