Sign in to follow this  
Followers 0
SMOKE1990

AHK user looking to convert

29 posts in this topic

I made a post earlier about something that was against the rules and wanted to apologize for that maybe i was misunderstood, I created a simple gui and am looking to make some things work the wording to making things work. I know how to do ini read write on ahk but on this the () and "" bother me more for some reason. Also the fact that the

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

has to be in the script? When i remove it the script automatically closes. IM not sure where I need to write my script due to me being new to the while type loops. I am under the impression that while loops run no matter what continuously and don't affect the top to bottom running of the script?

I finally got the gui created and am able to load it

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Seths - Desktop v1.001", 281, 293, 206, 131)
$Window = GUICtrlCreateCombo("", 8, 8, 177, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$CBS_UPPERCASE))
$Save = GUICtrlCreateButton("Save", 216, 48, 57, 25)
$Name1 = GUICtrlCreateLabel("Car Select", 8, 32, 53, 17)
$CarSelect = GUICtrlCreateCombo("", 8, 48, 129, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "07 Stang|RSX|C6")
$Label1 = GUICtrlCreateLabel("2-Step", 152, 32, 35, 17)
$MaxxBoost = GUICtrlCreateInput("", 152, 48, 57, 21)
$Update = GUICtrlCreateButton("Update", 200, 8, 75, 25)
$Bracket = GUICtrlCreateGroup("Bracket", 8, 72, 129, 65)
$Maxx_Boost = GUICtrlCreateCheckbox("Maxx Boost", 16, 88, 97, 17)
$Label7 = GUICtrlCreateLabel("Dial-In", 16, 112, 34, 17)
$Dial_In = GUICtrlCreateInput("", 64, 112, 65, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$H2H = GUICtrlCreateGroup("H2H", 8, 136, 129, 89)
$Roll_Start = GUICtrlCreateCheckbox("Roll Start", 16, 176, 97, 17)
$Delayt = GUICtrlCreateLabel("Delay", 16, 200, 31, 17)
$Delay = GUICtrlCreateInput("", 64, 200, 65, 21)
$Brake_N_G0 = GUICtrlCreateCheckbox("Brake N Go", 16, 152, 97, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Gears = GUICtrlCreateGroup("Gears", 152, 72, 121, 153)
$Start_Shift = GUICtrlCreateCheckbox("Start Shift", 160, 88, 97, 17)
$Label2 = GUICtrlCreateLabel("2nd", 160, 104, 22, 17)
$second = GUICtrlCreateInput("", 192, 104, 57, 21)
$Label3 = GUICtrlCreateLabel("3rd", 160, 128, 19, 17)
$third = GUICtrlCreateInput("", 192, 128, 57, 21)
$Label4 = GUICtrlCreateLabel("4th", 160, 152, 19, 17)
$fourth = GUICtrlCreateInput("", 192, 152, 57, 21)
$Label5 = GUICtrlCreateLabel("5th", 160, 176, 19, 17)
$fifth = GUICtrlCreateInput("", 192, 176, 57, 21)
$Label6 = GUICtrlCreateLabel("6th", 160, 200, 19, 17)
$sixth = GUICtrlCreateInput("", 192, 200, 57, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Tournament = GUICtrlCreateGroup("Tournament", 8, 224, 265, 57)
$Amature = GUICtrlCreateRadio("Amature", 16, 240, 65, 17)
$Pro = GUICtrlCreateRadio("Pro", 16, 256, 57, 17)
$Label8 = GUICtrlCreateLabel("# of Races", 104, 232, 57, 17)
$RaceCount = GUICtrlCreateInput("", 104, 248, 57, 21)
$Start = GUICtrlCreateButton("Start", 184, 248, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

What I have is all the buttons aside from radios and race count at the bottom when you hit save. It saved into an .ini file called settings.ini and when you chose a car type it would bring up the numbers. I use this to store info for ratios and how to drive on this racing game. Instead of writing them down on some notepad its easier to have them stored in one app. here is what i have on ahk

CarSelect:
;INIREAD IS THE FORMAT THE NUMBERS GET SAVED INTO AND HOW THEY GET READ
Gui, 1: Submit, NoHide
IniRead, PreStage, Settings.ini, %Car%, PreStage, %A_Space%
IniRead, 2StepLaunch, Settings.ini, %Car%, 2StepLaunch, %A_Space%
IniRead, RollStart, Settings.ini, %Car%, RollStart, %A_Space%
IniRead, DialIn, Settings.ini, %Car%, DialIn, %A_Space%
IniRead, shift, Settings.ini, %Car%, shift, %A_Space%
IniRead, 2nd, Settings.ini, %Car%, 2nd, %A_Space%
IniRead, 3rd, Settings.ini, %Car%, 3rd, %A_Space%
IniRead, 4th, Settings.ini, %Car%, 4th, %A_Space%
IniRead, 5th, Settings.ini, %Car%, 5th, %A_Space%
IniRead, 6th, Settings.ini, %Car%, 6th, %A_Space%
GuiControl,, PreStageEdit, %PreStage%
GuiControl,, 2StepLaunchEdit, %2StepLaunch%
GuiControl,, RollStartEdit, %RollStart%
GuiControl,, DialInEdit, %DialIn%
GuiControl,, shift, %shift%
GuiControl,, 2ndEdit, %2nd%
GuiControl,, 3rdEdit, %3rd%
GuiControl,, 4thEdit, %4th%
GuiControl,, 5thEdit, %5th%
GuiControl,, 6thEdit, %6th%
IniRead, NitrousCheck, Settings.ini, %Car%, NitrousCheck, 0
IniRead, MaxxEngageCheck, Settings.ini, %Car%, MaxxEngageCheck, 0
IniRead, RollStartCheck, Settings.ini, %Car%, RollStartCheck, 0
IniRead, StartShiftCheck, Settings.ini, %Car%, StartShiftCheck, 0
IniRead, clutchup, Settings.ini, %Car%, clutchup, 0
IniRead, clutchdown, Settings.ini, %Car%, clutchdown, 0
GuiControl,, NitrousCheck, %NitrousCheck%
GuiControl,, MaxxEngageCheck, %MaxxEngageCheck%
GuiControl,, RollStartCheck, %RollStartCheck%
GuiControl,, StartShiftCheck, %StartShiftCheck%
GuiControl,, clutchup, %clutchup%
GuiControl,, clutchdown, %clutchdown%
Return
;#####################

Save:
Gui, 1: Submit, NoHide
If !(Car || Windows)
Return
If 2StepLaunchEdit
IniWrite, %2StepLaunchEdit%, Settings.ini, %Car%, 2StepLaunch
If PreStageEdit
IniWrite, %PreStageEdit%, Settings.ini, %Car%, PreStage
IniWrite, %NitrousCheck%, Settings.ini, %Car%, NitrousCheck
IniWrite, %clutchup%, Settings.ini, %Car%, clutchup
IniWrite, %clutchdown%, Settings.ini, %Car%, clutchdown
IniWrite, %MaxxEngageCheck%, Settings.ini, %Car%, MaxxEngageCheck
If shift
IniWrite, %shift%, Settings.ini, %Car%, shift
If DialInEdit
IniWrite, %DialInEdit%, Settings.ini, %Car%, DialIn
IniWrite, %RollStartCheck%, Settings.ini, %Car%, RollStartCheck
If RollStartEdit
IniWrite, %RollStartEdit%, Settings.ini, %Car%, RollStart
IniWrite, %StartShiftCheck%, Settings.ini, %Car%, StartShiftCheck
If 2ndEdit
IniWrite, %2ndEdit%, Settings.ini, %Car%, 2nd
If 3rdEdit
IniWrite, %3rdEdit%, Settings.ini, %Car%, 3rd
If 4thEdit
IniWrite, %4thEdit%, Settings.ini, %Car%, 4th
If 5thEdit
IniWrite, %5thEdit%, Settings.ini, %Car%, 5th
If 6thEdit
IniWrite, %6thEdit%, Settings.ini, %Car%, 6th
Return


Update:
Count := 0
WinGet, ID, List
Windows := "|"
Loop, %ID%
{
    WinGetTitle, Title, % "ahk_id " ID%A_Index%
    If Title
    {
        Count++
        TitleID%Count% := ID%A_Index%
        Windows .= (A_Index = ID) ? Title : Title "|"
    }
}
GuiControl,, Windows, %Windows%
Return

update: is like a goto sub which i found out has been removed from here. along with save:

If anyone can assist me I would love to sit down and talk with you over some other ideas i have and know autoit can do that ahk couldnt. I can also offer money through paypal since this may take up alot of time

Share this post


Link to post
Share on other sites



Hi,

I know it's not what you want to hear, but I think you'll have probs with members jumping on you due to it's game related.

I'm aware its not to automate a game, but the rules have really got out of hand when it it comes to anything game related.

What makes it worse is members snowball on the rules until the topic gets locked.

It all turns into a baited flame fest, usually by the op being baited until he/she snaps then and then baiter is made out to be the one in the right due to the op topic was borderline to start with and the baiter has been here longer.

If you can avoid mentioning a third party game in your topic, and make your code generic so it doesn't look like it's to do with a third party game you'll probably get away with help and answers without the whole above scenario happening.

Good luck

Share this post


Link to post
Share on other sites

Let me get this straight. Your first post on this forum mentions captchas, and that topic gets locked. You were asked to read the rules and then you start another topic with the same title and mention games - not a good start. The AHK forum may place less value on ethics, but this is not the AHK forum.

Share this post


Link to post
Share on other sites

I'm aware its not to automate a game, but the rules have really got out of hand when it it comes to anything game related.

No they haven't. The rule has gotten really simple. Enforcement is really simple. There's no ambiguity for anybody with working brain cells. Is it draconian and unfair in many cases? Certainly. Is it simple to point to and simple to enforce? Absolutely.

What makes it worse is members snowball on the rules until the topic gets locked.

It all turns into a baited flame fest, usually by the op being baited until he/she snaps then and then baiter is made out to be the one in the right due to the op topic was borderline to start with and the baiter has been here longer.

Err, what? What forum are you looking at? Certainly not the one I am unless somebody else just happens to beat me to these threads and closes them before me. I don't see them. What I see are new users posting about game automation without reading our rules first. Then I see somebody come along and direct them to the rules. Then a moderator comes along and locks the thread. Occasionally a thread will go on a bit before it comes out that it's for a game at which point we go into the standard procedure of point out rules, report, lock thread.

The only real baiting occurs when an enthusiastically stupid user wishes to challenge the status quo. Then the fun starts.

Anyway, this thread was reported but I see nothing wrong with it. The user is trying to write an external tool to save and load vehicle settings to an external file. I've done this in the past although I don't remember why now. I do have a PDF of setups for one game I played ages ago and I remember writing a program or script to parse the game's setup data file(s) into a text file or something.

TL;DR version: I'm not locking the thread. Before you even think to ask, SMOKE 1990, no, I will not help you so do not PM me.

Share this post


Link to post
Share on other sites

The game rules are bs even if they are simple and needed.

My opinion is irrelevant and it's not my given right to be a member of the forums, it's a privilege which can be revoked at any time.

Yeah I'm an "enthusiastically stupid user wishes to challenge the status quo", so revoke my privilege permanently please.

As I can't beat it and I don't want to bow to it and I'm definitely not joining it.

Farewell.

Share this post


Link to post
Share on other sites

Sounds like someone's in a tiff.

Who doesn't have problems with the No Game policy? Those of us that know enough about programming to not have to ask those specific sort of questions on this forum. That's not to say that I write game scripts. I don't hardly even play games. Minecraft? Skyrim? What are those?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi,

Not sure whether this will help you or confuse you, and I can't test it so that is up to you, but it shows some of the things you will need to know.

So here is something for you to start with, if you get stuck just post back here.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Global $INI = "Settings.ini" ; The INI file
Global $A_Space = " " ; used as default value for the IniRead's in _CarSelect
Global $Windows = "" ; holds window titles for the combo, get updated in _UpdateWindowList


#Region - Main GUI
$gui_hMain = GUICreate("Seths - Desktop v1.001", 281, 293, 206, 131)
$gui_hWindow = GUICtrlCreateCombo("", 8, 8, 177, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $CBS_UPPERCASE))
$gui_hSave = GUICtrlCreateButton("Save", 216, 48, 57, 25)
$gui_hName1 = GUICtrlCreateLabel("Car Select", 8, 32, 53, 17)
$gui_hCarSelect = GUICtrlCreateCombo("", 8, 48, 129, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "07 Stang|RSX|C6")
GUICtrlCreateLabel("2-Step", 152, 32, 35, 17)
$gui_hMaxxBoost = GUICtrlCreateInput("", 152, 48, 57, 21)
$gui_hUpdate = GUICtrlCreateButton("Update", 200, 8, 75, 25)
$gui_hBracket = GUICtrlCreateGroup("Bracket", 8, 72, 129, 65)
$gui_hMaxxBoost = GUICtrlCreateCheckbox("Maxx Boost", 16, 88, 97, 17)
GUICtrlCreateLabel("Dial-In", 16, 112, 34, 17)
$gui_hDialIn = GUICtrlCreateInput("", 64, 112, 65, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gui_hH2H = GUICtrlCreateGroup("H2H", 8, 136, 129, 89)
$gui_hRollStart = GUICtrlCreateCheckbox("Roll Start", 16, 176, 97, 17)
$gui_hDelayt = GUICtrlCreateLabel("Delay", 16, 200, 31, 17)
$gui_hDelay = GUICtrlCreateInput("", 64, 200, 65, 21)
$gui_hBrakeNG0 = GUICtrlCreateCheckbox("Brake N Go", 16, 152, 97, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gui_hGears = GUICtrlCreateGroup("Gears", 152, 72, 121, 153)
$gui_hStartShift = GUICtrlCreateCheckbox("Start Shift", 160, 88, 97, 17)
GUICtrlCreateLabel("2nd", 160, 104, 22, 17)
$gui_hSecond = GUICtrlCreateInput("", 192, 104, 57, 21)
GUICtrlCreateLabel("3rd", 160, 128, 19, 17)
$gui_hThird = GUICtrlCreateInput("", 192, 128, 57, 21)
GUICtrlCreateLabel("4th", 160, 152, 19, 17)
$gui_hFourth = GUICtrlCreateInput("", 192, 152, 57, 21)
GUICtrlCreateLabel("5th", 160, 176, 19, 17)
$gui_hFifth = GUICtrlCreateInput("", 192, 176, 57, 21)
GUICtrlCreateLabel("6th", 160, 200, 19, 17)
$gui_hSixth = GUICtrlCreateInput("", 192, 200, 57, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gui_hTournament = GUICtrlCreateGroup("Tournament", 8, 224, 265, 57)
$gui_hAmature = GUICtrlCreateRadio("Amature", 16, 240, 65, 17)
$gui_hPro = GUICtrlCreateRadio("Pro", 16, 256, 57, 17)
GUICtrlCreateLabel("# of Races", 104, 232, 57, 17)
$gui_hRaceCount = GUICtrlCreateInput("", 104, 248, 57, 21)
$gui_hStart = GUICtrlCreateButton("Start", 184, 248, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW, $gui_hMain)
#EndRegion - Main GUI


_UpdateWindowList() ; populate combo


While 1 ; this will keep the script running
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $gui_hUpdate ; update button was pressed
            _UpdateWindowList() ; update the combo
        Case $gui_hSave ; save button was pressed
            MsgBox(0, "Save", "You clicked the save button, but this function has not yet been implemented.")
;~           _Save...
        Case $gui_hStart ; start button was pressed
            MsgBox(0, "Start", "You clicked the start button, but this function has not yet been implemented.")
        Case $gui_hWindow ; another window was selected
            MsgBox(0, "Window", "Selected Window Title: " & @CRLF & GUICtrlRead($gui_hWindow))
        Case $gui_hCarSelect ; another car was selected
            MsgBox(0, "CarSelect", "Selected Car: " & GUICtrlRead($gui_hCarSelect))
;~           _CarSelect(GUICtrlRead($gui_hCarSelect))
    EndSwitch

    Sleep(10) ; give the CPU a break
WEnd


; update the combo
Func _UpdateWindowList()
    Local $restore_datasep = AutoItSetOption("GUIDataSeparatorChar", @LF) ; to avoid titles with a | in them getting split, we change the data sepatator char
    Local $aWinList = WinList()
    $Windows = "" ; this is a global variable, so we need to reset it
    For $i = 1 To $aWinList[0][0]
        If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
            $Windows &= $aWinList[$i][0] & @LF
        EndIf
    Next
    $Windows = StringTrimRight($Windows, 1) ; strip trailing @LF
    GUICtrlSetData($gui_hWindow, "") ; empty the combo
    GUICtrlSetData($gui_hWindow, $Windows)
    AutoItSetOption("GUIDataSeparatorChar", $restore_datasep) ; restore data sepatator character
EndFunc   ;==>_UpdateWindowList

; select car
Func _CarSelect($Car)
    If Not $Car Then Return SetError(1, 0, False)

    $PreStage = IniRead($INI, $Car, "PreStage", $A_Space)
    $2StepLaunch = IniRead($INI, $Car, "2StepLaunch", $A_Space)
    $RollStart = IniRead($INI, $Car, "RollStart", $A_Space)
    $DialIn = IniRead($INI, $Car, "DialIn", $A_Space)
    $shift = IniRead($INI, $Car, "shift", $A_Space)
    $2nd = IniRead($INI, $Car, "2nd", $A_Space)
    $3rd = IniRead($INI, $Car, "3rd", $A_Space)
    $4th = IniRead($INI, $Car, "4th", $A_Space)
    $5th = IniRead($INI, $Car, "5th", $A_Space)
    $6th = IniRead($INI, $Car, "6th", $A_Space)

;~   GUICtrlSetData($gui_hPreStage, $PreStage)
;~   GUICtrlSetData($gui_h2StepLaunch, $2StepLaunch)
    _CheckboxCheck($gui_hRollStart, $RollStart)
;~   GUICtrlSetData($gui_hDialIn, $DialIn)
    _CheckboxCheck($gui_hStartShift, $shift)
    GUICtrlSetData($gui_hSecond, $2nd)
    GUICtrlSetData($gui_hThird, $3rd)
    GUICtrlSetData($gui_hFourth, $4th)
    GUICtrlSetData($gui_hFifth, $5th)

    $NitrousCheck = IniRead($INI, $Car, "NitrousCheck", 0)
    $MaxxEngageCheck = IniRead($INI, $Car, "MaxxEngageCheck", 0)
    $RollStartCheck = IniRead($INI, $Car, "RollStartCheck", 0)
    $StartShiftCheck = IniRead($INI, $Car, "StartShiftCheck", 0)
    $clutchup = IniRead($INI, $Car, "clutchup", 0)
    $clutchdown = IniRead($INI, $Car, "clutchdown", 0)

;~   GUICtrlSetData($gui_hNitrousCheck, $NitrousCheck)
;~   GUICtrlSetData($gui_hMaxxEngageCheck, $MaxxEngageCheck)
;~   GUICtrlSetData($gui_hRollStartCheck, $RollStartCheck)
;~   GUICtrlSetData($gui_hStartShiftCheck, $StartShiftCheck)
;~   GUICtrlSetData($gui_hclutchup, $clutchup)
;~   GUICtrlSetData($gui_hclutchdown, $clutchdown)

    Return SetError(0, 0, True)
EndFunc   ;==>_CarSelect

; save data
Func _Save($Car, $Windows)
    If Not $Car Or Not $Windows Then Return ; SetError(1, 0, 0)

    ; code here
EndFunc   ;==>_Save


Func _CheckboxCheck($hCheckbox, $fCheck = True)
    If $fCheck Then ; check the box
        GUICtrlSetState($hCheckbox, $GUI_CHECKED)
    Else ; uncheck the box
        GUICtrlSetState($hCheckbox, $GUI_UNCHECKED)
    EndIf
EndFunc   ;==>_CheckboxCheck

Edit: small code fix

Edited by Robjong

Share this post


Link to post
Share on other sites

I was perhaps too quick to judge the SMOKE1990 in this thread. So if you're reading this, I apologize. In fact I hope you will stick around, and make good use of AutoIt.

Share this post


Link to post
Share on other sites

It all turns into a baited flame fest, usually by the op being baited until he/she snaps then and then baiter is made out to be the one in the right due to the op topic was borderline to start with and the baiter has been here longer.

I agree. Sometimes, this is a problem. This happened to me a couple months ago. I wasn't the OP, but I was baited and flamed and I got banned for 3 days. I still don't think I did anything wrong. I only questioned whether a topic was against a rule. I proclaimed that I was fine if the topic was against the rules. I was just asking for confirmation from a moderator whether it was against the rules. The moderator who banned me was very slick in his morphing of my intentions to make me look like I was a rebel who was challenging the rules.


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

sleepydvdr,

I was baited and flamed and I got banned for 3 days

You were banned because you offered help to someone who asked for help to bruteforce crack a password in this thread - nothing to do with gaming. Furthermore I see no evidence there of you being baited or flamed. On the contrary I see you asking several times for confirmation that such things are not against the rules when they patently are - and many other members are telling you so. :D

You often offer help to others here - which might well be why you got such a short holiday on that occasion - and so I fail to understand why you post as you just have. The rules here are very clear - if any member does not like them then, as seems to be the case with smashly above, they are free to leave and the rest of us can continue in our legitimate use of AutoIt without their constant complaints. :)

Remember this is Jon's sandbox and we only play in it if we follow the rules that he, or his Mods, decide are valid. And as Valik has pointed out above, the rules on gaming are very simple - DO NOT DISCUSS! ;)

And we now return to our normal programming.....

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba23, I understand what you are saying. However, the key phrase is exactly what you said: DO NOT DISCUSS. Why not? If a user is not arguing and is seeking answers from moderators (I don't take the word of regular users - only moderators or MVPs such as yourself), then why is it so bad to ask a question?

I think discussing subjects like this is better than an iron hand that says "shut up or you will get punished".

Sometimes, the rules are not crystal clear to every person on the planet and they need to be elaborated a bit to be fully understood.

I hope I don't cause too much unrest. I'm just stating my true feelings.


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

sleepydvdr,

DO NOT DISCUSS. Why not?

From the Forum Rules:

"Do not discuss any of the following:

Automating games

[...]

Keyloggers and other forms of malware."

How much clearer can the rules be? :)

why is it so bad to ask a question?

Because the rules are that clear and they are enforced (in Valik's words from above) in draconian manner.

If in doubt - keep quiet and wait for a Mod to decide. In this thread czardas has played it quite correctly in my eyes - as I imagine it was he who reported the thread. I too wondered about whether to report it but decided on balance not to as there appeared to be no infraction of the rules, but it was a pretty close thing. Now that Valik has made a decision, czardas has generously apologised for any offence - a very nice thing to see as there was no formal requirement to do so.

If you want to see what the forum was like when game bots were allowed, just look through the archived section - I for one am very pleased that we no longer have a forum with that sort of behaviour. ;)

Anyway, enough from me - we have monopolised this thread long enough. :D

SMOKE1990,

Sorry to hijack your thread even more than it already had been. I am sure you will get some real help soon - please understand that most of our threads do not go off the rails as far as this one did! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

<while loop> ...has to be in the script? When i remove it the script automatically closes. IM not sure where I need to write my script due to me being new to the while type loops. I am under the impression that while loops run no matter what continuously and don't affect the top to bottom running of the script?

I'm not sure what you're asking, but I'll try to explain what I think you're asking. Forgive me if I'm stating the obvious: AutoIT runs each line in the order it's read, but it makes only one pass through the code and then it exits. When it encounters a While loop, it then keeps looping through that, ignoring everything else, until something inside the loop causes it to exit either the loop or the program.

In your case, the first part of the code creates the GUI, then the loop runs continuously, checking for a GUI message vi GUIGetMsg(). If the message happens to be $GUI_EVENT_CLOSE, then the program exits; otherwise it keeps looping. Ultimately, of course, you'll have more Case statements for the other possible GUI messages (button presses, etc.), with the code for how to handle them.

If you leave the While loop out entirely, the GUI will be created, but then instantly disappear because the program is finished.

P.S. Re the dreaded "game" word: As I understand it, game discussion is forbidden here mainly because of the low maturity level of many of the gamers that posted here, causing trouble. Not surprising because many of them are no doubt young teenage script kiddies who've developed gaming skills in lieu of real social skills. If you read through the archives you'll know what I mean. I suspect there are still a certain amount of posts related to game automation here, but if the poster has the discipline to never mention the "g" word and the maturity to behave when told something they don't like, nobody's the wiser... or even cares. But the "no games" rule lets the moderators lock a thread without getting into the gray area of whether somebody's behavior is unacceptable or just annoying.

Share this post


Link to post
Share on other sites

I implemented reaction on CarSelect (load data from apropriate ini)

and Save button (save data to apropriate ini)

INI file is named according to selected car. You can easily change it to save data to only one INI file, each car to separate section.

There are loaded/saved only 2 values: $Maxx_Boost checkbox and $Dial_In edit

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Seths - Desktop v1.001", 281, 293, 206, 131)
$Window = GUICtrlCreateCombo("", 8, 8, 177, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$CBS_UPPERCASE))
$Save = GUICtrlCreateButton("Save", 216, 48, 57, 25)
$Name1 = GUICtrlCreateLabel("Car Select", 8, 32, 53, 17)
$CarSelect = GUICtrlCreateCombo("", 8, 48, 129, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "07 Stang|RSX|C6")
$Label1 = GUICtrlCreateLabel("2-Step", 152, 32, 35, 17)
$MaxxBoost = GUICtrlCreateInput("", 152, 48, 57, 21)
$Update = GUICtrlCreateButton("Update", 200, 8, 75, 25)
$Bracket = GUICtrlCreateGroup("Bracket", 8, 72, 129, 65)
$Maxx_Boost = GUICtrlCreateCheckbox("Maxx Boost", 16, 88, 97, 17)
$Label7 = GUICtrlCreateLabel("Dial-In", 16, 112, 34, 17)
$Dial_In = GUICtrlCreateInput("", 64, 112, 65, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$H2H = GUICtrlCreateGroup("H2H", 8, 136, 129, 89)
$Roll_Start = GUICtrlCreateCheckbox("Roll Start", 16, 176, 97, 17)
$Delayt = GUICtrlCreateLabel("Delay", 16, 200, 31, 17)
$Delay = GUICtrlCreateInput("", 64, 200, 65, 21)
$Brake_N_G0 = GUICtrlCreateCheckbox("Brake N Go", 16, 152, 97, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Gears = GUICtrlCreateGroup("Gears", 152, 72, 121, 153)
$Start_Shift = GUICtrlCreateCheckbox("Start Shift", 160, 88, 97, 17)
$Label2 = GUICtrlCreateLabel("2nd", 160, 104, 22, 17)
$second = GUICtrlCreateInput("", 192, 104, 57, 21)
$Label3 = GUICtrlCreateLabel("3rd", 160, 128, 19, 17)
$third = GUICtrlCreateInput("", 192, 128, 57, 21)
$Label4 = GUICtrlCreateLabel("4th", 160, 152, 19, 17)
$fourth = GUICtrlCreateInput("", 192, 152, 57, 21)
$Label5 = GUICtrlCreateLabel("5th", 160, 176, 19, 17)
$fifth = GUICtrlCreateInput("", 192, 176, 57, 21)
$Label6 = GUICtrlCreateLabel("6th", 160, 200, 19, 17)
$sixth = GUICtrlCreateInput("", 192, 200, 57, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Tournament = GUICtrlCreateGroup("Tournament", 8, 224, 265, 57)
$Amature = GUICtrlCreateRadio("Amature", 16, 240, 65, 17)
$Pro = GUICtrlCreateRadio("Pro", 16, 256, 57, 17)
$Label8 = GUICtrlCreateLabel("# of Races", 104, 232, 57, 17)
$RaceCount = GUICtrlCreateInput("", 104, 248, 57, 21)
$Start = GUICtrlCreateButton("Start", 184, 248, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
 Case $CarSelect
 CarLoad()
 Case $Save
 Save()
EndSwitch
WEnd

Func CarLoad()
$car = GUICtrlRead($CarSelect) & '.ini'
$MaxxBoost_value = IniRead($car, 'Settings', 'MaxxBoost','')
If $MaxxBoost_value = '1' Then
GUICtrlSetState($Maxx_Boost, $GUI_CHECKED)
Else
GUICtrlSetState($Maxx_Boost, $GUI_UNCHECKED)
EndIf
$Dial_In_value = IniRead($car, 'Settings', 'DialIn','')
GUICtrlSetData($Dial_In, $Dial_In_value)
EndFunc

Func Save()
Local $MaxxBoost_value = '0'

$car = GUICtrlRead($CarSelect) & '.ini'
If IsChecked($Maxx_Boost) Then $MaxxBoost_value = '1'
IniWrite($car, 'Settings', 'MaxxBoost',$MaxxBoost_value)
$Dial_In_value = GUICtrlRead($Dial_In)
IniWrite($car, 'Settings', 'DialIn',$Dial_In_value)
EndFunc

Func IsChecked($control)
Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

Share this post


Link to post
Share on other sites

INI file is named according to selected car. You can easily change it to save data to only one INI file, each car to separate section.

Here are modified Load/Save functions to save to one INI file settings.ini each car to separate section

Func CarLoad()
$car = GUICtrlRead($CarSelect)
$MaxxBoost_value = IniRead('settings.ini', $car, 'MaxxBoost','')
If $MaxxBoost_value = '1' Then
GUICtrlSetState($Maxx_Boost, $GUI_CHECKED)
Else
GUICtrlSetState($Maxx_Boost, $GUI_UNCHECKED)
EndIf
$Dial_In_value = IniRead('settings.ini', $car, 'DialIn','')
GUICtrlSetData($Dial_In, $Dial_In_value)
EndFunc

Func Save()
Local $MaxxBoost_value = '0'

$car = GUICtrlRead($CarSelect)
If IsChecked($Maxx_Boost) Then $MaxxBoost_value = '1'
IniWrite('settings.ini', $car, 'MaxxBoost',$MaxxBoost_value)
$Dial_In_value = GUICtrlRead($Dial_In)
IniWrite('settings.ini', $car, 'DialIn',$Dial_In_value)
EndFunc

Share this post


Link to post
Share on other sites

Robjong thank you for the help i have a question reguarding the update window button. When i hit it it keeps adding all the open programs on top of the other ones. I looked through the code and couldnt see why it keeps doing it through that dll call. Also through what you wrote it helped me see where i can write my program at and see how it makes sense where you type it while leaving that loop on there so the app wont close.

Hi,

Not sure whether this will help you or confuse you, and I can't test it so that is up to you, but it shows some of the things you will need to know.

So here is something for you to start with, if you get stuck just post back here.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Global $INI = "Settings.ini" ; The INI file
Global $A_Space = " " ; used as default value for the IniRead's in _CarSelect
Global $Windows = "" ; holds window titles for the combo, get updated in _UpdateWindowList


#Region - Main GUI
$gui_hMain = GUICreate("Seths - Desktop v1.001", 281, 293, 206, 131)
$gui_hWindow = GUICtrlCreateCombo("", 8, 8, 177, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $CBS_UPPERCASE))
$gui_hSave = GUICtrlCreateButton("Save", 216, 48, 57, 25)
$gui_hName1 = GUICtrlCreateLabel("Car Select", 8, 32, 53, 17)
$gui_hCarSelect = GUICtrlCreateCombo("", 8, 48, 129, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "07 Stang|RSX|C6")
GUICtrlCreateLabel("2-Step", 152, 32, 35, 17)
$gui_hMaxxBoost = GUICtrlCreateInput("", 152, 48, 57, 21)
$gui_hUpdate = GUICtrlCreateButton("Update", 200, 8, 75, 25)
$gui_hBracket = GUICtrlCreateGroup("Bracket", 8, 72, 129, 65)
$gui_hMaxxBoost = GUICtrlCreateCheckbox("Maxx Boost", 16, 88, 97, 17)
GUICtrlCreateLabel("Dial-In", 16, 112, 34, 17)
$gui_hDialIn = GUICtrlCreateInput("", 64, 112, 65, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gui_hH2H = GUICtrlCreateGroup("H2H", 8, 136, 129, 89)
$gui_hRollStart = GUICtrlCreateCheckbox("Roll Start", 16, 176, 97, 17)
$gui_hDelayt = GUICtrlCreateLabel("Delay", 16, 200, 31, 17)
$gui_hDelay = GUICtrlCreateInput("", 64, 200, 65, 21)
$gui_hBrakeNG0 = GUICtrlCreateCheckbox("Brake N Go", 16, 152, 97, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gui_hGears = GUICtrlCreateGroup("Gears", 152, 72, 121, 153)
$gui_hStartShift = GUICtrlCreateCheckbox("Start Shift", 160, 88, 97, 17)
GUICtrlCreateLabel("2nd", 160, 104, 22, 17)
$gui_hSecond = GUICtrlCreateInput("", 192, 104, 57, 21)
GUICtrlCreateLabel("3rd", 160, 128, 19, 17)
$gui_hThird = GUICtrlCreateInput("", 192, 128, 57, 21)
GUICtrlCreateLabel("4th", 160, 152, 19, 17)
$gui_hFourth = GUICtrlCreateInput("", 192, 152, 57, 21)
GUICtrlCreateLabel("5th", 160, 176, 19, 17)
$gui_hFifth = GUICtrlCreateInput("", 192, 176, 57, 21)
GUICtrlCreateLabel("6th", 160, 200, 19, 17)
$gui_hSixth = GUICtrlCreateInput("", 192, 200, 57, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gui_hTournament = GUICtrlCreateGroup("Tournament", 8, 224, 265, 57)
$gui_hAmature = GUICtrlCreateRadio("Amature", 16, 240, 65, 17)
$gui_hPro = GUICtrlCreateRadio("Pro", 16, 256, 57, 17)
GUICtrlCreateLabel("# of Races", 104, 232, 57, 17)
$gui_hRaceCount = GUICtrlCreateInput("", 104, 248, 57, 21)
$gui_hStart = GUICtrlCreateButton("Start", 184, 248, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW, $gui_hMain)
#EndRegion - Main GUI


_UpdateWindowList() ; populate combo


While 1 ; this will keep the script running
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $gui_hUpdate ; update button was pressed
            _UpdateWindowList() ; update the combo
        Case $gui_hSave ; save button was pressed
            MsgBox(0, "Save", "You clicked the save button, but this function has not yet been implemented.")
;~           _Save...
        Case $gui_hStart ; start button was pressed
            MsgBox(0, "Start", "You clicked the start button, but this function has not yet been implemented.")
        Case $gui_hWindow ; another window was selected
            MsgBox(0, "Window", "Selected Window Title: " & @CRLF & GUICtrlRead($gui_hWindow))
        Case $gui_hCarSelect ; another car was selected
            MsgBox(0, "CarSelect", "Selected Car: " & GUICtrlRead($gui_hCarSelect))
;~           _CarSelect(GUICtrlRead($gui_hCarSelect))
    EndSwitch

    Sleep(10) ; give the CPU a break
WEnd


; update the combo
Func _UpdateWindowList()
    Local $restore_datasep = AutoItSetOption("GUIDataSeparatorChar", @LF) ; to avoid titles with a | in them getting split, we change the data sepatator char
    Local $aWinList = WinList()
    $Windows = "" ; this is a global variable, so we need to reset it
    For $i = 1 To $aWinList[0][0]
        If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
            $Windows &= $aWinList[$i][0] & @LF
        EndIf
    Next
    $Windows = StringTrimRight($Windows, 1) ; strip trailing @LF
    GUICtrlSetData($gui_hWindow, $Windows)
    AutoItSetOption("GUIDataSeparatorChar", $restore_datasep) ; restore data sepatator character
EndFunc   ;==>_UpdateWindowList

; select car
Func _CarSelect($Car)
    If Not $Car Then Return SetError(1, 0, False)

    $PreStage = IniRead($INI, $Car, "PreStage", $A_Space)
    $2StepLaunch = IniRead($INI, $Car, "2StepLaunch", $A_Space)
    $RollStart = IniRead($INI, $Car, "RollStart", $A_Space)
    $DialIn = IniRead($INI, $Car, "DialIn", $A_Space)
    $shift = IniRead($INI, $Car, "shift", $A_Space)
    $2nd = IniRead($INI, $Car, "2nd", $A_Space)
    $3rd = IniRead($INI, $Car, "3rd", $A_Space)
    $4th = IniRead($INI, $Car, "4th", $A_Space)
    $5th = IniRead($INI, $Car, "5th", $A_Space)
    $6th = IniRead($INI, $Car, "6th", $A_Space)

;~   GUICtrlSetData($gui_hPreStage, $PreStage)
;~   GUICtrlSetData($gui_h2StepLaunch, $2StepLaunch)
    _CheckboxCheck($gui_hRollStart, $RollStart)
;~   GUICtrlSetData($gui_hDialIn, $DialIn)
    _CheckboxCheck($gui_hStartShift, $shift)
    GUICtrlSetData($gui_hSecond, $2nd)
    GUICtrlSetData($gui_hThird, $3rd)
    GUICtrlSetData($gui_hFourth, $4th)
    GUICtrlSetData($gui_hFifth, $5th)

    $NitrousCheck = IniRead($INI, $Car, "NitrousCheck", 0)
    $MaxxEngageCheck = IniRead($INI, $Car, "MaxxEngageCheck", 0)
    $RollStartCheck = IniRead($INI, $Car, "RollStartCheck", 0)
    $StartShiftCheck = IniRead($INI, $Car, "StartShiftCheck", 0)
    $clutchup = IniRead($INI, $Car, "clutchup", 0)
    $clutchdown = IniRead($INI, $Car, "clutchdown", 0)

;~   GUICtrlSetData($gui_hNitrousCheck, $NitrousCheck)
;~   GUICtrlSetData($gui_hMaxxEngageCheck, $MaxxEngageCheck)
;~   GUICtrlSetData($gui_hRollStartCheck, $RollStartCheck)
;~   GUICtrlSetData($gui_hStartShiftCheck, $StartShiftCheck)
;~   GUICtrlSetData($gui_hclutchup, $clutchup)
;~   GUICtrlSetData($gui_hclutchdown, $clutchdown)

    Return SetError(0, 0, True)
EndFunc   ;==>_CarSelect

; save data
Func _Save($Car, $Windows)
    If Not $Car Or Not $Windows Then Return ; SetError(1, 0, 0)

    ; code here
EndFunc   ;==>_Save


Func _CheckboxCheck($hCheckbox, $fCheck = True)
    If $fCheck Then ; check the box
        GUICtrlSetState($hCheckbox, $GUI_CHECKED)
    Else ; uncheck the box
        GUICtrlSetState($hCheckbox, $GUI_UNCHECKED)
    EndIf
EndFunc   ;==>_CheckboxCheck

Edit: small code fix

Zenda thank you for the single file ini read, i can see how you wrote it to make it work for the rest of the inputs and check boxes. Appreciate all the help. You seem to have a good handle on autoit and if your interested in working with me we can put our minds together and ill basically hire you for any more help i need.

Here are modified Load/Save functions to save to one INI file settings.ini each car to separate section

Func CarLoad()
$car = GUICtrlRead($CarSelect)
$MaxxBoost_value = IniRead('settings.ini', $car, 'MaxxBoost','')
If $MaxxBoost_value = '1' Then
GUICtrlSetState($Maxx_Boost, $GUI_CHECKED)
Else
GUICtrlSetState($Maxx_Boost, $GUI_UNCHECKED)
EndIf
$Dial_In_value = IniRead('settings.ini', $car, 'DialIn','')
GUICtrlSetData($Dial_In, $Dial_In_value)
EndFunc

Func Save()
Local $MaxxBoost_value = '0'

$car = GUICtrlRead($CarSelect)
If IsChecked($Maxx_Boost) Then $MaxxBoost_value = '1'
IniWrite('settings.ini', $car, 'MaxxBoost',$MaxxBoost_value)
$Dial_In_value = GUICtrlRead($Dial_In)
IniWrite('settings.ini', $car, 'DialIn',$Dial_In_value)
EndFunc

Share this post


Link to post
Share on other sites

To all the crazy people on here :) i really enjoy reading this forum and think you guys are wound to tight. I really do like the clean professional forum rules that are put into place.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Hi,

glad it helped you figure things out, about the combo box problem, you can empty the combo before updating it with the new window list in the update function.

GUICtrlSetData($gui_hWindow, "") ; empty the combo

I also updated the code I posted before.

Edited by Robjong

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