Jump to content
Sign in to follow this  
thrlride

Help with using an input file as a variable

Recommended Posts

thrlride

I've come up with this so far:

while 1
    $usercode = FileOpen('c:\Backup\invite.txt', 0)
Run(@ProgramFilesDir& '\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_invite?user_code=($usercode)')
WinWaitActive('[CLASS:MozillaUIWindowClass]')

$hFF = WinGetHandle('[CLASS:MozillaUIWindowClass]')
sleep(5000)
ControlSend($hFF, '', '', '^{F4}')
wend

It seems it is actually sending $usercode instead of the actual 9 digit number I have in my text file.

What am I doing wrong with this?

Share this post


Link to post
Share on other sites
DavidKarner

I've come up with this so far:

while 1
    $usercode = FileOpen('c:\Backup\invite.txt', 0)
Run(@ProgramFilesDir& '\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_invite?user_code=($usercode)')
WinWaitActive('[CLASS:MozillaUIWindowClass]')

$hFF = WinGetHandle('[CLASS:MozillaUIWindowClass]')
sleep(5000)
ControlSend($hFF, '', '', '^{F4}')
wend

It seems it is actually sending $usercode instead of the actual 9 digit number I have in my text file.

What am I doing wrong with this?

You need to build the string for the run command.

(@ProgramFilesDir& '\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...ser_code=(' & $usercode & ')')

Share this post


Link to post
Share on other sites
bogQ

It seems it is actually sending $usercode instead of the actual 9 digit number I have in my text file.

What am I doing wrong with this?

you dont have FileReadLine

and as DavidKarner pointed your using Run with $var in the wrong way

$file = FileOpen("c:\Backup\invite.txt", 0)
$usercode = FileReadLine($file,1)
FileClose($file)
while 1
    Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_invite?user_code=("&$usercode&")")
    WinWaitActive("[CLASS:MozillaUIWindowClass]")
    sleep(5000)
    ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}")
wend

dont have firefox to see if itl work ^_^

Edit: tested its working

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
thrlride

you dont have FileReadLine

and as DavidKarner pointed your using Run with $var in the wrong way

$file = FileOpen("c:\Backup\invite.txt", 0)
$usercode = FileReadLine($file,1)
FileClose($file)
while 1
    Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_invite?user_code=("&$usercode&")")
    WinWaitActive("[CLASS:MozillaUIWindowClass]")
    sleep(5000)
    ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}")
wend

dont have firefox to see if itl work ^_^

Edit: tested its working

Thanks!

I tried this and it seems to only be pulling the first line of my input file and keeps entering that. Any idea why?

Share this post


Link to post
Share on other sites
DavidKarner

Thanks!

I tried this and it seems to only be pulling the first line of my input file and keeps entering that. Any idea why?

Because that is exactly what it was coded to do. =)

If you want to read the entire file and process each line, then you need to change your loop logic. Look at the AutoIt help for FileReadLine. It gives pretty good examples, but basically it is something like...

$file = FileOpen("c:\Backup\invite.txt", 0)

while 1
    $usercode = FileReadLine($file)
    if @error = -1 then exitloop
    Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...er_code=("&$usercode&")")
    WinWaitActive("[CLASS:MozillaUIWindowClass]")
    sleep(5000)
    ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}")
wend

FileClose($file)

Share this post


Link to post
Share on other sites
thrlride

I'd like to add one more request. I did a lot of searching and I couldn't find the answer. I wish I knew how to use this better so I wouldn't have to keep asking for help. ^_^

set /a var=100000000
SET BROWSER=firefox.exe
:LOOP
START %BROWSER% -new-tab http://www.reefmonkey.com/network/send_invite?user_code=%var%
ping 127.0.0.1 -n 2 > nul 2>&1
set /a var+=1
goto LOOP

My batch file is above. What it's doing is sending this 9 digit code and then incrementing by one and then sending that. Can someone please help with converting this to run in autoit?

I greatly appreciate everyone's help!

Edited by thrlride

Share this post


Link to post
Share on other sites
DavidKarner

I'd like to add one more request. I did a lot of searching and I couldn't find the answer. I wish I knew how to use this better so I wouldn't have to keep asking for help. ^_^

set /a var=100000000
SET BROWSER=firefox.exe
:LOOP
START %BROWSER% -new-tab http://www.reefmonkey.com/network/send_invite?user_code=%var%
ping 127.0.0.1 -n 2 > nul 2>&1
set /a var+=1
goto LOOP

My batch file is above. What it's doing is sending this 9 digit code and then incrementing by one and then sending that. Can someone please help with converting this to run in autoit?

I greatly appreciate everyone's help!

Umm, so in your original post the invite.txt just contained a list of numbers incrementing by 1?

$Index = 100000000
While 1
    $usercode = FileReadLine($file)
    if @error = -1 then exitloop
    Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...er_code=("&$Index&")")
    WinWaitActive("[CLASS:MozillaUIWindowClass]")
    sleep(5000)
    ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}")
    $Index = $Index + 1
wend

Share this post


Link to post
Share on other sites
thrlride

Umm, so in your original post the invite.txt just contained a list of numbers incrementing by 1?

$Index = 100000000
While 1
    $usercode = FileReadLine($file)
    if @error = -1 then exitloop
    Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...er_code=("&$Index&")")
    WinWaitActive("[CLASS:MozillaUIWindowClass]")
    sleep(5000)
    ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}")
    $Index = $Index + 1
wend
My input file has a list of numbers not incrementing by one. I was trying to get two scripts running, one that would use the input file and one that would start at 100000000 and then increment by one. I'd like to thank you and others that helped because after testing them it appears I have two working scripts for this purpose and I appreciate it!

I don't know if this is even possible or not but as this thing runs since it's closing the new tabs by design I won't know which commands were successful or how far it even ran. Ideally I need a way to have autoit run the command in the script and prior to it sending the control+f4 I would like it to view page source and append that to a file. Is something like that even possible?

Share this post


Link to post
Share on other sites
thrlride

I was able to figure out how to log it using this so I know which number it went through:

$Time=@Year & ' : ' & @MON & ' : ' & @MDAY & ' : ' & @Hour & ' : ' & @MIN & ' : ' & @SEC
    Filewrite('C:\TEXT.txt',@CRLF & '[' & $time & '] ' & $Index & @CRLF)

The problem is that after 50 successful invites in 24 hours it stops accepting them and with this I won't know when that point was reached.

If it logged the HTML source info to a file, though the file would be huge I could tell at what point it failed and start it over from that point the following day.

Edited by thrlride

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×