Jump to content
Wingens

Controlsend text

Recommended Posts

Wingens

Hi,

i am creating a hotkey script for my work.
Now i am hitting a wall, i have to be able to send a line of text using a combination of keys.
The problem i have is not in the combination but in the line of text i am trying to send.

What i am trying to send contains the symbol: !
Everytime i use my script it does send my line of text until it needs to send the !

First i tried:     
ControlSend("", "", "", "svm{$}8{4}{!}", 0)
ControlSend("", "", "", "{enter}")

Right now i changed the code to read the line of text from a ini file but still the problem.

Maybe someone has any ideas?

Share this post


Link to post
Share on other sites
Shoby

Hello Wingens,

If you state your issue briefly, We can try to help you out..

 

You have problems to read from .ini file ?

 

Share this post


Link to post
Share on other sites
Wingens

Tried the raw mode did not solve my problem.

I have no problem with reading the ini file but it sends:

svm$84

it loses the: ! at the end.

Share this post


Link to post
Share on other sites
Shoby

Wingens,

Create a ini file with Section name and Key-value format.

For example 

[Text]

Word= "The word that you want to send to ur script"

Then in your script,

Assign any variable to retrieve the text from .ini file like,

$text = IniRead (@ScriptDir & "\.ini", "Text", "Word","")

Then send this $text value to ur controlsend command

ControlSend ( "title", "text", controlID, $text)

 

Hope this will be useful for you..
 

Share this post


Link to post
Share on other sites
Shoby

Wingens,

 

Try Send("+{1}")..

Its working for me now..

Share this post


Link to post
Share on other sites
Wingens

My code right now is like that:

$var    = IniRead(@ScriptDir & "\pass.ini", "names", "pass", "")
    ControlSend("", "", "", $VAR)

Share this post


Link to post
Share on other sites
Shoby

Wingens,

 

Try this..

Controlsend("Untitled - Notepad","","[CLASS:Edit; INSTANCE:1]","svm{$}{8}{4}+{1}")

Its working for me here..

Share this post


Link to post
Share on other sites
Wingens

it does send it in a notepad or notepad ++,

but in IE it sends it differently:

svM$8$!

Somehow it chages...

Share this post


Link to post
Share on other sites
Zobengrauzis

if its IE, why no go with IE functions (_IEAttach, _IEFormElementSetValue etc).

They are more realible for tasks in thee

Share this post


Link to post
Share on other sites
Wingens

Need to read into that, don't know how that works yet...

Share this post


Link to post
Share on other sites
jvds

try
ControlSend("", "", "", "svm{$}8{4}{ASC 033}", 0)

Share this post


Link to post
Share on other sites
Wingens

The last one worked changed it a bit to between every character a sleep(50) because don't know why but some times it changes the characters is sends...

 

thx

The last one worked changed it a bit to between every character a sleep(50) because don't know why but some times it changes the characters is sends...

 

thx

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

  • Similar Content

    • ternal
      By ternal
      Hi,
      The FAQ proposed as a solution to keys getting stuck  to do this command
      ControlSend("", "", "", "text", 0) However this sends "text" to the last active control if I am not mistaken.I have tried this with
      controlsend("", "", "", "{altup}{shiftup}{ctrlup}", 0) This is already a lot better but still fails 1/10
      I cannot allow the script to send "text" to the last active control, and its a bit silly to let it send to somewhere where its harmless no?
      Are there any other methods of unstucking keys?
    • reida
      By reida
      Hello. On page there is mail address. How to keep in a text file this address? 
      It is page and email
      https://alpari.com/
      info@alpari.com
    • caramen
      By caramen
      Hey.  
       
      I requested help about how to get a value from a text in a variable. 
      Now i know how to do that. But i learned with the command FileRead. Now i whould like to know how to replace the command :
      FileRead('Dossier.txt') The purpose is to read a webpage text. To find some value inside. 
       
      Btw i tryed to play with WindowsInfo.au3 but i dont got much thing.  
    • Fortitude
      By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • therks
      By therks
      I'm trying to create a simple clock widget that automatically scales the text to the size of the window. I came up with the following method, but it doesn't work as well as I'd like. It especially has trouble scaling to the width of the window for some reason (in the example, try resizing the window to be narrow and tall).
      Does anyone have a better method?
      #include <Misc.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $_FONT_FAMILY = 'Arial', $_LB_TEXT Main() Func Main() _GDIPlus_Startup() Local $hGUI GUIRegisterMsg($WM_SIZE, WM_SIZE) $hGUI = GUICreate('', 300, 100, Default, Default, $WS_OVERLAPPEDWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $_LB_TEXT = GUICtrlCreateLabel('This is a string', 0, 0, 300, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont($_LB_TEXT, _MeasureString($hGUI, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) GUISetState() Local $iGM While 1 $iGM = GUIGetMsg() Switch $iGM Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) GUICtrlSetFont($_LB_TEXT, _MeasureString($hWnd, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) EndFunc Func _MeasureString($hWnd, $sString, $sFont = 'Arial') Local $iError, $aSize, $hGraphic, $hFormat, $hFamily, $tLayout, $iFontSize, $hFont, $aInfo If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf $aSize = WinGetClientSize($hWnd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate($sFont) $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[0], $aSize[1]) $iFontSize = 0 Do If Not $hFamily Then $iError = 1 $iFontSize = 10 ExitLoop EndIf $iFontSize += 1 $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) If $aInfo[1] = 0 Then ExitLoop Until DllStructGetData($aInfo[0], 3) >= $aSize[0] Or DllStructGetData($aInfo[0], 4) >= $aSize[1] $iFontSize -= 1 _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return SetError($iError, 0, $iFontSize) EndFunc
×