1. SHAMEEM KAKKAD
  2. PowerBuilder
  3. Thursday, 21 July 2022 00:44 AM UTC

HI,

I need to send a file through whatsapp. I used below method. but a small doubt.

int li_connect
ole_wsh = Create OleObject
li_connect = ole_wsh.ConnectToNewObject("WScript.Shell") //

ole_wsh.Run(whatsapp exe path here )

ole_wsh.appActivate("Whatsapp")
sleep (2)
ole_wsh.SendKeys("+{TAB}")
ole_wsh.SendKeys("{ENTER}")
ole_wsh.SendKeys("{DOWN}")
ole_wsh.SendKeys("{DOWN}")
ole_wsh.SendKeys("{DOWN}")
ole_wsh.SendKeys("{DOWN}")
ole_wsh.SendKeys("{ENTER}")  // now it is reached file attachment dialogbox.

In this box I need to paste my file in the file name area without use manual selection.

Have any chance ?.

 

René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 05:17 AM UTC
  2. PowerBuilder
  3. # 1

How about using SendKeys function to send CTRL+V to paste the filename from clipboard? Of cause you have to put it to clipboard first.

Or you could try to "enter" the filename key by key by sending each character.

Comment
  1. René Ullrich
  2. Thursday, 21 July 2022 06:19 AM UTC
I think PBs sleep function should be ok.

Sendkey(filename) could also work

Maybe you have to wait (sleep) a second after each Sendkey? If this is to long you may try a small loop that evaluets cpu() function. Or use the timing objects - it allows to specify fractions of seconds.
  1. Helpful
  1. SHAMEEM KAKKAD
  2. Thursday, 21 July 2022 06:37 AM UTC
I think PBs sleep function should be ok. = Sleep function totally sleeping the PB application.

Sendkey(filename) could also work = I think will work the ole object sleep method.

Maybe you have to wait (sleep) a second after each Sendkey? = Yes i did. no use

If this is to long you may try a small loop that evaluets cpu() function. = I give a loop 10 million nos.. cpu is consuming it's time. but no use



  1. Helpful
  1. René Ullrich
  2. Thursday, 21 July 2022 07:40 AM UTC
I can't try it with WhatsApp. But this works for me with Noteoad:

ole_wsh.Run("notepad.exe")

Sleep(1)

ole_wsh.SendKeys("^o") // CTRL+O (File->Open)

ole_wsh.SendKeys("test.txt") // file must exists

ole_wsh.SendKeys("{ENTER}")
  1. Helpful
There are no comments made yet.
SHAMEEM KAKKAD Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 01:50 AM UTC
  2. PowerBuilder
  3. # 2

Hi Sir,

I am using Appeon 2021.

Rest API need Payment. This case we can use without any payment.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 01:42 AM UTC
  2. PowerBuilder
  3. # 3

Hi, Shameem -

After doing a quick web search, it appears that WhatsApp has a REST API interface. Have you considered using it? You did not state what version of PB you are using, but recent versions of PowerBuilder provide excellent capabilities to utilize REST interfaces.

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.