Hearing a noise,he woke up.
here hearing is said to be a participle. But how it acts as an adjective? Again,
By working hard, you can prosper.
Is working a participle or gerund?
Participles modify other words or parts of a sentence. They can appear where adjectives or adverbs would work.
Looking at him closely I saw that Jim was not well (adverb).
I took the dog jumping on me outside for a while (adjective).
Gerunds do not modify anything. They can appear where nouns or pronouns would work.
I struggled with Jim.
I struggled with talking to Jim.
By working hard, you can prosper
Prepositions take objects, objects are noun or noun-like, therefore "working hard" couldn't be anything but a gerund.
Of course it's possible that a preposition's object is modified by a participial phrase.
I left with those mean kids throwing things at me.
I truly hate the vocabulary used with participles. In English, participles are formed from verbs. Each verb has a progressive participle and a perfect participle. The principle purpose of participles is in verbal phrases for the purpose of indicating the aspect of the lexically significant verb.
However, participles can also be used as adjectives or as nouns. When they are used as nouns, they are called gerunds.
The children were running the business on their own by then.
The participle "running" is used here as the lexically significant part of a verbal phrase that is in the past progressive tense.
They bought a thriving business.
The participle "thriving" is used here as an adjective.
Swimming is good though tedious exercise.
The participle "swimming" is used here as a noun and so is called a gerund.
It would be easier for students if we said that a "gerund" is one way that progressive pariciples are used in English. There is no difference in form between a participle and a gerund.