Sign in to follow this  
Followers 0
Orkhayiq

New to AutoIt and Coding - First script..

16 posts in this topic

Hello there AutoIt community,

I'm new to coding/scripting and would like some help with my first small project I've got going. Bare in mind I'm not experienced at all and this code will prove it! The bits that work are from examples I've slightly modified, the rest; guess work trying to make it function.

The aim of the project so far is listed in the ; Script Function: line at the top of the code form.

You can see the logic I'm working by but it's obviously wrong. When someone has got time to sort it out using my most likely inefficient methods of cutting corners to achieve the same goal, please do! I'd like to stick to the pattern I'm going at and learn how to simplify it later.

Here's the catastrophe:

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win7 x64
; Author:         Orkhayiq 
;
; Script Function:
;   To open a GUI, enter the users C:\Users\'USERNAME'\My Documents.. into a text field. Read the text inputed ($username) and use it whilst in the "; Wait for SaveAs window" process to save a .ini file to C:\Users\$username\My Documents\BFBC2 beta
;


#include <GUIConstantsEx.au3>
#include <EditConstants.au3>



; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "AutoIt Example (English Only)", "This script will run Notepad type in some text and then quit.  Run?")

; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "AutoIt", "OK.  Bye!")
    Exit
EndIf


$mainwindow = GUICreate("Hello World", 300, 500)
GUICtrlCreateLabel("Please enter your C:\Users\'USERNAME'\My Documents..", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 190, 170, 60)
$userinputfield = GUICtrlCreateEdit ("Someones username", 100, 100, 150, 50)
GUISetState(@SW_SHOW)

Do
    GUIGetMsg()
    $msg = $username
    until $userinputfield = $okbutton


; Run Notepad
Run("Notepad.exe")


; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems
WinWaitActive("[CLASS:Notepad]")


; Now that the Notepad window is active type some text
Send("[WindowSettings]{ENTER}Width=1680{ENTER}Height=1050{ENTER}Fullscreen=false{ENTER}RefreshRate=59.882999{ENTER}VSync=false{ENTER}[Sound]{ENTER}Quality=high{ENTER}VoipEnable=true{ENTER}[Graphics]{ENTER}Effects=high{ENTER}Soldiers=high{ENTER}Vehicles=high{ENTER}Overgrowth=high{ENTER}Undergrowth=high{ENTER}StaticObjects=high{ENTER}Terrain=high{ENTER}Shadows=high{ENTER}Bloom=false{ENTER}HSAO=true{ENTER}MSAA=0{ENTER}Water=high{ENTER}MainQuality=custom{ENTER}Texture=high{ENTER}DxVersion=9{ENTER}Aniso=4{ENTER}Detail=high{ENTER}")
Sleep(500)
Send("+{UP 2}")
Sleep(500)


; Now Save As by pressing Alt-a and then a (File menu -> Save As)
Send("!f")
Send("a")
Sleep(1000)

; Wait for SaveAs window
WinWaitActive("Save As")
Send("C:\Users\"$username"\Documents\BFBC2Beta\TESTsettings.ini")
Send("{ENTER}")
Sleep(1000)

; Wait for the Confirm Save As window popup
WinWaitActive("Confirm Save As")
Send("y")

; Now Exit by pressing Alt-f and then x (File menu -> Exit)
Send("!f")
Send("x")

; Now wait for Notepad to close before continuing
WinWaitClose("[CLASS:Notepad]")


; Finished!

Thanks in advance! :D

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Heare is reedited version with no gui included, and with no send command (hope that i did not write any mistakes while editing it)

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win7 x64
; Author:         Orkhayiq 
;
; Script Function:
;   To open a GUI, enter the users C:\Users\'USERNAME'\My Documents.. into a text field. Read the text inputed ($username) and use it whilst in the "; Wait for SaveAs window" process to save a .ini file to C:\Users\$username\My Documents\BFBC2 beta
;
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <File.au3>

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
$ini = InputBox("AutoIt Example (English Only)","This Script Will Create Ini File On Cyrebtly Loged User In Destination Folder "&@CRLF&@CRLF&"MyDocumentsDir\BFBC2Beta\TESTsettings.ini"&@CRLF&@CRLF&"Run?",@MyDocumentsDir&"\BFBC2Beta\TESTsettings.ini")
If $ini = "" Then
    MsgBox(0, "AutoIt", "OK.  Bye!")
    Exit
EndIf
If Not FileExists($ini) Then
    DirCreate(StringReplace($ini,"TESTsettings.ini",""))
    If @error Then
        MsgBox(0,"ERROR","Exiting!!!")
        Exit
    EndIf
EndIf

IniWrite ($ini, "WindowSettings", "Width", "1680" )
IniWrite ($ini, "WindowSettings", "Height", "1050" )
IniWrite ($ini, "WindowSettings", "Fullscreen", "False" )
IniWrite ($ini, "WindowSettings", "RefreshRate", "59.882999" )
IniWrite ($ini, "WindowSettings", "VSync", "False" )

IniWrite ($ini, "Sound", "Quality", "high" )
IniWrite ($ini, "Sound", "VoipEnable", "True" )

IniWrite ($ini, "Graphics", "Effects", "high" )
IniWrite ($ini, "Graphics", "Soldiers", "high" )
IniWrite ($ini, "Graphics", "Vehicles", "high" )
IniWrite ($ini, "Graphics", "Overgrowth", "high" )
IniWrite ($ini, "Graphics", "Undergrowth", "high" )
IniWrite ($ini, "Graphics", "StaticObjects", "high" )
IniWrite ($ini, "Graphics", "Terrain", "high" )
IniWrite ($ini, "Graphics", "Shadows", "high" )
IniWrite ($ini, "Graphics", "Bloom", "False" )
IniWrite ($ini, "Graphics", "HSAO", "True" )
IniWrite ($ini, "Graphics", "MSAA", "0" )
IniWrite ($ini, "Graphics", "Water", "high" )
IniWrite ($ini, "Graphics", "MainQuality", "custom" )
IniWrite ($ini, "Graphics", "Texture", "high" )
IniWrite ($ini, "Graphics", "DxVersion", "9" )
IniWrite ($ini, "Graphics", "Aniso", "4" )
IniWrite ($ini, "Graphics", "Detail", "high" )

To have gui youl need to load GUIGetMsg() into variable

$msg = GUIGetMsg()

And then in $msg is = pressed button

Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit;exit on gui close
            Case $msg = $okbutton
                ;write ini
        EndSelect

write the ini

Edit:

IniWrite

--------------------------------------------------------------------------------

Remarks

A standard ini file looks like:

[sectionName]

Key=Value

If file does not exist, it is created.

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

Thanks a lot for that! Much appreciated :D

Works well. I'm going to look through it and digest it all. Try and understand it all.

I may have some other questions or needed help, so I'll be adding new posts later most likely..

Thanks once again

Share this post


Link to post
Share on other sites

I've managed to figure out how to copy a file if it is already present and create a backup of that file.

If FileExists($ini) Then
    FileCopy(@MyDocumentsDir&"\BFBC2Beta\settings.ini",@MyDocumentsDir&"\BFBC2Beta\settings_BACKUP.ini")
        If @error Then
            MsgBox((0,"ERROR","Error occured backing up file settings.ini. Rename settings.ini to settings_BACKUP.ini and try again.")
            Exit
        EndIf
EndIf

I'm wondering if it is possible to have a similar function for the settings_BACKUP.ini: If found, create settings_BACKUP(2).ini and if (2) is present then create BACKUP(3)? Maybe instead of number coding the backup .ini files with (2), (3), (4)... , maybe it's possible to add the date and time on each file instead (??/??/?? - ??:??).

Took me ages to figure out that simple code above! Don't tell me there is any easier way.. :D

Share this post


Link to post
Share on other sites

Here's how the code is looking so far:

; AutoIt Version: 3.0
; Language:       English
; Platform:       Win7 x64
; Author:         Orkhayiq 
;
; Script Function:
;   To create a GUI that allows cutomisation if each iniWrite variable, write it to the setting.ini (create it if not found and give the option to back the original file up) and then allow the user to launch the game from a MsgBox.
;
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <File.au3>

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
$ini = InputBox("::: BFBC2 ::: Settings Configurator :::","This script will create an .ini file on the currently logged user in destination folder: "&@CRLF&@CRLF&"My Documents\BFBC2Beta\settings.ini"&@CRLF&@CRLF&"Run?",@MyDocumentsDir&"\BFBC2Beta\settings.ini","",300,180)
If $ini = "" Then
    MsgBox(262144+64, "::: BFBC2 ::: Settings Configurator :::", "::: Created by Orkhayiq :::",5)
    Exit
EndIf

If FileExists($ini) Then
    $msgbox = MsgBox(32+4,"The settings.ini was detected..","The configurator will now write to settings.ini. Would you like to create a backup of the original?")  
        If $msgbox = 6 Then
            FileCopy(@MyDocumentsDir&"\BFBC2Beta\settings.ini",@MyDocumentsDir&"\BFBC2Beta\settings_BACKUP.ini")
                If @error Then
                    MsgBox(48,"ERROR","An error occured backing up file settings.ini. Rename settings.ini to settings_BACKUP.ini and try again.")
                    Exit
                EndIf
        Endif
EndIf

If Not FileExists($ini) Then
    MsgBox(32+0,"The settings.ini was created..","The configurator will now write to settings.ini")
        DirCreate(StringReplace($ini,"settings.ini",""))
            If @error Then
                MsgBox(48,"ERROR","An error occured trying to create file settings.ini. Create a settings.ini file and try again.")
                Exit
            EndIf
EndIf

IniWrite ($ini, "WindowSettings", "Width", "1680" )
IniWrite ($ini, "WindowSettings", "Height", "1050" )
IniWrite ($ini, "WindowSettings", "Fullscreen", "False" )
IniWrite ($ini, "WindowSettings", "RefreshRate", "59.882999" )
IniWrite ($ini, "WindowSettings", "VSync", "False" )

IniWrite ($ini, "Sound", "Quality", "high" )
IniWrite ($ini, "Sound", "VoipEnable", "True" )

IniWrite ($ini, "Graphics", "Effects", "high" )
IniWrite ($ini, "Graphics", "Soldiers", "high" )
IniWrite ($ini, "Graphics", "Vehicles", "high" )
IniWrite ($ini, "Graphics", "Overgrowth", "high" )
IniWrite ($ini, "Graphics", "Undergrowth", "high" )
IniWrite ($ini, "Graphics", "StaticObjects", "high" )
IniWrite ($ini, "Graphics", "Terrain", "high" )
IniWrite ($ini, "Graphics", "Shadows", "high" )
IniWrite ($ini, "Graphics", "Bloom", "False" )
IniWrite ($ini, "Graphics", "HSAO", "True" )
IniWrite ($ini, "Graphics", "MSAA", "0" )
IniWrite ($ini, "Graphics", "Water", "high" )
IniWrite ($ini, "Graphics", "MainQuality", "custom" )
IniWrite ($ini, "Graphics", "Texture", "high" )
IniWrite ($ini, "Graphics", "DxVersion", "9" )
IniWrite ($ini, "Graphics", "Aniso", "4" )
IniWrite ($ini, "Graphics", "Detail", "high" )

MsgBox(262144, "::: BFBC2 ::: Settings Configurator :::", "New settings were successfully written!",3)
MsgBox(262144+64, "::: BFBC2 ::: Settings Configurator :::", "::: Created by Orkhayiq using AutoIt :::",3.5)

If someone could look through it and give me any suggestions to cut out code or help me with creating a GUI that allows the user to customise the variables sent by TniWrite eg: low, medium, or high / true or false. That would be very nice.

Thanks :D

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

So another small update on my code progress.

I'm in need of help. If someone could read through the notes inside the code and suggest/example some methods of achieving my goals? Also, if anyone has time to answer some of my previous post questions please do! :D

; AutoIt Version: 3.0
; Language:       English
; Platform:       Win7 x64
; Author:         Orkhayiq 


; Script Function:
;   To create a GUI that allows cutomisation if each iniWrite variable, write it to the setting.ini (create it if not found and give the option to back the original file up) and then allow the user to launch the game from a MsgBox.

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <File.au3>


; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script

$ini = InputBox("::: BFBC2 ::: Settings Configurator :::", "This script will create an .ini file on the currently logged user in destination folder: "&@CRLF&@CRLF&"My Documents\BFBC2Beta\settings.ini"&@CRLF&@CRLF&"Run?", @MyDocumentsDir&"\BFBC2Beta\settings.ini", "", 300, 180 )
If $ini = "" Then
    MsgBox(262144+64, "::: BFBC2 ::: Settings Configurator :::", "::: Created by Orkhayiq using AutoIt :::", 3.5 )
    Exit
EndIf


; settings.ini file present

If FileExists($ini) Then
    $msgbox = MsgBox(32+4, "The settings.ini file was detected..", "The configurator will now write to settings.ini. Would you like to create a backup of the original?" )  
        If $msgbox = 6 Then
            FileCopy(@MyDocumentsDir&"\BFBC2Beta\settings.ini",@MyDocumentsDir&"\BFBC2Beta\settings_BACKUP.ini" )
                If @error Then
                    MsgBox(48, "ERROR", "An error occured backing up file settings.ini. Rename settings.ini to settings_BACKUP.ini and try again." )
                    Exit
                EndIf
        Endif
EndIf
    

; settings.ini file NOT present

If Not FileExists($ini) Then
    MsgBox(32+0,"The settings.ini file was created..", "The configurator will now write to settings.ini" )
        DirCreate(StringReplace($ini,"settings.ini", "" ))
            If @error Then
                MsgBox(48,"ERROR", "An error occured trying to create file settings.ini. Create a settings.ini file and try again." )
                Exit
            EndIf
EndIf


; Write specified data to BFBC2's settings.ini file

IniWrite ($ini, "WindowSettings", "Width", "1680" )
IniWrite ($ini, "WindowSettings", "Height", "1050" )
IniWrite ($ini, "WindowSettings", "Fullscreen", "False" )
IniWrite ($ini, "WindowSettings", "RefreshRate", "59.882999" )
IniWrite ($ini, "WindowSettings", "VSync", "False" )

IniWrite ($ini, "Sound", "Quality", "high" )
IniWrite ($ini, "Sound", "VoipEnable", "True" )

IniWrite ($ini, "Graphics", "Effects", "high" )
IniWrite ($ini, "Graphics", "Soldiers", "high" )
IniWrite ($ini, "Graphics", "Vehicles", "high" )
IniWrite ($ini, "Graphics", "Overgrowth", "high" )
IniWrite ($ini, "Graphics", "Undergrowth", "high" )
IniWrite ($ini, "Graphics", "StaticObjects", "high" )
IniWrite ($ini, "Graphics", "Terrain", "high" )
IniWrite ($ini, "Graphics", "Shadows", "high" )
IniWrite ($ini, "Graphics", "Bloom", "False" )
IniWrite ($ini, "Graphics", "HSAO", "True" )
IniWrite ($ini, "Graphics", "MSAA", "0" )
IniWrite ($ini, "Graphics", "Water", "high" )
IniWrite ($ini, "Graphics", "MainQuality", "custom" )
IniWrite ($ini, "Graphics", "Texture", "high" )
IniWrite ($ini, "Graphics", "DxVersion", "9" )
IniWrite ($ini, "Graphics", "Aniso", "4" )
IniWrite ($ini, "Graphics", "Detail", "high" )


; Confirmation to show successful data write.

MsgBox(262144, "::: BFBC2 ::: Settings Configurator :::", "New settings were successfully written!", 3 )


; Launch BFBC2? Having real trouble figuring out all this Select/Switch case nonsense! ;)

$msgbox = MsgBox(262144+32+4, "::: BFBC2 ::: Settings Configurator :::", "Would you like to launch BFBC2 now?" )
;~      Select
            If $msgbox = 6 then
                $fod = FileOpenDialog ("Please navigate to and select your Steam.exe..", @ComputerName & "", "(Steam.exe)|All Files (*.*)", 1 + 4 )
                
                
                    ; Write the 'BFBC2 Settings Configurator.ini' file to the scripts/compiled final exe's folder. How?
                    
                        IniWrite ("BFBC2 Settings Configurator.ini", "Steam", "Directory", $fod )
            EndIf           
                    ; Once use has defined the Steam.exe, I need to add launch options to the .exe to launch the correct program within Steam.
                    ; After launch is executed go to Quit Popup MsgBox below.
                    ; Also next launch, be able to read the 'BFBC2 Settings Configurator.ini' so user won't have to re-define the .exe's location.
                    
                    If @error Then
                        $msgbox = MsgBox(48+5, "Error", "You didn't select Steam.exe" )
                    EndIf   
;~          Case $msgbox = 4 Then 
                $fod = FileOpenDialog ("Please navigate to and select your Steam.exe..", @ComputerName & "", "(Steam.exe)|All Files (*.*)", 1 + 4 )
                        IniWrite ("BFBC2 Settings Configurator.ini", "Steam", "Directory", $fod )
                    If @error Then
                        $msgbox = MsgBox(48+5, "Error", "You didn't select Steam.exe" )
                    EndIf   
;~          Case $msgbox = 2 Then
                        
                ; Cancel BFBC2 launch and move on to the Quit Popup MsgBox below.   
                
;~      EndSelect


; Quit Popup

MsgBox(262144+64, "::: BFBC2 ::: Settings Configurator :::", "::: Created by Orkhayiq using AutoIt :::", 3.5 )

TIA.

Edited by Orkhayiq

Share this post


Link to post
Share on other sites

Maybe instead of number coding the backup .ini files with (2), (3), (4)

This shud return the next free filename with [1] [2] [3] [4]

$ini = "1.ini"
$x = 1
Do
    $x += 1
Until Not FileExists(StringReplace($ini,".ini","")&"["&$x&"]"&".ini")
MsgBox(0,"",StringReplace($ini,".ini","")&"["&$x&"]"&".ini")

to customise the variables sent by TniWrite eg: low, medium, or high / true or false

Heare is one small gui example for you

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered
$Combo_1 = GUICtrlCreateCombo("item1", 10, 10,-1,-1,$CBS_DROPDOWNLIST) ; create first item
GUICtrlSetData(-1, "item2|item3", "item3") ; add other item snd set a new default
$Button_1 = GUICtrlCreateButton("Button Test", 10, 50)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
        Case $msg = $Button_1
            MsgBox(0,"Sellected text",GUICtrlRead($Combo_1))
    EndSelect
WEnd

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

I'm working on trying to get your examples working, thank you.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Can't get the FileOpenDialog to work how I'd like. The file isn't created unless you press the Cancel button in the FOD popup.

; Confirmation to show successful data write.
; Launch BFBC2?
$msgbox = MsgBox ( 262144+32+4, "::: BFBC2 ::: Settings Configurator :::", "The new settings were written successfully."&@CRLF&@CRLF&"Would you like to launch BFBC2 now?"&@CRLF&@CRLF&"" )

            ;   If No (7): Skip to next function
            If $msgbox = 7 Then 
            EndIf

            ; Once use has defined the Steam.exe, I need to add launch options to the .exe directory string to launch the correct program within Steam.
            ; After launch is executed go to Quit Popup MsgBox below.
            ; Also next launch, be able to read the 'BFBC2 Settings Configurator.ini' so user won't have to re-define the .exe's location.                  
            ; If Yes (6): Skip to next function
            If $msgbox = 6 then
                
                $bfbc2config = "BFBC2 CONFIG.ini"
                
                    If Not FileExists ( $bfbc2config ) Then
                        MsgBox ( 32, "Creating..", "BFBC2 Configurator's BFBC2 CONFIG.ini will be created." )
                            DirCreate ( StringReplace ( $bfbc2config, "BFBC2 CONFIG.ini", "" ))
                    EndIf
                    
                $fod = FileOpenDialog ( "Please navigate to and select your Steam.exe..", @ComputerName & "", "(Steam.exe)|All Files (*.*)", 1 + 4 )

                                ; Write the 'BFBC2 CONFIG.ini' file to the location of the scripts/compiled exe's running DIR. How?             
                                IniWrite ( $bfbc2config, "Steam", "Directory", $fod )

                        
                            If @error Then
                                $msgbox = MsgBox( 48+5, "Error", "You didn't select Steam.exe" )
                            EndIf   
                    
            EndIf

I know this is likely simple to solve but it's been slowly sending me insane!

Tried out as much as I could guess, please help!

Edited by Orkhayiq

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hope that i understanded you corredctly with what you need

i tested it on "(test.ini)|All Files (*.*)" change it to suit your needs

; Confirmation to show successful data write.
; Launch BFBC2?
$msgbox = MsgBox ( 262144+32+4, "::: BFBC2 ::: Settings Configurator :::", "The new settings were written successfully."&@CRLF&@CRLF&"Would you like to launch BFBC2 now?"&@CRLF&@CRLF&"" )

            ;   If No (7): Skip to next function
            If $msgbox = 7 Then 
            EndIf

            ; Once use has defined the Steam.exe, I need to add launch options to the .exe directory string to launch the correct program within Steam.
            ; After launch is executed go to Quit Popup MsgBox below.
            ; Also next launch, be able to read the 'BFBC2 Settings Configurator.ini' so user won't have to re-define the .exe's location.                  
            ; If Yes (6): Skip to next function
            If $msgbox = 6 then
                selectfile()
            Else
                Exit
            EndIf
                
                
Func selectfile()
    $bfbc2config = "BFBC2 CONFIG.ini"
    If Not FileExists ( $bfbc2config ) Then
        MsgBox ( 32, "Creating..", "BFBC2 Configurator's BFBC2 CONFIG.ini will be created." )
        DirCreate ( StringReplace ( $bfbc2config, "BFBC2 CONFIG.ini", "" ))
    EndIf
    $fod = FileOpenDialog ( "Please navigate to and select your Steam.exe..", @ComputerName & "", "(test.ini)|All Files (*.*)", 1 + 4 )
    ; Write the 'BFBC2 CONFIG.ini' file to the location of the scripts/compiled exe's running DIR. How?  
    If Not @error Then                              
        MsgBox(0,"",$fod)                               
        IniWrite ( $bfbc2config, "Steam", "Directory", $fod )
    Else
        If MsgBox ( 48+5, "Error", "You didn't select Steam.exe" ) = 4 Then
            selectfile()
        Else
            Exit
        EndIf
    EndIf
EndFunc
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

#11 ·  Posted (edited)

That's much cleaner than my attempt!

My main problem at the moment:

DirCreate ( StringReplace ( $bfbc2config, " ", " " ))

This bit of code always creates a folder "BFBC2 CONFIG.ini"..

..But I want a "BFBC2 CONFIG.ini" file created.

Solved:

DirCreate ( StringReplace ( $bfbc2config, "BFBC2 CONFIG.ini", " " ))

- Creates a *.ini

Knowing how to jump between areas of the code using a 'Func ???()' command was really useful. Been thinking about how to jump around.

--

I'm going to try and figure out how to read from a ini and use the stored info in the code so the user won't have to redefine the program path.

Edited by Orkhayiq

Share this post


Link to post
Share on other sites

Ini will b created automaticly when you use iniwrite if file does not exsist, scroll up to my second post and youl see remarks on iniwrite, or open the help file and read it.


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

#13 ·  Posted (edited)

I've been reading the the help file when I can.

Quite a lot to absorb!

I've got a question(suprised? lol): I've got all these resolutions as separate Datas in the DropDown.

RES_1 x RES_2 : Is there a simple way to write the first number into the "WindowSettings", "Width", "NotFound" and the second number after the 'x' into "WindowSettings", "Height", "NotFound" ?

..I don't want to have to make the user select the width in one box and the height in another (meaning they have to match the resolutions up correctly otherwise the game will run in odd aspect ratios.

I want to keep it as $CBS_DropDown as it lets users enter their own number if I haven't included it.

GUICreate ( "|[< BFBC2 - Tweaker | v1.0 >]|") ; will create a dialog box that when displayed is centered


$Cmb_WinSet_Resolution = IniRead ( @MyDocumentsDir&"\BFBC2Beta\settings.ini", "WindowSettings", "Width", "NotFound" )
$Combo_1 = GUICtrlCreateCombo( $Cmb_WinSet_Resolution, 10, 200, 100, 80, $CBS_DROPDOWN, "") ; create first item
    GUICtrlSetData(-1, "1280 x 720|1280 x 768|1280 x 800|1280 x 960|1280 x 1024|1360 x 768|1600 x 900|1600 x 1024|1680 x 1050|1920 x 1080|1920 x 1200", "" ) ; add other item snd set a new default

; I've tried using &RES_1& x &RES_2& and
; &"RES_1"& x &"RES_2"& and
; &RES_1&"RES_1" x &RES_2&"RES_2"
; Maybe no the best detective work but I keep poking it till it does something! :p

    
$Button_1 = GUICtrlCreateButton("Button Test", 10, 50)
    GUISetState()
    
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
        Case $msg = $Button_1
            MsgBox(0,"Sellected text",GUICtrlRead($Combo_1))
    EndSelect
WEnd

I haven't tried to edit the bottom half of the code yet.

Thank you :mellow:

Edited by Orkhayiq

Share this post


Link to post
Share on other sites

try StringSplit on GUICtrlRead($Combo_1) with flag '1' to split text " x " load it to variable and read results from $var[1] and $var[2] :mellow:


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

#16 ·  Posted (edited)

Thanks for the suggestion. I'll give it a go.

..and jaberwocky, I doubt it could be any worse than my attempts, haha!

----

Okay, I am trying hard every time you give me some advice but can't make the solution work.

The MsgBox TEST is returning $Cmb_Box as "3" when I want it to be saying the same as the Selected text MsgBox.

Struggling to StringSplit it.

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <ListboxConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

GUICreate ( "|[< BFBC2 - Tweaker | v1.0 >]|") ; will create a dialog box that when displayed is centered


$WinSettings_Width_ini = IniRead ( @MyDocumentsDir&"\BFBC2Beta\settings.ini", "WindowSettings", "Width", "NotFound" )
$WinSettings_Height_ini = IniRead ( @MyDocumentsDir&"\BFBC2Beta\settings.ini", "WindowSettings", "Height", "NotFound" )



$Cmb_Box = GUICtrlCreateCombo( "", 10, 200, 100, 80, $CBS_DROPDOWN, "" ) ; create first item
        
    GUICtrlSetData(-1, "2560 × 1920|2560 x 1600|1920 x 1200|1920 x 1080|1768 x 992|1680 x 1050|1600 x 1200|1600 x 1024|1600 x 900|1440 x 900|1360 x 768|1280 x 1024|1280 x 960|1280 x 800|1280 x 768|1280 x 720|1152 x 864|1024 x 786|800 x 600", &$WinSettings_Width_ini" x "$WinSettings_Height_ini& ) ; add other item snd set a new default

    
$Button_1 = GUICtrlCreateButton("Response?", 10, 50)
    GUISetState()
    
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE 
        GUISetState(@SW_HIDE)
            ExitProgram()           
        Case $msg = $Button_1
            MsgBox(0,"Selected text", GUICtrlRead($Cmb_Box))
                $WinSettings_Width_NEW = GUICtrlRead($Cmb_Box)
                $WinSettings_Height_NEW = GUICtrlRead($Cmb_Box)
                    StringSplit ( $Cmb_Box, &$WinSettings_Width_NEW" x "$WinSettings_Height_NEW&, 1)
                    MsgBox(0, "TEST:", $Cmb_Box)
    EndSelect
WEnd

TIA.

Edited by Orkhayiq

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