Sign in to follow this  
Followers 0
GarrettHylltun

HotKeySet and Send help requested

5 posts in this topic

Greetings,

Any help is greatly appreciated.  I'm a bit new to AutoIT, I have the help file and some examples and started in on a little project with some success, but also having some ill effects which I'm sure is due to my lack of knowledge of AutoIT.

Trying to send some key presses to another program from a Windowed AutoIT program.  All is fine with the initial send of keys, but then that's it, I can't press my hotkey again, if I do, nothing happens.  I fear that I'm not returning to my main func from the func for my hotkey.  Or I'm just completely mucking up the code.

Could someone please look over my code and give me some hints as to what I'm possibly doing wrong?

Thanks in advance,

~Garrett

#include <GUIConstantsEx.au3>
#include <Constants.au3>
HotKeySet("!{F1}", "SendText1")

_Main()

Func _Main()
        Local $exitbutton
        GUICreate("FATE Hotkeys", 300, 200)
        $exitbutton = GUICtrlCreateButton("Exit", 220, 166, 70, 24)
        GUISetState()

        While 1
            $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitbutton
                ExitLoop
            EndSelect
        WEnd
    GUIDelete()
    Exit
EndFunc

Func SendText1()
    Local $hWnd = WinWait("[CLASS:FATE]", "", 0)
    If WinExists("[CLASS:FATE]") Then
        WinActivate($hWnd)
        Send("{LCTRL down}")
        Send("{LSHIFT down}")
        Send("{~ down}")
        Send("{LCTRL up}")
        Send("{LSHIFT up}")
        Send("{~ up}")
        Send("fame")
        sleep(10)
        Send("{ENTER down}")
        Send("{ENTER up}")
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Other than the rather odd combo of keys you're sending, I don't see anything amiss with the code.

Add some error checking, use consolewrite in various parts of the script, but not in your gui message loop.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Suggest that you read the forum rules regarding game automation.

Share this post


Link to post
Share on other sites

GarrettHylltun,

For someone who has been a member since 2005 you seem remarkably uninterested in following the Forum rules (there is also a link at bottom right of each page). :naughty:

I suggest that you read them before you post again - although since you are averaging about a post a year, perhaps you had best wait until just before you post as they may well have changed from the current set in the intervening period. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Similar Content

    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?
       

    • AndreyS
      By AndreyS
      Dear developers and creators of the language, please explain to me why when pressing the combination Crtl + Shift + C from the 5th or the 10th time "sticks / sinks" Ctrl or Shift? And then you need to press Ctrl or Shift again to reset their triggering. I only need to use hot keys like in the example!
      The code is a small example. Its essence is that when a user in the editor selects any number and presses a combination, then it increases by 1. 
      Dim $x HotKeySet("+^c","Calc") While 1 Sleep(10000) WEnd Func Calc() Send("^c") Sleep(50) $x=ClipGet()+1 ClipPut($x) Send("^v") EndFunc I thought that in my program some kind of glitch was searching for a reason for a long time. And it turned out that apparently somehow the work of some functions used in the example is not compatible. 
      Tell me, please, what is the problem?
    • ur
      By ur
      If you observe in below code.
      Func _WinWaitActivate($title,$text,$timeout=$time_out) Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc WinActivate("Untitled - Notepad") $p = "Notallowed1!!" Send("{ENTER}{ENTER}{ENTER}{ENTER}"& $p &"{ENTER}create{SPACE}database{SPACE}"& $p &";{ENTER}") In the notepad if you observe, ! is missing in the text got.
       
      Is there way to get that also printed.
    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf