Jump to content

problems with code


Recommended Posts

i dont know how to describe it. what its meant todo is get teh text writen from gui input and put it into notepad++ but instead of doing that its just typing a 4. Here is the code

#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $iGUIWidth = 300, $iGUIHeight = 250
    Local $idEdit_1, $idOK_Btn, $idCancel_Btn, $iMsg

    #forceref $idEdit_1

    GUICreate("McNews Article Creator", $iGUIWidth, $iGUIHeight)

    $idTitle_Label = GUICtrlCreateLabel("Title", 8, 10)

    $idEdit_1 = GUICtrlCreateInput("", 5, 25, 290, 25)

    $idMain_Text = GUICtrlCreateLabel ("Text", 8, 55)

    $idEdit_2 = GUICtrlCreateEdit ("", 5, 75, 290, 125)

    $idCreate_Btn = GUICtrlCreateButton("Create", 75, 210, 70, 25)

    $idUndo_Btn = GUICtrlCreateButton("AI Editor", 165, 210, 70, 25)

    GUISetState(@SW_SHOW)

    While 1
        $iMsg = GUIGetMsg()

        Select

            Case $iMsg = $GUI_EVENT_CLOSE
                GUIDelete()
                Exit

            Case $iMsg = $idCreate_Btn
                MsgBox(64, "McNews", "Creating")

                Run(@ProgramFilesDir & '\Notepad++\notepad++.exe "C:\Users\samtan117\Desktop\Article"')

                WinWaitActive("[CLASS:Notepad++]")

                Send("{up}")
                Send("{up}")
                Send("{up}")
                Send("{up}")
                Sleep(200)
                Send("" & $idEdit_1)

            Case $iMsg = $idUndo_Btn
                ;MsgBox(64, "New GU", "You clicked on the Cancel button!")

        EndSelect

    WEnd
EndFunc

 

Link to comment
Share on other sites

  • Developers
Send(GuiRead($idEdit_1))

You need to read the control in stead of sending its handle!

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

"doesn't work" doesn't help us much. This works just fine for me:

#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $iGUIWidth = 300, $iGUIHeight = 250
    Local $idEdit_1, $idOK_Btn, $idCancel_Btn, $iMsg

    #forceref $idEdit_1

    GUICreate("McNews Article Creator", $iGUIWidth, $iGUIHeight)
    $idTitle_Label = GUICtrlCreateLabel("Title", 8, 10)
    $idEdit_1 = GUICtrlCreateInput("", 5, 25, 290, 25)
    $idMain_Text = GUICtrlCreateLabel ("Text", 8, 55)
    $idEdit_2 = GUICtrlCreateEdit ("", 5, 75, 290, 125)
    $idCreate_Btn = GUICtrlCreateButton("Create", 75, 210, 70, 25)
    $idUndo_Btn = GUICtrlCreateButton("AI Editor", 165, 210, 70, 25)
    GUISetState(@SW_SHOW)

    While 1
        $iMsg = GUIGetMsg()
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    GUIDelete()
                    Exit
                Case $iMsg = $idCreate_Btn
                    MsgBox(64, "McNews", "Creating")
                    Run(@ProgramFilesDir & '\Notepad++\notepad++.exe "C:\Users\samtan117\Desktop\Article"')
                    WinWaitActive("[CLASS:Notepad++]")
                    Send("{up}")
                    Send("{up}")
                    Send("{up}")
                    Send("{up}")
                    Sleep(200)
                    Send("" & GUICtrlRead($idEdit_1))
                Case $iMsg = $idUndo_Btn
                    ;MsgBox(64, "New GU", "You clicked on the Cancel button!")
            EndSelect
    WEnd
EndFunc

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

"doesn't work" doesn't help us much. This works just fine for me:

#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $iGUIWidth = 300, $iGUIHeight = 250
    Local $idEdit_1, $idOK_Btn, $idCancel_Btn, $iMsg

    #forceref $idEdit_1

    GUICreate("McNews Article Creator", $iGUIWidth, $iGUIHeight)
    $idTitle_Label = GUICtrlCreateLabel("Title", 8, 10)
    $idEdit_1 = GUICtrlCreateInput("", 5, 25, 290, 25)
    $idMain_Text = GUICtrlCreateLabel ("Text", 8, 55)
    $idEdit_2 = GUICtrlCreateEdit ("", 5, 75, 290, 125)
    $idCreate_Btn = GUICtrlCreateButton("Create", 75, 210, 70, 25)
    $idUndo_Btn = GUICtrlCreateButton("AI Editor", 165, 210, 70, 25)
    GUISetState(@SW_SHOW)

    While 1
        $iMsg = GUIGetMsg()
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    GUIDelete()
                    Exit
                Case $iMsg = $idCreate_Btn
                    MsgBox(64, "McNews", "Creating")
                    Run(@ProgramFilesDir & '\Notepad++\notepad++.exe "C:\Users\samtan117\Desktop\Article"')
                    WinWaitActive("[CLASS:Notepad++]")
                    Send("{up}")
                    Send("{up}")
                    Send("{up}")
                    Send("{up}")
                    Sleep(200)
                    Send("" & GUICtrlRead($idEdit_1))
                Case $iMsg = $idUndo_Btn
                    ;MsgBox(64, "New GU", "You clicked on the Cancel button!")
            EndSelect
    WEnd
EndFunc

 

​ahh perfect thankyou i types it as send("" GUICtrlRead($idEdit_1))

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...