kylomas Posted August 23, 2012 Share Posted August 23, 2012 (edited) Hi, I am trying to use guictrlsendtodummy with parm #2 being a variable that contains a url. guictrlsendtodummy is returning an error. guictrlsendtodummy is being invoked from an adlib routine. I've tried it both with and without parm #2 (value passed back to the dummy ctrl). The following is the code: expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <Constants.au3> ; *** End added by AutoIt3Wrapper *** #include<date.au3> #include<ie.au3> #include<array.au3> #NoTrayIcon #AutoIt3Wrapper_Add_Constants=n Opt("TrayMenuMode", 1) adlibregister("monitor_web_traffic",3000) ; create tray Local $dl0010 = TrayCreateItem("Auto Download") trayitemsetstate($dl0010,65) TrayCreateItem("") Local $exititem = TrayCreateItem("Exit") TraySetState() ; create main gui local $main010 = guicreate("") global $dummyctrl = guictrlcreatedummy() guisetstate(@SW_HIDE) local $traymsg, $main010msg While 1 $traymsg = TrayGetMsg() $main010msg = guiGetMsg() Select Case $traymsg = 0 ContinueLoop Case $traymsg = $exititem _exit() case $traymsg = $dl0010 if trayitemgetstate($dl0010) = 68 Then consolewrite("Turning auto download off" & @lf) AdlibUnRegister("monitor_web_traffic") Else consolewrite("Turning auto download on" & @lf) adlibregister("monitor_web_traffic",3000) endif case $main010msg = $dummyctrl consolewrite("dummy ctrl value at case stmt = " & guictrlread($dummyctrl) & @lf) _process_download_file(guictrlread($dummyctrl)) EndSelect Wend func _process_download_file($fl) consolewrite("Processing file = " & $fl & @lf) endfunc func monitor_web_traffic() Local $i = 1, $yt, $yl While 1 $oIE = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then exitloop $yt = _IEPropertyGet($oIE, "title") $yl = _IEPropertyGet($oIE, "locationurl") if stringinstr($yl,"[url="http://www.youtube.com/watch?v"]http://www.youtube.com/watch?v[/url]=") > 0 then consolewrite("Detected dl candidate = " & $yl & @lf) if guictrlsendtodummy($dummyctrl,$yl) = 0 then msgbox(0,"error at send to dummy","") endif $i += 1 WEnd endfunc Func _exit() Exit EndFunc ;==>_exit Also, am I handling the message loop correctly for messages from both a gui and the tray? Thanks, kylomas Edited August 23, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2012 Moderators Share Posted August 23, 2012 kylomas,Your loop looks fine to me as regards dealing with TrayGetMsg and GUIGetMsg events. Are you getting the correct URL written in the console when the dummy is fired? I ask because your StringInStr line as written is not syntactially correct - you have too many "double-quote" characters - so you might not be getting what you think you should have being passed to the dummy control. 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 Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 (edited) M23, Yes, I am getting console output for the correct url. The forum is reformatting urls for some reason. kylomas Edit: additiional info M23, no I am getting no output because the dummy control is NOT being actioned. I am getting an error in the guictrlsendtodummy statement. kylomas Edited August 23, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2012 Moderators Share Posted August 23, 2012 kylomas,And the "ConsoleWrite("Detected dl candidate = " & $yl & @LF)" line also returns the correct URL which you are trying to send to the dummy? I have never had a problem with the GUICtrlSendToDummy function - I wonder why you do. Can you please run this and see if it works for you: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cDummy = GUICtrlCreateDummy() GUISetState() AdlibRegister("_DummySend", 2000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy ConsoleWrite("Received = " & GUICtrlRead($cDummy) & @CRLF) EndSwitch WEnd Func _DummySend() $iSec = "http://url/" & @SEC & "/watch" ConsoleWrite("Sent = " & $iSec & @CRLF) GUICtrlSendToDummy($cDummy, $iSec) EndFuncM23 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 Link to comment Share on other sites More sharing options...
BrewManNH Posted August 23, 2012 Share Posted August 23, 2012 I ran the code from the OP and could not get the GUICtrlSendToDummy function to work in the script, even though it seems to be written ok. I even took the example script from the help file and inserted one of the URLs I got from this script into that code and it worked ok. It's just not working in this script and I can't see why. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 M23, First, apologies for my confused first response. I am getting correct console output from the adlib function Your code is actioning the dummy control, however, the begining of the string is being overwritten with a "0", e.h "http" turns into "0ttp". The counter is being incremented correctly. Thanks, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 @bremanNH - the code from the help doc makes NO sense to me. No matter what I click the script just ends. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted August 23, 2012 Share Posted August 23, 2012 The script is supposed to end when you click the button, if you look at the OnEvent function called from the button and the dummy control you'll see that the button sends to the dummy control, and the dummy control exits the script.I ran your script again and found that the GUICtrlSendToDummy isn't working if the GUI is hidden, when I changed the GUISetState from GUISetState(@SW_HIDE) to GUISetState(), it worked every time. I don't use the dummy control, but perhaps it doesn't like it when the GUI is hidden, no idea for sure though. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2012 Moderators Share Posted August 23, 2012 BrewManNH,GUICtrlSendToDummy isn't working if the GUI is hiddenExcellent detective work - same result here. 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2012 Moderators Share Posted August 23, 2012 kylomas, You can send a string to an input while the GUI is hidden - perhaps that will do the trick for you: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cDummy = GUICtrlCreateDummy() $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUISetState(@SW_HIDE) AdlibRegister("_DummySend", 2000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy ConsoleWrite("Received Dummy= " & GUICtrlRead($cDummy) & @CRLF) EndSwitch If StringLen(GUICtrlRead($cInput)) > 0 Then ConsoleWrite("Received Input = " & GUICtrlRead($cInput) & @CRLF) GUICtrlSetData($cInput, "") EndIf WEnd Func _DummySend() $iSec = "fred" ConsoleWrite("Sent = " & $iSec & @CRLF) GUICtrlSendToDummy($cInput, $iSec) GUICtrlSetData($cInput, $iSec) EndFunc Any help? M23 P.S. I will enquire about the dummy problem for you. 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 Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 M23, Thanks, let me play with your solution. My OP is still not working despite changing the gui to show. I am sure that I am doing something idiotic that I do not see. I think that I will go with your last example. @BrewmanNH - thanks for your input and good catch! The code that makes no sense to me is the example code from guictrlcreatedummy. The code from guictrlsendtodummy I understand. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted August 23, 2012 Share Posted August 23, 2012 OHHHHHH I almost forgot another thing. The reason the original post isn't working even with the GUI visible is because you need to move the Case $main010msg = $dummyctrl section to before you try to read from the TrayMenu sections, you have a case that if the TrayMsg is 0 to continue the loop, which skips over the Dummy control message section, because unless the tray items are being actioned, the return is always 0. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 M23, When I run your last example I do NOT action the dummy control ("Received dummy =" output not sent to console). kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 @BremanNH, Thank you, good catch again. IT now works and I'll implement M23's lat suggestioin to see if I can hide the gui. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2012 Moderators Share Posted August 23, 2012 kylomas,That was the idea - you cannot use GUICtrlSendToDummy witha hidden GUI - but you can use GUICtrlSetData on an input which gives you the same result. BrewManNH,<self/facepalm> How did I miss that! Or you could remove the following lines:Case $traymsg = 0 ContinueLoopBut as the snippet I posted showed, you really cannot use GUICtrlSendToDummywith a hidden GUI - unless I am missing something else. 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 Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 M23, I ran your last example with the guictrlsendtodummy commented out and received exactly the same results. The dummy control does not appear to be actioned. What am I missing? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2012 Moderators Share Posted August 23, 2012 kylomas, I ran your last example with the guictrlsendtodummy commented out [...] The dummy control does not appear to be actionedWell that is not really a surprise, is it! You are missing nothing - we all appear to agree that a dummy control does not get actioned when the GUI is hidden. I have asked the Devs to take a look. But you can use an input as I showed. Does that help you progress with your script in the near term? 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 Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 M23, Yes, and thank you for your patience! kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 M23, BrewmanNH, I got it to mimic actioning a dummy ocntrol using M23's input solution. This code works and I can continue developement. expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <Constants.au3> ; *** End added by AutoIt3Wrapper *** #include<date.au3> #include<ie.au3> #include<array.au3> #NoTrayIcon #AutoIt3Wrapper_Add_Constants=n Opt("TrayMenuMode", 1) adlibregister("monitor_web_traffic",3000) ; create tray Local $dl0010 = TrayCreateItem("Auto Download") trayitemsetstate($dl0010,65) TrayCreateItem("") Local $exititem = TrayCreateItem("Exit") TraySetState() ; create main gui local $main010 = guicreate("",500,500) local $inpt010 = guictrlcreateinput("", 01, 10, 200, 20) guisetstate(@sw_hide) local $traymsg, $main010msg While 1 $traymsg = TrayGetMsg() $main010msg = guiGetMsg() Select Case $traymsg = $exititem _exit() case $traymsg = $dl0010 if trayitemgetstate($dl0010) = 68 Then consolewrite("Turning auto download off" & @lf) AdlibUnRegister("monitor_web_traffic") Else consolewrite("Turning auto download on" & @lf) adlibregister("monitor_web_traffic",3000) endif EndSelect If StringLen(GUICtrlRead($inpt010)) > 0 Then ConsoleWrite("Received Input = " & GUICtrlRead($inpt010) & @CRLF) _process_download_file(guictrlread($inpt010)) GUICtrlSetData($inpt010, "") EndIf Wend func _process_download_file($fl) consolewrite("Processing file = " & $fl & @lf) endfunc func monitor_web_traffic() Local $i = 1, $yt, $yl, $ret While 1 $oIE = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then exitloop $yt = _IEPropertyGet($oIE, "title") $yl = _IEPropertyGet($oIE, "locationurl") if stringinstr($yl,"http://www.youtube.com/watch?v=") > 0 then consolewrite("Detected dl candidate = " & $yl & @lf) guictrlsetdata($inpt010,$yl) endif $i += 1 WEnd endfunc Func _exit() Exit EndFunc ;==>_exit Again, thanks kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted August 23, 2012 Author Share Posted August 23, 2012 Does anyone know why forum posted code sometimes retains formatting and sometimes does not? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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