FileReadLine issue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
stcy00
Posts: 7
Joined: 25 Nov 2020, 03:44

FileReadLine issue

25 Nov 2020, 04:02

Hi, can help me with this. in file, i have a list of contact i want to send msg to. but its not working.

Code: Select all

F1::
    FileReadLine, line, c:\users\sunny\desktop\wsend.txt, %A_Index%
    RUN, chrome.exe https://api.whatsapp.com/send?phone=601%line%&text=  
return
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: FileReadLine issue

25 Nov 2020, 04:52

Code: Select all


Loop, Read, c:\users\sunny\desktop\wsend.txt
    Run,% "chrome.exe https://api.whatsapp.com/send?phone=601" . A_LoopReadLine . "&text="
Return

Untested.
Last edited by BoBo on 25 Nov 2020, 11:27, edited 2 times in total.
Reason: Quotes changed as advised by Gregster. Thx 4 pointing this out! :o) (root cause: iOS tablet auto-replace)
gregster
Posts: 9098
Joined: 30 Sep 2013, 06:48

Re: FileReadLine issue

25 Nov 2020, 10:37

The quotation marks look strange and non-standard.
Most likely, it should be " instead of and . Edit: Now fixed by BoBo :thumbup:
stcy00
Posts: 7
Joined: 25 Nov 2020, 03:44

Re: FileReadLine issue

26 Nov 2020, 00:09

BoBo wrote:
25 Nov 2020, 04:52

Code: Select all


Loop, Read, c:\users\sunny\desktop\wsend.txt
    Run,% "chrome.exe https://api.whatsapp.com/send?phone=601"  . A_LoopReadLine . "&text="
Return

Untested.
it works but it keep looping. and pop out.
i need to send msg to 1st line, then only trigger 2nd line.
Last edited by stcy00 on 26 Nov 2020, 00:14, edited 1 time in total.
gregster
Posts: 9098
Joined: 30 Sep 2013, 06:48

Re: FileReadLine issue

26 Nov 2020, 00:14

The same general syntax should also work with your variable named line that you used above.
The loop was just an example.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: FileReadLine issue

26 Nov 2020, 03:22

The main reason why I’ve changed to a Loop from FileReadLine is that the OP has used A_Index what if used intentionally is only available within a Loop, AFAIK.
The built-in variable A_Index contains the number of the current loop iteration. It contains 1 the first time the loop's body is executed. For the second time, it contains 2; and so on. If an inner loop is enclosed by an outer loop, the inner loop takes precedence. A_Index works inside all types of loops, including file-loops and registry-loops; but A_Index contains 0 outside of a loop.
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: FileReadLine issue

26 Nov 2020, 03:31

use RunWait instead of Run
Hubert
User avatar
mikeyww
Posts: 27264
Joined: 09 Sep 2014, 18:38

Re: FileReadLine issue

26 Nov 2020, 07:35

In your original script, A_Index is null because a loop is not being used. The following will work. I removed &text=, but you can add it if needed.

Code: Select all

lineNum := 0, addresses := A_Desktop "\wsend.txt"

F1::
FileReadLine, line, %addresses%, % ++lineNum
If ErrorLevel {
 MsgBox, 48, Done, There are no more addresses.
 lineNum := 0
} Else Run, chrome.exe https://api.whatsapp.com/send?phone=601%line%
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 173 guests