Jump to content

Send {ENTER} works sometimes


DarkManX
 Share

Recommended Posts

Hello,

im trying to code a bot, that sends ENTER, waits 3sec and sends ENTER again. But that works just sometimes:

Hotkeyset("{F1}","startBot")
Hotkeyset("{F2}","stopBot")

Func stopBot()
    Exit;
EndFunc

Func startBot()
    Sleep(100)
    Send("{ENTER}")
    Sleep(3000)
    Send("{ENTER}")
EndFunc

While 1
    Sleep(1000)
WEnd

Sometimes it doesnt send the first, sometimes doesnt send the second ENTER. I dont know why, can somebody help pls?!

TY

Link to comment
Share on other sites

The first thing that comes to mind is that you don't know what application the {ENTER} is sent to. It depends on what has the focus at the time. And that might not be what you expect. If that's the case, I'd make sure the app I mean to get the {ENTER} has the focus at the right time with a WinActivate statement before each Send command.

Link to comment
Share on other sites

Alternatively to doing what rodent1 suggested and checking if the window is active, you could use ControlSend instead of Send and it would work even if the window isn't active. There is also a possibility that the software itself is the problem.. What program are you trying to send to?

Out of helpfiles:

ControlSend ( "title", "text", controlID, "string" [, flag] )

Link to comment
Share on other sites

Its Fifa12, i have to do always the same changes in the teamformation i want to hit just 1 button to make it. :bye:

So now i made some changes:

Func startBot()
    If WinActivate("FIFA") Then
        Sleep(3000)
        Send("{ENTER}")
        Sleep(2000)
        MsgBox(0,"","1")
    Else
        MsgBox(0,"","0")
    EndIf
Endfunc

It shows me the message 1 everytime, but doesnt sends ENTER. If i do this: Send("{ENTER}{ENTER}{ENTER}{ENTER}{ENTER}") it works sometimes, but i dont like it. there is a certain change it wont send it. What do i have to enter in controlID, i dont get it? I cant select the fifa-window via autoit window info tool, because fifa always gets fullscreen and there is no way to change it. Am I doing something wrong? Why it doesnt work? :oops:

Link to comment
Share on other sites

  • Moderators

DarkManX,

Welcome to the AutoIt forum. :bye:

Its Fifa12

Unfortunately you appear to have missed the Forum Rules on your way in. Please read them now and then you will understand why you will get no help and this thread will now be locked. :oops:

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

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...