Jump to content
floz94

type text script with key bind

Recommended Posts

floz94

Hey, I was wondering if someone can write me a simple script that would press enter - type text - press enter again when pressed binded key,

Share this post


Link to post
Share on other sites
floz94

I'm trying to make this work, but for some reason I cant compile this, can you find why?

 

Quote

HotKeySet("{10}", "_Toggle1")

Global $Toggle1 = False

While 1
    If $Toggle1 Then SendInfo (" PM for more information. "))
    Sleep(50)
WEnd
;
Func SendInfo ($text)
    Send("{ENTER}")
    Sleep(100)
    Send($text)
    Sleep(100)
    Send("{ENTER}")
    Sleep(1000)
EndFunc   ;==>SendInfo
;
Func _Toggle1 ()
    $Toggle1 = Not $Toggle1
EndFunc   ;==>_Toggle1
;
Func _Exit ()
    Exit
EndFunc   ;==>_Exit

 

Share this post


Link to post
Share on other sites
aa2zz6
Posted (edited)

It looks like your syntax and structure is not correct. What kind of program are you trying to automate? Your current script isn't setting an active screen to write to and because it's in a while loop it'll write for ever. I'll post an example script that you can take a look at. I would recommend using the WinActive  function to activate the desired screen before using send("...") to write.

Example script:

_IsPressed Codes > https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

;
#include <Misc.au3>
#include <MsgBoxConstants.au3>

HotKeySet("{F5}", "Terminate")

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed("10", $hDLL) Then ; This is the Shift key << press to hold
        ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF)
        Run("notepad.exe")
        WinWaitActive("Untitled - Notepad")
        Send("This is some text.")
        ; Wait until key is released.
        While _IsPressed("10", $hDLL)

        WEnd
        ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF)
    ElseIf _IsPressed("1B", $hDLL) Then
        MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.")
        ExitLoop
    EndIf
    Sleep(250)
WEnd

DllClose($hDLL)

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Edited by aa2zz6

Share this post


Link to post
Share on other sites
floz94

Well I just want to find a script that will send simple msg in game, is there a one i can copy?

Share this post


Link to post
Share on other sites
aa2zz6
Just now, floz94 said:

Well I just want to find a script that will send simple msg in game, is there a one i can copy?

I don't mean to be rude but if you don't want to learn from the example and links I provided then I won't be able to help you ^^

Share this post


Link to post
Share on other sites
floz94

Anyone else can help?

Share this post


Link to post
Share on other sites
floz94

Im looking for simple script that would type for me in game previously set text once pressed the bind key

Share this post


Link to post
Share on other sites
Jos
Posted (edited)
7 hours ago, floz94 said:

Well I just want to find a script that will send simple msg in game, is there a one i can copy?

@floz94,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. (there is also a link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

Also see that patience isn't your strongest point. Make sure you get some when continuing in these forums. 

See you soon with a legitimate question I hope. :)

Jos

 

Edited by Jos

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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×