RalfB Posted November 27, 2013 Posted November 27, 2013 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
l3ill Posted November 27, 2013 Posted November 27, 2013 (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 November 27, 2013 by billo My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
JohnOne Posted November 27, 2013 Posted November 27, 2013 MsgBox() is script blocking, as is InputBox() Create your own gui. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Gianni Posted November 27, 2013 Posted November 27, 2013 (edited) Hi RalfB maybe you can use ControlSend instead of Send in this case bye Edit: misunderstood your question wrong answer sorry Edited November 27, 2013 by PincoPanco Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
RalfB Posted November 27, 2013 Author Posted November 27, 2013 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.)
l3ill Posted November 27, 2013 Posted November 27, 2013 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 My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
RalfB Posted November 28, 2013 Author Posted November 28, 2013 :-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:
MHz Posted November 28, 2013 Posted November 28, 2013 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
Gianni Posted November 28, 2013 Posted November 28, 2013 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() Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
RalfB Posted November 28, 2013 Author Posted November 28, 2013 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()
RalfB Posted November 28, 2013 Author Posted November 28, 2013 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.
DW1 Posted November 28, 2013 Posted November 28, 2013 (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 November 28, 2013 by danwilli AutoIt3 Online Help
RalfB Posted November 28, 2013 Author Posted November 28, 2013 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.
Gianni Posted November 28, 2013 Posted November 28, 2013 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 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Moderators Melba23 Posted November 28, 2013 Moderators Posted November 28, 2013 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Gianni Posted November 28, 2013 Posted November 28, 2013 thanks Melba23, learned something new right now i will look into the matter Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now