Jump to content
Sign in to follow this  
stevenfullman

Confused Newbie - What's happened to my variables?

Recommended Posts

Hi,

This is a really basic one...

When this script runs, instead of sending first name, surname & office to the notepad window, it sends 7 8 9 instead. Obviously I've done something silly, would one of you please make me embarrassed and tell me what!

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
GUICreate("User Setup", 320, 120)
GUISetState (@SW_SHOW)
GUICtrlCreateGroup("", 5, 5, 200, 100)
GUICtrlCreateLabel("First Name   : ", 10, 20)
GUICtrlCreateLabel("Last  Name   : ", 10, 50)
GUICtrlCreateLabel("Office     : ", 10, 80)
$forename = GUICtrlCreateInput("", 90, 17, 100)
$surname = GUICtrlCreateInput("", 90, 47, 100)
$office = GUICtrlCreateCombo("Please Select...", 90, 77, 100)
GUICtrlSetData(-1,"Dagenham|E London|Gravesend|Hampstead|Hornsey|Ilford|Newham|Romford|Sidcup|Willesden","Please Select...")
GUICtrlCreateGroup("", 215, 5, 100, 100)
$SendButton = GUICtrlCreateButton("&Set Me Up", 225, 20, 80, 75)
GUICtrlSetOnEvent($SendButton, "SendButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked")

While 1
    Sleep(1000)
    
WEnd

Func SendButton()
    
Dim $firstinit = StringLeft($forename, 1)
Dim $lastinit = StringLeft($Surname, 1)

Run("notepad.exe")
WinWaitActive("")
Send($forename & " " & $surname & " " & $firstinit & " " & $lastinit & @CRLF & $office) 
    
    
EndFunc

Func CloseClicked()
    
    Exit
    
EndFunc

Thanks in advance!

Steve

Share this post


Link to post
Share on other sites

$surname is the Control ID# of the Input box you created.

GuiCtrlRead($surname) is the contents of the textbox.

Send($forename & " " & GuiCtrlRead($surname) & " " & GuiCtrlRead($firstinit) & " " & GuiCtrlRead($lastinit) & @CRLF & GuiCtrlRead($office))


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

pretty simple, you need GuiCtrlRead

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
GUICreate("User Setup", 320, 120)
GUISetState (@SW_SHOW)
GUICtrlCreateGroup("", 5, 5, 200, 100)
GUICtrlCreateLabel("First Name   : ", 10, 20)
GUICtrlCreateLabel("Last  Name   : ", 10, 50)
GUICtrlCreateLabel("Office       : ", 10, 80)
$forename = GUICtrlCreateInput("", 90, 17, 100)
$surname = GUICtrlCreateInput("", 90, 47, 100)
$office = GUICtrlCreateCombo("Please Select...", 90, 77, 100)
GUICtrlSetData(-1,"Dagenham|E London|Gravesend|Hampstead|Hornsey|Ilford|Newham|Romford|Sidcup|Willesden","Please Select...")
GUICtrlCreateGroup("", 215, 5, 100, 100)
$SendButton = GUICtrlCreateButton("&Set Me Up", 225, 20, 80, 75)
GUICtrlSetOnEvent($SendButton, "SendButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked")

While 1
    Sleep(1000)
    
WEnd

Func SendButton()
    
Dim $firstinit = StringLeft(GuiCtrlRead($forename), 1)
Dim $lastinit = StringLeft(GuiCtrlRead($Surname), 1)

Run("notepad.exe")
WinWaitActive("")
Send(GuiCtrlRead ( $forename ) & " " & GuiCtrlRead ( $surname ) & " " & $firstinit & " " & $lastinit & @CRLF & GuiCtrlRead ( $office ) )    
    
    
EndFunc

Func CloseClicked()
    
    Exit
    
EndFunc

edit: Cyberslug was to fast for me

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

$surname is the Control ID# of the Input box you created.

GuiCtrlRead($surname) is the contents of the textbox.

Send($forename & " " & GuiCtrlRead($surname) & " " & GuiCtrlRead($firstinit) & " " & GuiCtrlRead($lastinit) & @CRLF & GuiCtrlRead($office))

<{POST_SNAPBACK}>

Thanks, CS!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...