somehow; without knowing/thinking
Expresses doing something without a clear purpose or awareness, often as a background action.
This pattern describes an action done absent-mindedly, without a specific intention or conscious thought. It often sets a scene where the main action happens while the person is doing something else unintentionally. For example, you might be gazing out the window not really looking at anything, and then you notice something. It carries a nuance of 'not particularly meaning to do it, but it happened.'
ともなく and ともなしに are essentially interchangeable, but ともなしに is more adverbial and often used to connect to the next clause. In modern usage, ともなく is more common in written narrative, while ともなしに can sound slightly more formal. Both are N1-level and mostly appear in written or formal spoken contexts, not in casual conversation.
When using this pattern, the verb before it is in dictionary form, and the action described is typically not the main point of the sentence but rather a backdrop. It is not used for intentional actions.