Sign in to follow this  
Followers 0
Azu

Some problems reading/writing from ini

23 posts in this topic

#include <GUIConstants.au3>
#include <string.au3>
$inipath="C:/Program Files/AutoLogin.ini"
$readini=IniReadSectionNames($inipath)
HotKeySet("{ESC}", "_Exit")
HotKeySet("{END}", "_Exit")
HotKeySet("!{F4}", "_Exit")
HotKeySet("^+1", "_Misc1")
HotKeySet("^+2", "_Misc2")
HotKeySet("^+3", "_Misc3")
HotKeySet("^+4", "_Misc4")
_Panel()
Func _Exit()
Exit
EndFunc
Func DAAutoLogin()
$DARunPath = IniRead($inipath, "DA", "Path", "")
If $DARunPath = "" Then
_Change()
Else
EndIf
Run($DARunPath)
WinWaitActive("Darkages")
Sleep(100)
WinWaitActive("Darkages")
Sleep(100)
Send("{ESC}")
$x = 0
$y = 0
$checksum = 1010249294
While $checksum <> PixelChecksum(528 + $x,451 + $y, 612 + $x,470 + $y)
Sleep(100)
WEnd
MouseClick("left", 168 + $x, 205 + $y, 2)
$checksum = PixelChecksum(505 + $x,386 + $y, 532 + $x,402 + $y)
While $checksum = PixelChecksum(505 + $x,386 + $y, 532 + $x,402 + $y)
Sleep(50)
WEnd
MouseClick("left", 232 + $x, 391 + $y, 1)
Sleep(100)
MouseClick("left", 108 + $x, 318 + $y, 1)
MouseClick("left", 302 + $x, 253 + $y, 1)
$DARunName = IniRead($inipath, "DA", "Name", "")
Send($DARunName)
Send("{Enter}")
$DARunPassword = IniRead($inipath, "DA", "Password", "")
ClipPut($DARunPassword)
Send($DARunPassword)
Send("{Enter}")
WinWaitClose("Darkages")
_Panel()
EndFunc
Func ROAutoLogin()
$RORunPath = IniRead($inipath, "RO", "Path", "")
If $RORunPath = "" Then
_Change()
Else
EndIf
Run($RORunPath)
WinWait ("Ragnarok")
Sleep (500)
WinWait ("Ragnarok")
Sleep (500)
$RORunName = IniRead($inipath, "RO", "Name", "")
Send($RORunName)
Send("{Tab}")
$RORunPassword = IniRead($inipath, "RO", "Password", "")
Send($RORunPassword)
Send("{Enter}")
for $x = 1 to 15
Sleep (100)
Send ("{ENTER}")
Next
WinWaitClose("Ragnarok")
_Panel()
EndFunc
Func SCAutoLogin()
$SCRunPath = IniRead($inipath, "SC", "Path", "")
If $SCRunPath = "" Then
_Change()
Else
EndIf
Run($SCRunPath)
WinWaitActive("Brood War")
Sleep(100)
WinWaitActive("Brood War")
Sleep(100)
$checksum = PixelChecksum(194,264,198,268)
While $checksum = PixelChecksum(194,264,198,268)
Sleep(10)
WEnd
$checksum = PixelChecksum(364,300,368,304)
MouseClick("primary", 196, 266, 1)
While $checksum = PixelChecksum(364,300,368,304)
Sleep(10)
WEnd
$checksum = PixelChecksum(347,253,347,253)
MouseClick("primary", 366, 302, 1)
While $checksum = PixelChecksum(347,253,347,253)
Sleep(10)
WEnd
$checksum = PixelChecksum(396,234,396,234)
MouseClick("primary", 520, 394, 30)
While $checksum = PixelChecksum(396,234,396,234)
Sleep(10)
WEnd
Sleep(1500)
$checksum = PixelChecksum(408,272,408,272)
While $checksum = PixelChecksum(408,272,408,272)
Sleep(10)
WEnd
for $x = 1 to 7
Sleep (10)
Send ("{Tab}")
Next
$SCRunName = IniRead($inipath, "SC", "Name", "")
Send($SCRunName)
Send("{TAB}")
$SCRunPassword = IniRead($inipath, "SC", "Password", "")
Send($SCRunPassword)
Send("{Enter}")
WinWaitClose("Brood War")
_Panel()
EndFunc
Func WoWAutoLogin()
$WoWRunPath = IniRead($inipath, "WoW", "Path", "")
If $WoWRunPath = "" Then
_Change()
Else
EndIf
Run($WoWRunPath)
WinWait ("World of Warcraft")
Sleep (400)
WinWait ("World of Warcraft")
Sleep (400)
$WoWRunName = IniRead($inipath, "WoW", "Name", "")
Send($WoWRunName)
Send("{Tab}")
$WoWRunPassword = IniRead($inipath, "WoW", "Password", "")
Send ($WoWRunPassword)
Send("{Enter}")
Sleep (8500)
Send ("{ENTER}")
WinWaitClose("World of Warcraft")
_Panel()
EndFunc
Func _Panel()
Dim $ScanMsgBox = _MainPanel(4, '-=Auto Login Control Panel=-', 'Welcome to Auto Login!')
If $ScanMsgBox = 6 Then
DAAutoLogin()
ElseIf $ScanMsgBox = 7 Then
ROAutoLogin()
ElseIf $ScanMsgBox = 8 Then
WoWAutoLogin()
ElseIf $ScanMsgBox = 9 Then
SCAutoLogin()
ElseIf $ScanMsgBox = 10 Then
_Change()
EndIf
EndFunc
Func _Change()
GuiCreate("Auto Login Editer", 368, 66)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
GuiCtrlCreateTab(1, 0, 368, 23)
GuiCtrlCreateTabItem("DA")
GuiCtrlCreateLabel("Username:", 0, 25)
$DARunName=IniRead($inipath, "DA", "Name", "")
$DAName=GuiCtrlCreateInput($DARunName, 51, 23, 130, 20)
GuiCtrlCreateLabel("Password:", 188, 25)
$DARunPassword=IniRead($inipath, "DA", "Password", "")
$DAPassword=GuiCtrlCreateInput($DARunPassword, 238, 23, 130, 20)
GuiCtrlCreateLabel("Path:", 0, 50)
$DARunPath=IniRead($inipath, "DA", "Path", "")
$DA=GuiCtrlCreateInput($DARunPath, 26, 48, 280, 20)
$BrowseDA=GuiCtrlCreateButton("Browse", 310, 48, 59, 20)
GuiCtrlCreateTabItem("RO")
GuiCtrlCreateLabel("Username:", 0, 25)
$RORunName=IniRead($inipath, "RO", "Name", "")
$ROName=GuiCtrlCreateInput($RORunName, 51, 23, 130, 20)
GuiCtrlCreateLabel("Password:", 188, 25)
$RORunPassword=IniRead($inipath, "RO", "Password", "")
$ROPassword=GuiCtrlCreateInput($RORunPassword, 238, 23, 130, 20)
GuiCtrlCreateLabel("Path:", 0, 50)
$RORunPath=IniRead($inipath, "RO", "Path", "")
$RO=GuiCtrlCreateInput($RORunPath, 26, 48, 280, 20)
$BrowseRO=GuiCtrlCreateButton("Browse", 310, 48, 59, 20)
GuiCtrlCreateTabItem("WoW")
GuiCtrlCreateLabel("Username:", 0, 25)
$WoWRunName=IniRead($inipath, "WoW", "Name", "")
$WoWName=GuiCtrlCreateInput($WoWRunName, 51, 23, 130, 20)
GuiCtrlCreateLabel("Password:", 188, 25)
$WoWRunPassword=IniRead($inipath, "WoW", "Password", "")
$WoWPassword=GuiCtrlCreateInput($WoWRunPassword, 238, 23, 130, 20)
GuiCtrlCreateLabel("Path:", 0, 50)
$WoWRunPath=IniRead($inipath, "WoW", "Path", "")
$WoW=GuiCtrlCreateInput($WoWRunPath, 26, 48, 280, 20)
$BrowseWoW=GuiCtrlCreateButton("Browse", 310, 48, 59, 20)
GuiCtrlCreateTabItem("SC")
GuiCtrlCreateLabel("Username:", 0, 25)
$SCRunName=IniRead($inipath, "SC", "Name", "")
$SCName=GuiCtrlCreateInput($SCRunName, 51, 23, 130, 20)
GuiCtrlCreateLabel("Password:", 188, 25)
$SCRunPassword=IniRead($inipath, "SC", "Password", "")
$SCPassword=GuiCtrlCreateInput($SCRunPassword, 238, 23, 130, 20)
GuiCtrlCreateLabel("Path:", 0, 50)
$SCRunPath=IniRead($inipath, "SC", "Path", "")
$SC=GuiCtrlCreateInput($SCRunPath, 26, 48, 280, 20)
$BrowseSC=GuiCtrlCreateButton("Browse", 310, 48, 59, 20)
GuiCtrlCreateTabItem("Misc")
$Misc01=GuiCtrlCreateButton("1", 0, 25, 10, 18)
$Misc1=IniRead($inipath, "Misc", "1", "")
$Misc01=GuiCtrlCreateInput($Misc1, 10, 23, 155, 20)
$Misc02=GuiCtrlCreateButton("2", 182, 25, 10, 18)
$Misc2=IniRead($inipath, "Misc", "2", "")
$Misc02=GuiCtrlCreateInput($Misc2, 192, 23, 155, 20)
$Misc03=GuiCtrlCreateButton("3", 0, 50, 10, 18)
$Misc3=IniRead($inipath, "Misc", "3", "")
$Misc03=GuiCtrlCreateInput($Misc3, 10, 48, 155, 20)
$Misc04=GuiCtrlCreateButton("4", 182, 50, 10, 18)
$Misc4=IniRead($inipath, "Misc", "4", "")
$Misc04=GuiCtrlCreateInput($Misc4, 192, 48, 155, 20)
GuiCtrlCreateTabItem("Binds")
GuiCtrlCreateTabItem("")
$Apply=GuiCtrlCreateButton("Apply", 310, 0, 59, 20)
GuiSetState()
Do
$msg = GUIGetMsg()
Select
Case $msg= $BrowseDA
$DA = FileOpenDialog("Browse to DA", "", "Dark Ages (*.exe)","", "DA.exe")
IniWrite($inipath, "DA", "Path", $DA)
Case $msg= $BrowseRO
$RO = FileOpenDialog("Browse to RO", "", "Ragnarok Online (*.exe)","", "RO.exe")
IniWrite($inipath, "RO", "Path", $RO)
Case $msg= $BrowseWoW
$WoW = FileOpenDialog("Browse to WoW", "", "World of Warcraft (*.exe)","", "WoW.exe")
IniWrite($inipath, "WoW", "Path", $WoW)
Case $msg= $BrowseSC
$SC = FileOpenDialog("Browse to SC", "", "Star Craft (*.exe)","", "SC.exe")
IniWrite($inipath, "SC", "Path", $SC)
Case $msg= $Misc01
$Misc1 = FileOpenDialog("Browse to misc file 1", "", "(*.exe)","", "")
IniWrite($inipath, "Misc", "1", $Misc01)
Case $msg= $Misc02
$Misc2 = FileOpenDialog("Browse to misc file 2", "", "(*.exe)","", "")
IniWrite($inipath, "Misc", "2", $Misc02)
Case $msg= $Misc03
$Misc3 = FileOpenDialog("Browse to misc file 3", "", "(*.exe)","", "")
IniWrite($inipath, "Misc", "3", $Misc03)
Case $msg= $Misc04
$Misc4 = FileOpenDialog("Browse to misc file 4", "", "(*.exe)","", "")
IniWrite($inipath, "Misc", "4", $Misc04)
Case $msg= $Apply
IniWrite($inipath, "DA", "Path", GUICtrlRead ($DA))
IniWrite($inipath, "DA", "Password", GUICtrlRead ($DAPassword))
IniWrite($inipath, "DA", "Name", GUICtrlRead ($DAName))
IniWrite($inipath, "RO", "Path", GUICtrlRead ($RO))
IniWrite($inipath, "RO", "Password", GUICtrlRead ($ROPassword))
IniWrite($inipath, "RO", "Name", GUICtrlRead ($ROName))
IniWrite($inipath, "WoW", "Path", GUICtrlRead ($WoW))
IniWrite($inipath, "WoW", "Password", GUICtrlRead ($WoWPassword))
IniWrite($inipath, "WoW", "Name", GUICtrlRead ($WoWName))
IniWrite($inipath, "SC", "Path", GUICtrlRead ($SC))
IniWrite($inipath, "SC", "Password", GUICtrlRead ($SCPassword))
IniWrite($inipath, "SC", "Name", GUICtrlRead ($SCName))
IniWrite($inipath, "Misc", "1", GUICtrlRead ($Misc1))
IniWrite($inipath, "Misc", "2", GUICtrlRead ($Misc2))
IniWrite($inipath, "Misc", "3", GUICtrlRead ($Misc3))
IniWrite($inipath, "Misc", "4", GUICtrlRead ($Misc4))
EndSelect
Until $msg= $GUI_EVENT_CLOSE
GuiDelete()
_Panel()
EndFunc
Func _MainPanel($mb_Icon, $mb_Title, $mb_Text, $mb_Time = '')
Local $StrnLenText = MsgLongestString($mb_Text)
Local $NumberOfLines = (UBound(StringSplit($mb_Text, @CRLF)) - 1) * 5
Local $MsgValue = 0
Local $Timer = ''
$iMsgBox = GUICreate($mb_Title, $StrnLenText + 190, 100 + $NumberOfLines, -1, -1, 0x00400000, 0x00000008)
GUICtrlCreateLabel($mb_Text, 60, 10)
GUICtrlCreateIcon(@SystemDir & "\User32.dll", $mb_Icon, 10, 10, 35, 35)
$DA = GUICtrlCreateButton("DA", 0 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen("DA"), 25)
$RO = GUICtrlCreateButton("RO", 65 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen("RO"), 25)
$WoW = GUICtrlCreateButton("WoW", 130 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen("WoW"), 25)
$SC = GUICtrlCreateButton("SC", 69 + ($StrnLenText / 2), 25 + $NumberOfLines, 50 + StringLen("SC"), 17)
$Info = GUICtrlCreateButton("Change", 134 + ($StrnLenText / 2), 25 + $NumberOfLines, 50 + StringLen("_Change"), 17)
GUISetState()
If $mb_Time <> '' Then $Timer = TimerInit()
While 1
$imsg = GUIGetMsg()
Select
Case $imsg = $DA
$MsgValue = 6
ExitLoop
Case $imsg = $RO
$MsgValue = 7
ExitLoop
Case $imsg = $WoW
$MsgValue = 8
ExitLoop
Case $imsg = $SC
$MsgValue = 9
ExitLoop
Case $imsg = $Info
$MsgValue = 10
ExitLoop
Case $mb_Time <> ''
If TimerDiff($Timer) / 1000 >= $mb_Time Then ExitLoop
EndSelect
WEnd
GUIDelete($iMsgBox)
Return $MsgValue
EndFunc
Func MsgLongestString($sText)
Local $sSplit = StringSplit($sText, @CRLF)
Local $Times = ''
If Not @error Then
ArraySortByLen($sSplit)
If StringLen($sSplit[1]) <= 100 Then $Times = 2.25
If StringLen($sSplit[1]) >= 101 And StringLen($sSplit[1]) <= 150 Then $Times = 2.5
If StringLen($sSplit[1]) >= 151 And StringLen($sSplit[1]) <= 201 Then $Times = 3
If StringLen($sSplit[1]) >= 202 Then $Times = 3.25
Return Round(StringLen($sSplit[1])*$Times)
Else
If StringLen($sText) <= 100 Then $Times = 2.25
If StringLen($sText) >= 101 And StringLen($sText) <= 150 Then $Times = 2.5
If StringLen($sText) >= 151 And StringLen($sText) <= 201 Then $Times = 3
If StringLen($sText) >= 202 Then $Times = 3.25
Return Round(StringLen($sText)*$Times)
EndIf
EndFunc
Func ArraySortByLen(ByRef $nArray, $Start = 1)
For $i = $Start To UBound($nArray) - 2
Local $SE = $i
For $x = $i To UBound($nArray) - 1
If StringLen($nArray[$SE]) < StringLen($nArray[$x]) Then $SE = $x
Next
Local $HLD = $nArray[$i]
$nArray[$i] = $nArray[$SE]
$nArray[$SE] = $HLD
Next
EndFunc
Func _Misc1()
$Misc1 = IniRead($inipath, "Misc", "1", "")
Run($Misc1)
EndFunc
Func _Misc2()
$Misc2 = IniRead($inipath, "Misc", "2", "")
Run($Misc2)
EndFunc
Func _Misc3()
$Misc3 = IniRead($inipath, "Misc", "3", "")
Run($Misc3)
EndFunc
Func _Misc4()
$Misc4 = IniRead($inipath, "Misc", "4", "")
Run($Misc4)
EndFunc

The reading and writing to the ini is just generally buggy and I'm not sure why.. please tell me how to fix it..

Share this post


Link to post
Share on other sites



I don't see what is wrong with it? can u explain a little more?

Share this post


Link to post
Share on other sites

It has some problems reading/writing the ini I don't know why :o

For example if I put in C:/Starcrafts/SC.exe

It might put in 0 instead..

Share this post


Link to post
Share on other sites

I didn't have any issues. So, I turn to the standard question: what version of AutoIt are you using?

Share this post


Link to post
Share on other sites

I just got the beta from yesterday.. so I'm guesing I have the newest..

Share this post


Link to post
Share on other sites

Are you sure you're running it with the beta? Do you have Scite so you can verify?

Share this post


Link to post
Share on other sites

I tried scite before.. didn't like it.. uninstalled it within 30 seconds =/

Notepad>All

Share this post


Link to post
Share on other sites

I've gotten into a "discussion" about this before, so I won't be doing it again. If you really think Notepad is better than anything else out there, that's your own deal. You're just making it harder for yourself.

Share this post


Link to post
Share on other sites

Oh and I just redownlaoded/reinstalled the beta again so I'm sure I have the latest version.. got it about 40 seconds ago >.>

The version is " autoit-v3.1.1.110-beta-Setup.exe 21-Feb-2006 12:42 2.2M "

Share this post


Link to post
Share on other sites

Actually there is one thing better then notepad; gedit

But that is a Linux text editer and I run Windows sooooooooo notepad is the next best thing

Anyways wtf?

Share this post


Link to post
Share on other sites

Look there's a problem with my script okay can you just tell me how to fix it this has nothing to do with scite or w/e

Share this post


Link to post
Share on other sites

1. Don't double (or triple) post.

2. There's nothing wrong with your script as far as your details and my testing can tell. Either explain more, or figure it out yourself. I did what I could with the information I have.

Share this post


Link to post
Share on other sites

Okay

Select my script

Press ctrl c

Right click on your desktop

Make a text document

Open it

Press ctrl v

Press alt f4

Click save

Right click on the file and rename it to AutoLogin.au3

Click change

Use the GUI and fill out the settings and stuff

Click apply to save changes

Some of the stuff will get messed up/corrupted and will save as 0 in the ini file, which is located at C:/Program Files/AutoLogin.ini

Some stuff in it gets set to =0 such as paths to files

This isn't suppost happen

How do I fix it..

Please help :o

Share this post


Link to post
Share on other sites

Ha!!, I see my _MsgBox comming in handy!!

Whether you like or dislike the Editor, make it easy on yourself, and only use it for Debugging then. Download it, if your running into errors, open it up in SciTe. I only say this because it has a lot of functionality with other options, that you don't get by using any other editor thanks to Jdeb.

With that said, if you are sure your running Beta... let's make sure for sure (wow).

Make a test.au3 and put in

MsgBox(0, 'Test', 'AutoIt Version Running = ' & @AutoItVersion)
Might be surprised at what you find, and I think that was the point that green was making.

It's not anyones 'Job' to figure out your problem, we do it because we like to the sadist that we are.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

@Anyone: Ok, I was about to get pissed off, but I decided that the guy's too noobish for me to get mad over.

@Azu: I went ahead and did all your work for you, but because you really suck at using detail in your explanations, and refusing to try anything suggested, I'm not going to tell you now. I may later....

Share this post


Link to post
Share on other sites

; Replace these
$SC = FileOpenDialog("Browse to SC", "", "Star Craft (*.exe)","", "SC.exe")

; With this
GUICtrlSetData($SC, FileOpenDialog("Browse to SC", "", "Star Craft (*.exe)","", "SC.exe"))

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I knew it! It had nothing to do with my version! Thanks Jotun.

Problem solved! Please lock this topic so greenmachine doesn't spam it.. thanks..

Edited by Azu

Share this post


Link to post
Share on other sites

I knew it! It had nothing to do with my version! Thanks Jotun. I'm glad SOMEONE on these forums isn't an asshole. :o

Problem solved, thanks again Jotun.

And as far as your 'version', I merely suggested a few options (never had looked at your 'long' code), on why you 'might' want to use SciTe (and when you might want to use it). I'm sure I was right that it was showing you 3.1.1 because you never responded, and it only installed itself in the Beta folder, SciTe would show you how to use Beta.

The ***hole part... well, you need to re-read your post, and look at who the ***hole started out being. Maybe even read the forum and see that some try to help even when the questions/scripts don't make any sense, so they are 'common questions' asked the solve 'most' problems (maybe not yours)... and maybe respect that a bit before you snap off with an un-educated response.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

And as far as your 'version', I merely suggested a few options (never had looked at your 'long' code), on why you 'might' want to use SciTe (and when you might want to use it). I'm sure I was right that it was showing you 3.1.1 because you never responded, and it only installed itself in the Beta folder, SciTe would show you how to use Beta.

The ***hole part... well, you need to re-read your post, and look at who the ***hole started out being. Maybe even read the forum and see that some try to help even when the questions/scripts don't make any sense, so they are 'common questions' asked the solve 'most' problems (maybe not yours)... and maybe respect that a bit before you snap off with an un-educated response.

I'm pretty sure he's talking about me, but it doesn't matter. He's not worth my time.

Share this post


Link to post
Share on other sites

lol. I would'nt be gettin mad at greenmachine, he is like aalways helping people out, always giving them the answer, their is gonna be a time where u need his help and no one esle will no the answer(lmao, maybe not bu o well) and he wont want to help u. same thing with everyone else...

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0