Sign in to follow this  
Followers 0
AutID

ControlSend/Send not working accurately

8 posts in this topic

#1 ·  Posted (edited)

So I am having this bug, don't know if someone had that before, couldn't find much with google and forum searches.

I want to send TAB to a specific window we have at work. Tab changes the value of some specific things on the window.
Now the first way I tried is ControlSend($hWND, "", "", "{TAB}"). That would normally work but in my case, it doesn't. I tried elevating scite, even though our program doesn't require admin, but still nothing. ControlSend doesn't return any error.
Then the second bad way I tried was

WinActivate($hWND)

Send("{TAB}").
Now this works once out of ten. I could run the same script 10 times and it will only work once, maybe less. 1/20 times.

I don't have any clue from which side this bug is coming from, autoit or my window.

 

Any ideas?

Edited by AutID

Share this post


Link to post
Share on other sites



Why are you using the WindowHandle in the ControlHandle parameter of ControlSend()?

Jos

Sorry about that, wrote it by hand, didn't check it in scite. I have used those commands very little in autoit. Not very big fan of those commands :/. Will edit the post.

Share this post


Link to post
Share on other sites

No clue what you are telling me there.  Just Cut&Paste what you have in your script into a codebox.
The ControlSend() now only contains a WindowHandle. You are missing the control you want to send the TAB to.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OT:

"ControlSend/Send not working accurately" is definitely not true! With this title you insinuate that the AutoIt-developers are lazy dumbasses not fixing a "bug" since years! They are NOT!

"I am not able to understand how ControlSend/Send works accurately" should be the title! 

 

BTT:

After activating a Window it is highly recommended to wait until the activation of this Window! In your example the Send("{TAB}") is executed immediately after the WinActivate($hWND)! At this time, Windows is processing the activation of the window, and nobody knows if the window is active or not. You have to ensure that the Window is active, maybe "WinWaitActive" would good to start with....

Edited by AndyG

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

No clue what you are telling me there.  Just Cut&Paste what you have in your script into a codebox.
The ControlSend() now only contains a WindowHandle. You are missing the control you want to send the TAB to.

Jos

 

The controlID doesn't have to be specified if the control has focus when the windows is activated, cases sensitive excluded.
This example will work as the original one in the examples provided from autoit(controlID not included)

Example()


Func Example()
 ; Run Notepad
 Run("notepad.exe")


 ; Wait 10 seconds for the Notepad window to appear.
 Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

 ; Wait for 2 seconds.
 Sleep(2000)

 ; Send a string of text to the edit control of Notepad. The handle returned by WinWait is used for the "title" parameter of ControlSend.
 ControlSend($hWnd, "", "", "This is some text")

 ; Wait for 2 seconds.
 Sleep(2000)

 ; Close the Notepad window using the handle returned by WinWait.
 WinClose($hWnd)

 ; Now a screen will pop up and ask to save the changes, the classname of the window is called
 ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
 WinWaitActive("[CLASS:#32770]")
 Sleep(500)
 Send("{TAB}{ENTER}")
EndFunc   ;==>Example

 

 In my case when the window is activated, my control has focus.
Now after this simpe code:

Local $hWND = WinGetHandle("title")


Sleep(3000) ;so the guy from the 5th post won't compain
ControlSend($hWND, "", "", "{TAB}")

if I simply press TAB on my keyboard, it will work like a charm. However if I add more sleep and then use Send("{TAB}") it won't work.

 

Anyway Jos this is just an explanation, no worries I found a workaround.

Edited by AutID

Share this post


Link to post
Share on other sites

OT:

"ControlSend/Send not working accurately" is definitely not true! With this title you insinuate that the AutoIt-developers are lazy dumbasses not fixing a "bug" since years! They are NOT!

"I am not able to understand how ControlSend/Send works accurately" should be the title! 

 

BTT:

After activating a Window it is highly recommended to wait until the activation of this Window! In your example the Send("{TAB}") is executed immediately after the WinActivate($hWND)! At this time, Windows is processing the activation of the window, and nobody knows if the window is active or not. You have to ensure that the Window is active, maybe "WinWaitActive" would good to start with....

I don't know if autoit developers are lazy and I can't understand why you are claiming that. To be honest; I can barely understand what you are saying.

As for what you are claiming about autoit:
Everybody can know "if the window is active or not" by using WinActive().

 

P.S. this is not facebook. If you need some attention go there or take a pet.

Share this post


Link to post
Share on other sites

ControlSetText = 99.99999% accurate...even without an active window.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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
Sign in to follow this  
Followers 0

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi friends, I have a question, please.
      I have created a window containing a edit box
      I need to know how to change the keyboard language,
      e.g :
      if a user open the  script  it will be change the keyBord language   in window automatically into English
      I found more examples but didn't work with me .
      Note:  
       I use the windows 10 os
      Please help me .
      thanks in advance to all
      with my Greetings and my appreciation for all users and admins
    • spuuunit
      By spuuunit
      This is what I'm trying to do: In Firefox, if you hold down CTRL + C for about 200ms, then press CTRL + T. This is my code:
      While WinActive(" - Mozilla Firefox") If _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Then $timer = TimerInit() While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) $diff = TimerDiff($timer) If $diff > 200 Then Send("^{T}") While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) WEnd EndIf WEnd EndIf WEnd The problem is that the CTRL key gets stuck down after Send("^{T}"). I found this, but what I understand that happens when I release, and that is not what I want. The "General unstuck method" did nothing.
    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm trying to move and resize a program call CPUID HWMonitor (http://www.cpuid.com/softwares/hwmonitor.html) but WinMove() doesn't work. Can someone tell me how to get this to work for this program? I've successfully moved other programs using WinMove(), and I've used WinGetTitle ("[ACTIVE]") to confirm the title is correct. WinActivate("CPUID HWMonitor") does work.
      If I run the following code nothing happens, doesn't move or resize, but AutoIt doesn't complain about the code either:
      WinMove("CPUID HWMonitor", 0, 0, 475, 715) The class changes every time the program opens (and I've nevery had a lot of success with classes tbh, bit hit and miss for me).
      Thanks all!
    • KemyKo
      By KemyKo
      I want to create a program that resizes and changes style/exstyles of other windows. 
      The problem is that i don`t know why my script doesn`t work.
      Here is an example:
      #RequireAdmin #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $setStyle, $getStyle, $outputString='', $getHandle, $setState $getHandle = WinGetHandle("[CLASS:Notepad]") $outputString &= $getHandle & @LF $setState = GUISetState(@SW_SHOWNORMAL, $getHandle) $outputString &= $setState & @LF $getStyle = GUIGetStyle($getHandle) If IsArray($getStyle) = 1 Then $outputString &= $getStyle[0]& ' ' &$getStyle[1]& @LF Else $outputString &= "NOTHING" & @LF EndIf $setStyle = GUISetStyle($WS_POPUPWINDOW, -1, $getHandle) $outputString &= $setStyle & @LF MsgBox(0,"OUTPUT", $outputString) It doesn`t work... At least not for me 
      I noticed that $getHandle is "0x0021023A" and AutoIt Window Info shows : "0x000000000021023A"
      I don`t know if that`s a problem . If it is, idk how to fix it 
    • Baboo85
      By Baboo85
      Hi all,
      I need to start a script that include:
      - admin privileges
      - multiple cmd commands
      - no bat, no exe, no tmp files created anywhere (especially in the user temp folder)
      In a bat file it would be simple, but users shouldn't see what commands I'm sending.
      Example of the script:
      echo off cls echo. echo I AM A TOOL echo. echo NOTE: echo - note 1 echo - note 2 echo - etc set USER1=0 set COMPUTER1=0 if /i %username% equ user.user ( set USER1=1 set COMPUTER1=1 ) if /i %username% equ another.user set USER1=1 if /i %computername% equ notebook set COMPUTER1=1 if %USER1% EQU 1 ( if %COMPUTER1% EQU 1 ( reg delete "HKLM\SOFTWARE\blablabla" /f ) else ( echo Computer not authorized. Contact assistance.) ) else ( echo User not authorized. Contact assistance.) echo. pause exit With the send("") is a disaster.
      I'm a noob here, so what can I do?
       
      EDIT: OR ELSE I explain the situation and what I need, so if there is a simple solution I can use that.
       
      SITUATION: our domain users have Users rights on the machine. Some of them need administrator rights.
      We create a local user with administrator rights, so that the users must insert username and password when asked to run something with administrator rights.
      We have an internal domain group policy that blocks EXE, BAT, COM, TMP files from the user local temp directory, for a security reason (malware). That also blocks most software installation.
      But some users are often out of office, away from workplace and in another country, they need a complete control on their computers.
       
      WHAT I NEED: I need to check the username and the computer name. If the username is the one with local administrator rights and the computer name is a computer that is qualified to temporary remove the policy, then I need to execute a REG DELETE command with administrator rights.
       
      I hope I explained myself.
       
      Thank you very much.