Sign in to follow this  
Followers 0
RalfB

MsgBox doesn't receive Send()

17 posts in this topic

Hi,

I'm writing a remote control for my media pc. IR Remote ist handled by TriggeredByExternalEvent() which translates to keyboard strokes and Send()'s them to the different programs. Problem is: when I open a MsgBox, Remote input doesn't reach to box. The routine is called as it should (DebugOutput). MsgBox has focus, normal key strokes go there.

Func TriggeredByExternalEvent()
    DebugOutput('Yes, I arrived here.')
    Send('{RIGHT}')
EndFunc

local $answer=MsgBox(4096+3,"Blabla","Question?")
 switch $answer 
   case 2 ;Cancel
    return
   case 6 ;Yes
    DoSomeFancyStuff()
   case 7 ;No/Nein => Nur FB aus
    DoSomeFancyOtherStuff()
 endswitch

Any ideas?

Ralf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi RalfB,

  And welcome to the forum !!  That is not really what MsgBox is designed for.

If you need remote input, for instance type something and see it in a message box. Take a look at InputBox.

good luck!

Bill

for instance

Local $inputVariable = InputBox("Some Input from User", "Where do you want to go today?", "", "")
MsgBox(4096, "Send me a postcard from:", $inputVariable, 3)
Edited by billo

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi RalfB

maybe you can use ControlSend instead of Send in this case

bye

Edit:

misunderstood your question
wrong answer

sorry

Edited by PincoPanco

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Hi!

Thank you for your answer.

 

 

If you need remote input, for instance type something and see it in a message box. Take a look at InputBox.

 

I don't need remote input, I need a way to handle a MsgBox remotely. (=not jumping of the couch instead do it with the IR remote ;-) )

 

MsgBox() is script blocking, as is InputBox()

Create your own gui.

Well, that work I wanted to avoid... ;-)

But MsgBox seems not to be script blocking: while being in the message box, TriggeredByExternalEvent() gets executed when IR remote is active, the debug message appears - but the Send() obviuosly doesn't come through. (Which is strange for being triggered by a hotkey (via HotKeySet), I'm able to get it done:

HotKeySet("x","TriggeredByExternalEvent")

Func TriggeredByExternalEvent() 
    DebugOutput('Yes, I arrived here.')
    Send('{RIGHT}')
EndFunc

(Like this it looked before I changed IR USB dongle to WIN-LIRC & serial interface which is more versatile.)

Share this post


Link to post
Share on other sites

I think I see the problem.

You've misspelled the debug command:

Should look like this:

From the helpfile:

#include <Debug.au3>

_DebugSetup("Check Excel")
For $i = 1 To 4
    WinActivate("Microsoft Excel")
    ; interact with Excel
    Send("{Down}")
    _DebugOut("Moved Mouse Down") <------------=======|||
Next

Bill

Share this post


Link to post
Share on other sites

:-D Sorry for confusing you:

"TriggeredByEvent" and "DebugOutput" are named differently in my programm and are homebrew functions. I just choose those names to make clear what the functions do in above script.

I think I see the problem.

You've misspelled the debug command:

Share this post


Link to post
Share on other sites

I cannot get hotkey to work while the msgbox is present in this test below. The message stack is not processed until the msgbox is closed.

HotKeySet('x', 'hotkey')

ConsoleWrite('before' & @CRLF)

MsgBox(1, 'test', 'current')

ConsoleWrite('after' & @CRLF)

Exit

Func hotkey()
    ConsoleWrite('hotkey' & @CRLF)
    WinActivate('test')
    If WinActive('test')  Then Send('{ENTER}')
EndFunc

:)

Share this post


Link to post
Share on other sites

Mhz, it seems that OP uses 2 separate programs one send() and the other (the MsgBox) receives the send()

RalfB,
If you are using 2 separate programs, as it seems from your first post, then it should work.
Maybe it doesn't because the  MsgBox has not the focus while the other program performs the send()


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Sorry, my fault.

I cannot get hotkey to work while the msgbox is present in this test below. The message stack is not processed until the msgbox is closed.

 

You are right. I was mistaken for the USB dongle I used before produces keystrokes and somehow I thought that they were processed by my script - which they weren't.

 

Mhz, it seems that OP uses 2 separate programs one send() and the other (the MsgBox) receives the send()

RalfB,
If you are using 2 separate programs, as it seems from your first post, then it should work.
Maybe it doesn't because the  MsgBox has not the focus while the other program performs the send()

This now might bring me to a quick solution: export the MsgBox to a second script and execute it from the first with Run()

Share this post


Link to post
Share on other sites

Ok, problem solved (instead of hotkey, my TriggeredByExternalEvent works too):

Hotkeyset("x","x")

func x()
        send ("n")
endfunc

func MyMsgBox($flag,$title,$text,$timeout=0,$hwnd=0)
    local $fh=FileOpen("MyMsgBox.au3",2)
    FileWriteLine($fh,"Exit(MsgBox("&$flag&",'"&$title&"','"&$text&"',"&$timeout&","&$hwnd&"))")
    FileClose($fh)
    Local $iPID = RunWait('"' & @AutoItExe & '" MyMsgBox.au3 "');
    If @error Then
            Return SetError(@error, 1, 0)
    EndIf
    return $iPID
endfunc


local $answer= MyMsgBox(4096+3,"Test","What do you answer?")

MsgBox(4096,"Answer","The answer was: "&$answer)

Thank you.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Ok, problem solved (instead of hotkey, my TriggeredByExternalEvent works too):

Hotkeyset("x","x")

func x()
        send ("n")
endfunc

func MyMsgBox($flag,$title,$text,$timeout=0,$hwnd=0)
    local $fh=FileOpen("MyMsgBox.au3",2)
    FileWriteLine($fh,"Exit(MsgBox("&$flag&",'"&$title&"','"&$text&"',"&$timeout&","&$hwnd&"))")
    FileClose($fh)
    Local $iPID = RunWait('"' & @AutoItExe & '" MyMsgBox.au3 "');
    If @error Then
            Return SetError(@error, 1, 0)
    EndIf
    return $iPID
endfunc


local $answer= MyMsgBox(4096+3,"Test","What do you answer?")

MsgBox(4096,"Answer","The answer was: "&$answer)

Thank you.

A couple things:

Since you are using RunWait, I'm not sure that you are solving the issue as you've just swapped one blocking function for another here.

Also, you do not need to create a temp file in your function for this:

Func MyMsgBox($flag, $title, $text, $timeout = 0, $hwnd = 0)
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine  "Exit(MsgBox(' & $flag & ',''' & $title & ''',''' & $text & ''',' & $timeout & ',' & $hwnd & '))"')
    If @error Then
        Return SetError(@error, 1, 0)
    EndIf
    Return $iPID
EndFunc   ;==>MyMsgBox

EDIT:  Oh I see now that you are needing a return from the messagebox, so I understand why you used RunWait there, don't know why I overlooked it at first.  I'm surprised the RunWait isn't creating the same issue that MsgBox was for you still though.

Edited by danwilli

Share this post


Link to post
Share on other sites

A couple things:

Since you are using RunWait, I'm not sure that you are solving the issue as you've just swapped one blocking function for another here.

Also, you do not need to create a temp file in your function for this:

Func MyMsgBox($flag, $title, $text, $timeout = 0, $hwnd = 0)
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine  "Exit(MsgBox(' & $flag & ',''' & $title & ''',''' & $text & ''',' & $timeout & ',' & $hwnd & '))"')
    If @error Then
        Return SetError(@error, 1, 0)
    EndIf
    Return $iPID
EndFunc   ;==>MyMsgBox

Oh I see now that you are needing a return from the messagebox, so I understand why you used RunWait there, don't know why I overlooked it at first.  I'm surprised the RunWait isn't creating the same issue that MsgBox was for you still though.

Thanks for the command line option - didn't know that one yet. :-)

RunWait works perfectly, not creating those blocking issues.

Share this post


Link to post
Share on other sites

Ok, problem solved (instead of hotkey, my TriggeredByExternalEvent works too):

Hotkeyset("x","x")

func x()
        send ("n")
endfunc

func MyMsgBox($flag,$title,$text,$timeout=0,$hwnd=0)
    local $fh=FileOpen("MyMsgBox.au3",2)
    FileWriteLine($fh,"Exit(MsgBox("&$flag&",'"&$title&"','"&$text&"',"&$timeout&","&$hwnd&"))")
    FileClose($fh)
    Local $iPID = RunWait('"' & @AutoItExe & '" MyMsgBox.au3 "');
    If @error Then
            Return SetError(@error, 1, 0)
    EndIf
    return $iPID
endfunc


local $answer= MyMsgBox(4096+3,"Test","What do you answer?")

MsgBox(4096,"Answer","The answer was: "&$answer)

Thank you.

 

Hi RalfB

instead of rewriting and overwriting everytime your msgbox in an external file you should compile only one time your function and then call the compiled function via runwait as you already do:

for example, this is the MyMsgBox.au3 script that you have to compile (just 2 lines):

If $CmdLine[0] = 5 Then Exit (MsgBox($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4], $CmdLine[5]))
Exit (-1)

and here is how you can call the compiled function (MyMsgBox.exe):

Func MyMsgBox($flag, $title, $text, $timeout = 0, $hwnd = 0)
    Local $iPID = RunWait('.\MyMsgBox.exe ' & $flag & ' ' & $title & ' ' & $text & ' ' & $timeout & ' ' & $hwnd)
    If @error Then
        Return SetError(@error, 1, 0)
    EndIf
    Return $iPID
EndFunc   ;==>MyMsgBox

bye


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

PincoPanco,

Rather then fully compile that small script, why not get it into .a3x format - much smaller and easier to FileInstall. Then you can run it using the interpreter within the main script - as long as you remember to enable this functionality with the #pragma compile(AutoItExecuteAllowed, True) directive. ;)

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

thanks Melba23, learned something new right  now
i will look into the matter :)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Thanks, I'll look into this, too.

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