Jump to content

ControlSend script blocking bug?


milos83
 Share

Recommended Posts

41 minutes ago, Earthshine said:

I just tested the workaround 1 that was posted above. I commented out the first line and added a declaration for the dummy. Works!!

;~ $gGUIDummy = GUICreate("")
Local $gGUIDummy
Run("notepad.exe")
$HWND = WinWait("Untitled - Notepad")
WinActivate($gGUIDummy)
ConsoleWrite("Sending..." & @CRLF)
;~ ControlSend($HWND, "", "", "!f") ;control Id 0 is the issue here
WinMenuSelectItem($hWnd,"","&File","&Save")
ConsoleWrite("sent..." & @CRLF)

I think as long as you use a valid dummy variable (not defined on the fly, EVER) it seems to work. no errors.

 

 

Can any of you mod's please move this topic to the development forum?

Link to comment
Share on other sites

yeah, I think you were just feeding it garbage and not a null variable, so this actually makes sense. Did you check the @error? and extended error info when you don't allocate a variable before using it? This is probably not a bug IMO. You can't feed things garbage memory locations and expect things to work in any language.

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

  • Developers
36 minutes ago, milos83 said:

Can any of you mod's please move this topic to the development forum?

Why? This looks like an AutoIt3 discussion.

Jos

 

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

Link to comment
Share on other sites

i think this is working properly. You can't throw out an un-allocated memory address (pointer) at a function and not expect problems. that variable is just a pointer to memory somewhere.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

1 hour ago, Earthshine said:

yeah, I think you were just feeding it garbage and not a null variable, so this actually makes sense. Did you check the @error? and extended error info when you don't allocate a variable before using it? This is probably not a bug IMO. You can't feed things garbage memory locations and expect things to work in any language.

Actually, if you look at my original post, I am sending a zero, not a variable.

You are right, we can't expect everything to work no matter what we trow at it.

I just wanted to point out an observation. Nothing critical.

 

Regards

Link to comment
Share on other sites

good luck with your scripting. BrewMan had the correct answer first. You just had to WinActivate your Notpad instance and your original code works great.

$gGUIDummy = GUICreate("")
;~ MsgBox(1, "", "GUI Windows Handle is: " & $gGUIDummy)
Run("notepad.exe")

$HWND = WinWait("Untitled - Notepad")

WinActivate($gGUIDummy)
WinActivate($HWND)
ControlSend($HWND, "", 0, "!f") ;control Id 0 is the issue here

GUICreate was giving us a valid handle, checked it. 

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

4 hours ago, Earthshine said:

good luck with your scripting. BrewMan had the correct answer first. You just had to WinActivate your Notpad instance and your original code works great.

$gGUIDummy = GUICreate("")
;~ MsgBox(1, "", "GUI Windows Handle is: " & $gGUIDummy)
Run("notepad.exe")

$HWND = WinWait("Untitled - Notepad")

WinActivate($gGUIDummy)
WinActivate($HWND)
ControlSend($HWND, "", 0, "!f") ;control Id 0 is the issue here

GUICreate was giving us a valid handle, checked it. 

 

 

On 1/17/2018 at 5:30 PM, milos83 said:

That code is showing how in certain condition the ControlSend is blocking further script execution.

You can't remove a part of code and say "Here! It doesn't block anymore!" XD

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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