Jump to content

send function variable


Recommended Posts

Hi.

So i have this variable. I want to send but it only sends the first letter or number.

HotkeySet ("{esc}", "Stop")
 
Func Stop ()
        Exit 0
EndFunc
 
 
Global $time, $add, $a, $start ,$Timedif
 
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
 
MENU()                 
Func MENU()            
GUICreate("Bella", 275, 200)
GUISetBkColor(0xaaaaaa)
GUICtrlCreateLabel("word", 30, 15)
 
$time = GUICtrlCreateinput("",30,30,100,20)
$add = GUICtrlCreateButton("Add", 150, 29, 33 )
$start = GUICtrlCreateButton("Start", 100, 150, 75,50)
 
 
GUISetState()  
    While 1            
        $msg = GUIGetMsg()
                If $msg = $GUI_EVENT_CLOSE Then ExitLoop
                If $msg = $start Then  s()
                    
    
                If $msg = $add Then Add()   
                If $msg = $add Then MsgBox(0, "Added", ($a))
wend   
    GUIDelete()        
EndFunc
 


Func Add()                                          
    $a = GUICtrlRead($time)                                                     
EndFunc  

 
Func s()   
sleep (3200)
Send("{" & $a & "}")
sleep (100)
EndFunc

I kinda tried all i know and it is not working. I was happy i finaly found it but it only sends 1 letter or number.

Send("{" & $a & "}")

this is failing me but i don't know why.

A small explanation would be nice.

thnx

Link to comment
Share on other sites

I never worked with send but this is working:

Just replace the Func s()

Func s()
sleep (3200)
$aS = StringSplit($a, "", 2) ;put all characters to an array
If IsArray($aS) Then
    For $i = 0 To UBound($aS) - 1 ;send each character from the array
        Send("{" & $aS[$i] & "}")
    Next
EndIf
sleep (100)
EndFunc

BR,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

Asdafa,

Welcome to the AutoIt forum. :mellow:

To send the {} characters, you need to include the "raw" flag - look in the Help file for more details on that.

I have also adjusted a few other bits of your code - please ask if anything I have done is unclear: :party:

; Putting includes first in a good idea
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>

HotKeySet("{esc}", "Stop")

Func Stop()
    Exit 0
EndFunc   ;==>Stop

Global $time, $add, $a, $start, $Timedif

MENU()

Func MENU()
    GUICreate("Bella", 275, 200)
    GUISetBkColor(0xaaaaaa)
    GUICtrlCreateLabel("word", 30, 15)

    $time = GUICtrlCreateInput("", 30, 30, 100, 20)
    $add = GUICtrlCreateButton("Add", 150, 29, 33)
    $start = GUICtrlCreateButton("Start", 100, 150, 75, 50)

    GUISetState()
    While 1
        ; A Switch structure is easy to maintain and less cluttered
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $start
                s()
            Case $add
                Add()
                ; You do not need {} here, you need ""
                MsgBox(0, "Added", $a)
        EndSwitch

    WEnd
    GUIDelete()
EndFunc   ;==>MENU

Func Add()
    $a = GUICtrlRead($time)
EndFunc   ;==>Add

Func s()
    Sleep(3200)
    ; Use the "raw" flag
    Send("{" & $a & "}", 1)
    Sleep(100)
EndFunc   ;==>s

I hope that is all clear. :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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