Jump to content

Combobox - what am I doing wrong?


Recommended Posts

Hi Guys,

Please see the code below:

#include <file.au3>

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\form1_1.kxf
$Form1_1 = GUICreate("Auto-it Autotext", 351, 583, 192, 125)
$Shortcutkeylabel = GUICtrlCreateLabel("Shortcut key", 17, 60, 104, 33, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$Shortcut_input = GUICtrlCreateInput("", 17, 112, 300, 21)
$Main_label = GUICtrlCreateLabel("Auto-it Autotext", 17, 8, 300, 33, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$Combo1 = GUICtrlCreateCombo("Please select", 168, 408, 137, 25)
GUICtrlSetData(-1, "Text|Code", "Text")
$Label1 = GUICtrlCreateLabel("Code or Full Text", 17, 156, 124, 33, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$code_input = GUICtrlCreateEdit("", 17, 208, 300, 178)
GUICtrlSetData(-1, "")
$ok_button = GUICtrlCreateButton("Ok", 17, 536, 97, 25, $WS_GROUP)
$Cancel_button = GUICtrlCreateButton("Cancel", 193, 536, 95, 25, $WS_GROUP)
$Input_chooser = GUICtrlCreateLabel("Input Type", 17, 405, 124, 33, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###






While 1
    $shortinputfile = FileOpen("D:\Program Files\AutoIt3\Include\autotextmain.au3", 1)
    $codeinputfile = FileOpen("D:\Program Files\AutoIt3\Include\autotextfunctions.au3", 1)
    $shortinputread = GUICtrlRead($Shortcut_input)
    $Msg = GUIGetMsg()
    Select

        Case $Msg = $GUI_EVENT_CLOSE
            Exit
        Case $Msg = $Cancel_button
            Exit


        Case $Msg = $ok_button

            Select

                Case GUICtrlRead($Combo1) = "Text"

                    If $shortinputread = "" Then Exit
                    If $shortinputread <> "" Then
                        _FileWriteToLine("D:\Program Files\AutoIt3\Include\autotextmain.au3", 39, @CRLF & "HotStringSet(" & """" & $shortinputread & """" & "," & """" & $shortinputread & """" & ")", 1)
                        FileClose($shortinputfile)
                        Exit
                    EndIf
                    $codeinputread = GUICtrlRead($code_input)
                    If $codeinputread = "" Then Exit
                    If $codeinputread <> "" Then
                        $len = StringLen($shortinputread)
                        FileWrite("D:\Program Files\AutoIt3\Include\autotextfunctions.au3", "Func " & $shortinputread & "(" & ")" & @CRLF & "send(" & """" & "{BS " & $len & "}" & """" & ")" & @CRLF & "send(" & """" & $codeinputread & """" & ")" & @CRLF & "EndFunc" & @CRLF & @CRLF)

                        FileClose($codeinputfile)

                        Exit
                    EndIf
                Case GUICtrlRead($Combo1) = "Code"

                    If $shortinputread = "" Then Exit
                    If $shortinputread <> "" Then
                        _FileWriteToLine("D:\Program Files\AutoIt3\Include\autotextmain.au3", 39, @CRLF & "HotStringSet(" & """" & $shortinputread & """" & "," & """" & $shortinputread & """" & ")", 1)
                        FileClose($shortinputfile)
                        Exit

                    EndIf

                    $codeinputread = GUICtrlRead($code_input)
                    If $codeinputread = "" Then Exit
                    If $codeinputread <> "" Then
                        $len = StringLen($shortinputread)

                        FileWrite("D:\Program Files\AutoIt3\Include\autotextfunctions.au3", "Func " & $shortinputread & "(" & ")" & @CRLF & "send(" & """" & "{BS " & $len & "}" & """" & ")" & @CRLF & $codeinputread & @CRLF & "EndFunc" & @CRLF & @CRLF)
                        FileClose($codeinputfile)
                        Exit
                    EndIf


            EndSelect

    EndSelect


WEnd;### Tidy Error -> switch is never closed in your script.

The file write function in both cases is not working while the _filewriteline function is working. Any leads what I might be getting wrong here?

Thanks.

Link to comment
Share on other sites

Ok, finally got it to work >_<

Here is the code:

#include <file.au3>

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Auto-it Autotext", 352, 418)
$Label1 = GUICtrlCreateLabel("Code or Full Text", 17, 156, 308, 33, BitOR($SS_CENTER,$SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$Input_chooser = GUICtrlCreateLabel("Input Type", 17, 109, 104, 33, BitOR($SS_CENTER,$SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$Shortcutkeylabel = GUICtrlCreateLabel("Shortcut key", 17, 60, 104, 33, BitOR($SS_CENTER,$SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$Main_label = GUICtrlCreateLabel("Auto-it Autotext", 17, 8, 308, 33, BitOR($SS_CENTER,$SS_CENTERIMAGE), $WS_EX_STATICEDGE)
$Shortcut_input = GUICtrlCreateInput("", 137, 64, 191, 21)
$Combo1 = GUICtrlCreateCombo("Please select", 136, 112, 191, 25)
GUICtrlSetData(-1, "Text|Code")
$code_input = GUICtrlCreateEdit("", 17, 200, 308, 170)
GUICtrlSetData(-1, "")
$ok_button = GUICtrlCreateButton("Ok", 25, 392, 97, 25, $WS_GROUP)
$Cancel_button = GUICtrlCreateButton("Cancel", 201, 392, 95, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###









While 1

    $Msg = GUIGetMsg()

    Select
        Case $Msg = $GUI_EVENT_CLOSE
            Exit


        Case $Msg = $Cancel_button
            Exit

            Case $Msg = $ok_button And $codeinputread = ""
                Exit

            Case $Msg = $ok_button And $textinputread = ""
                Exit

        Case $Msg = $ok_button And GUICtrlRead($Combo1) = "Text"
            $shortinputfile = ("D:\Program Files\AutoIt3\Include\autotextmain.au3")
            $codeinputfile = ("D:\Program Files\AutoIt3\Include\autotextfunctions.au3")
            $shortinputread = GUICtrlRead($Shortcut_input)
            $codeinputread = GUICtrlRead($code_input)
            $textinputread = GUICtrlRead($Combo1)
            $code_inputread = GUICtrlRead($Combo1)

            ; opening files
            FileOpen($shortinputfile, 1)
            FileOpen($codeinputfile, 1)

            ; Execute($writeshortcutfile)

            _FileWriteToLine($shortinputfile, 39, @CRLF & "HotStringSet(" & """" & $shortinputread & """" & "," & """" & $shortinputread & """" & ")", 1)



            ;Execute($writetextfile)

            $len = StringLen($shortinputread)
            FileWrite($codeinputfile, "Func " & $shortinputread & "(" & ")" & @CRLF & "send(" & """" & "{BS " & $len & "}" & """" & ")" & @CRLF & "send(" & """" & $codeinputread & """" & ")" & @CRLF & "EndFunc" & @CRLF & @CRLF)

            ; Execute closefiles

            FileClose($shortinputfile)
            FileClose($codeinputfile)


            Exit

        Case $Msg = $ok_button And GUICtrlRead($Combo1) = "Code"
            $shortinputfile = ("D:\Program Files\AutoIt3\Include\autotextmain.au3")
            $codeinputfile = ("D:\Program Files\AutoIt3\Include\autotextfunctions.au3")
            $shortinputread = GUICtrlRead($Shortcut_input)
            $codeinputread = GUICtrlRead($code_input)
            $textinputread = GUICtrlRead($Combo1)
            $code_inputread = GUICtrlRead($Combo1)

            ; opening files
            FileOpen($shortinputfile, 1)
            FileOpen($codeinputfile, 1)

            ; Execute($writeshortcutfile)

            _FileWriteToLine($shortinputfile, 39, @CRLF & "HotStringSet(" & """" & $shortinputread & """" & "," & """" & $shortinputread & """" & ")", 1)



            ;Execute($writecodefile)

            $len = StringLen($shortinputread)

            FileWrite($codeinputfile, "Func " & $shortinputread & "(" & ")" & @CRLF & "send(" & """" & "{BS " & $len & "}" & """" & ")" & @CRLF & $codeinputread & @CRLF & "EndFunc" & @CRLF & @CRLF)

            ; Execute closefiles



            FileClose($shortinputfile)
            FileClose($codeinputfile)


            Exit

    EndSelect



WEnd;### Tidy Error -> switch is never closed in your script.;### Tidy Error -> func is never closed in your script.;### Tidy Error -> case is never closed in your script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...