Sign in to follow this  
Followers 0
NoobieAutoitUser

Looking for guidance , with 'ini' and variables:)

3 posts in this topic

#1 ·  Posted (edited)

Hi, thanks for looking at my post.

I have a script that does 'auto answering' for Pidgin (chat client, using XMPP). I use OTR (off the record - encrypts conversations) with Pidgin. Their is a pause when someones connects to you (some times it takes seconds, other minutes), as the OTR kicks in. I made a script that works with it and is so far is flawless. I am using an 'ini' to read from to get the info that is needed for each user (~10 users).

I understand how to read the different sections on the ini. How do I tell the script what section to use based on who logged in?

Example = !Mycell logs in and uses Buddy1 in the ini.

Example = Webpage logs in and uses Buddy2 in the ini.

How do I tell the script what part to use? I have one main script. Do I need to make a script for each ini?

Thanks for any help. I feel so close to being done with this, and this part has me stumped.

 

 

 

[Buddy1]
Wname=!My-Cell-Q1
ClipWrite=!My-Cell-Q1ClipWrite.txt
TextToRead=!My-Cell-Q1-Read-Text.txt
Ran=Yes

[Buddy2]
Wname=Webpage
ClipWrite=Webpage.txt
TextToRead=Webpage-Read-Text.txt
; Maine script
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

; sleep(5000000000000000000000000)



$sIniFile = 'ini-begin.ini'
; S- Read the INI file for the values.
Local $sReadIni0 = IniRead($sIniFile, "Buddy1", "Wname", "Default Value")
Local $sReadIni1 = IniRead($sIniFile, "Buddy1", "ClipWrite", "Default Value")
Local $sReadIni2 = IniRead($sIniFile, "Buddy1", "TextToRead", "Default Value")




; S-Delete File for 'clip write' , so file is blank on first use.
; FileDelete - Do not use quotes, with viariables. Use quotes with full name.

FileDelete($sReadIni1)
; sleep(500000000000000000000000)
; E-Delete File for 'clip write' , so file is blank on first use.

; S- Read the INI file for the values.
; Display the value returned by IniRead. (Works)
; MsgBox($MB_SYSTEMMODAL, "", "The value of 'Buddy1' in the section labelled '$sReadIni0 ' is: " & $sReadIni0)
; MsgBox($MB_SYSTEMMODAL, "", "The value of 'Buddy1' in the section labelled 'ClpWrite' is: " & $sReadIni1)
; sleep(5000000000000)
; MsgBox($MB_SYSTEMMODAL, "", "The value of 'Buddy1' in the section labelled 'TextToRead' is: " & $sReadIni2)
; Write the values to an INI file (Works).
; IniWrite($sIniFile, "Buddy1", "Ran", "Yes")
; E- Read the INI file for the values.



; S - Wait for message window to appear.
; The 10 is in seconds (not milliseconds)
; WinWait($sReadIni0 , "", 10)
If WinExists($sReadIni0 ) Then
  ;MsgBox(0, "", "Window exists")
Else
  ;MsgBox(0, "", "Window does not exist")
  Exit
EndIf
; E - Wait for message window to appear.

$counter = 0
While $counter <= 5
    Sleep(10)
    ;MsgBox(0, "Value of $counter is:", $counter)
    winactivate($sReadIni0)
    Send("^l")
winactivate($sReadIni0)
Sleep(1500)
Send("!c")
winactivate($sReadIni0)
Sleep(1500)
Send("{RIGHT}")
winactivate($sReadIni0)
Sleep(1500)
Send("{RIGHT}")
winactivate($sReadIni0)
Sleep(1500)
send("{ENTER}")
winactivate($sReadIni0)
Sleep(1500)
Send("{F6}")
winactivate($sReadIni0)
Sleep(1500)
Send("^a")
winactivate($sReadIni0)
Sleep(1500)
Send("^c")
winactivate($sReadIni0)
Sleep(1500)
Send("^l")
winactivate($sReadIni0)
Sleep(1500)

; S - Write Clipboard to a file
; the & '@CRLF' adds a line break afer paste form clipboard
filewrite($sReadIni1,clipget() & @CRLF)
; E - Send keys to pidgin to copy text and send to ClipWrite.
; S - Look for matching text in file.)
Sleep(1500)
$textToFind = ("successfully refreshed")
$AllText = FileRead($sReadIni1)
If StringInStr($AllText ,$textToFind)  <> 0 then
;it's there
;MsgBox($MB_OK, "Crap", "Yes")
exitloop
else
;it isn't there
;MsgBox($MB_OK, "Crap", "No")
Sleep(100)
endif
; E - Look for matching text in file.

    $counter = $counter + 1
WEnd

For $i = 1 to _FileCountLines($sReadIni2)
$line = FileReadLine($sReadIni2, $i)
;Send($line & @CRLF)
Send($line)
Send("{ENTER}")
Sleep(5000)
Next
; FileClose($file)
; end read form text fiel and send to pidgin

 

Edited by NoobieAutoitUser
Spellcheck was off

Share this post


Link to post
Share on other sites



#2 ·  Posted

39 minutes ago, NoobieAutoitUser said:

How do I tell the script what part to use? I have one main script. Do I need to make a script for each ini?

I have only looked at your script quickly, but if you are talking about multiple users and some doing conversations simultaneously, then it would indeed be better to have a separate script monitoring each person, especially as AutoIt is not multi-threaded. Perhaps an even better way, is for each person to have their own script on their PC, and they upload to a shared file or similar.

At least, that's how I would deal with it ... but another boffin here, much smarter than me might have an alternate option or method.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#3 ·  Posted

Do you really need to name the ini sections Buddy1, Buddy2 etc ?
It would be much easier to do it like this :

[!My-Cell-Q1]
ClipWrite=!My-Cell-Q1ClipWrite.txt
TextToRead=!My-Cell-Q1-Read-Text.txt
Ran=Yes

[Webpage]
ClipWrite=Webpage.txt
TextToRead=Webpage-Read-Text.txt

and once you get the name of the logged user, just look into the corresponding section
You might also read the ini to a 2D array when the script starts, and deal with this array while the script is running

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  
Followers 0