dbzfanatic Posted June 30, 2014 Share Posted June 30, 2014 (edited) Hi everyone, I'm writting a program that incorporates a few different elements (ps3netsrv and webman) and I've got most of it knocked out but I can't seem to get the menu item I added to the default system menu to call anything. Here's the script I've got so far (I'm not nearly done but the rest I can probably do once I get this menu thing fixed). expandcollapse popup#include <GUIConstants.au3> #include <Constants.au3> #include <IE.au3> #include <WinAPI.au3> #include <GUIStatusBar.au3> #include <array.au3> #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <timers.au3> $IE_Base = "192.168.1.73" dim $sStatusPrev, $sStatus, $sConsole, $sConsolePrev, $tTimer, $mnuCheck Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainWindow = GUICreate("WebManNetSrv", 680, 615, 10, 10) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetBkColor(0x00) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") $edtConsole = GUICtrlCreateEdit("",-1,381,683,215,BitOR($ES_WANTRETURN,$WS_VSCROLL,$ES_READONLY)) GUICtrlSetFont($edtConsole,10,400,"","Terminal",5) GUICtrlSetBkColor($edtConsole,0x000000) GUICtrlSetColor($edtConsole,0xC0C0C0) GUICtrlSetState($edtConsole,@SW_DISABLE) GUISetState() $pid = run(@ScriptDir & "\ps3netsrv.exe L:\ 38008 192.168.1.*","",@SW_SHOW) ProcessWait ($pid) ; get the handle of the cmd window as i cannot be certain that there will be only one instance of the cmd running with the same window title or class $cmdHandle = _ProcessGetHWnd($pid, 2) Local $hWndChild = $cmdHandle[1][1] WinSetState($hWndChild, '', @SW_HIDE) WinMove($hWndChild,"",@DesktopWidth + 120,@DesktopHeight/2) $oIE = IECreatePseudoEmbedded(0,0,680,380,$mainWindow) _IENavigate($oIE,$IE_Base) _IELoadWait($oIE) $bStatus = _GUICtrlStatusBar_Create($mainWindow) _GUICtrlStatusBar_SetMinHeight($bStatus,20) _GUICtrlStatusBar_SetText($bStatus,"Waiting...") $hMenu = _GUICtrlMenu_GetSystemMenu($mainWindow) $mnuCheck = _GUICtrlMenu_InsertMenuItem($hMenu, 6, "Check Now") ;~ $sConsole = _ConsoleCopyText($hWndChild) $tTimer = _Timer_Init() While 1 sleep(100) if TimerDiff($tTimer) >= 30000 Then $sConsole = _ConsoleCopyText($hWndChild) $tTimer = _Timer_Init() Endif If $sConsole <> $sConsolePrev Then GUICtrlSetData($edtConsole,$sConsole) $sConsolePrev = $sConsole EndIf If $sStatus <> $sStatusPrev Then _GUICtrlStatusBar_SetText($bStatus,$sStatus) $sStatusPrev = $sStatus EndIf if Ping($IE_Base) = 0 Then _GUICtrlStatusBar_SetText($bStatus,"System shutdown detected. Waiting for reboot...") Sleep(8500) _IENavigate($oIE,$IE_Base) _IELoadWait($oIE) $sStatus = "Client Offline" Else $sStatus = "Client Online" EndIf ; end of event loop WEnd Func CLOSEClicked() WinClose(WinGetTitle($hWndChild)) ProcessClose("ps3netsrv.exe") $oIE.quit $oIE.exit _IEQuit($oIE) Exit EndFunc Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) ;~ Sleep(100) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0) EndFunc ;==>WM_PAINT Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000) Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit() While 1 ; Get list of windows $aWin = WinList($sTitle) ; Searches thru all windows For $i = 1 To $aWin[0][0] ; Found a window owned by the given PID If $iPid = WinGetProcess($aWin[$i][1]) Then ; Option 0 or 1 used If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then Return $aWin[$i][1] ; Option 2 is used ElseIf $iOption = 2 Then ReDim $aReturn[UBound($aReturn) + 1][2] $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $aWin[$i][0] $aReturn[$aReturn[0][0]][1] = $aWin[$i][1] EndIf EndIf Next ; If option 2 is used and there was matches then the list is returned If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn ; If timed out then give up If TimerDiff($hTimer) > $iTimeout Then ExitLoop ; Waits before new attempt Sleep(Opt("WinWaitDelay")) WEnd ; No matches SetError(1) Return 0 EndFunc ;==>_ProcessGetHWnd Func IECreatePseudoEmbedded($i_Left, $i_Top, $i_Width, $i_Height, $h_Parent) Local $o_IE, $h_HWND $o_IE = ObjCreate("InternetExplorer.Application") $o_IE.theatermode = True $o_IE.fullscreen = True $o_IE.statusbar = False $h_HWND = _IEPropertyGet($o_IE, "hwnd") _WinAPI_SetParent($h_HWND, $h_Parent) _WinAPI_MoveWindow($h_HWND, $i_Left, $i_Top, $i_Width, $i_Height, False) _WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) Return $o_IE EndFunc ;==>IECreatePseudoEmbedded Func _ConsoleCopyText($hWin = $hWndChild) $hCurrent = WinActive("") WinActivate($hWin) ControlSend($hWin,"","","!{SPACE}") ControlSend($hWin,"","","ES") ControlSend($hWin,"","","{ENTER}") WinActivate($hCurrent) $sConsole = ClipGet() Return $sConsole EndFunc By the way, before anyone asks, yes I've tried using STDOUT_Read for the "console" and have tried joining the windows as well. STDOUT_Read doesn't return anything until the program closes and joining the windows doesn't give me the control over the console I want/need (sending messages to display on the screen) so this is what I'm left with. Edited July 1, 2014 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 30, 2014 Moderators Share Posted June 30, 2014 Everything I've read about ps3netsrv and webman has to do with streaming of games. As you've obviously been around for a while, and I am sure you are familiar with the forum rules, can you please explain a bit more about what you're trying to accomplish (and how it doesn't violate those rules)? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
dbzfanatic Posted July 1, 2014 Author Share Posted July 1, 2014 (edited) ps3netsrv is mainly used to stream games but it also allows the streaming of dvds and bluerays over a network just like a media center except a bit easier (just type in your folder and go) and it will show on your network, no dedicated media streaming server or anything and it's really low overhead so it's almost like XMBC. What I'm trying to do is keep track of which media is mounted/streamed and which ps3(s) are connected as well as the status of each. Instead of running back and forth between programs (granted it's not terribly difficult just tedious) I can look at one window and get all the info I need as well as all management options for mounting or changing the stream, restarting the ps3 if it freezes, whatever. Automation of media streaming apps isn't against the rules last time I checked and I think it'd be a lot easier to stream an ISO of my DVDs and Bluerays than getting up and changing discs every time a movie ends (my daughter is 2 and is in the "ooooo shiney" stage so this option is a real help). Yes I know there are options like vudu and I do have several movies on vudu but my net connection sucks so I want to have this second option to have some family movie time. I can't code this thing to prevent piracy the author of ps3netsrv and/or webman would have to do that but I can make the streaming easier for whatever media is chosen. Specifically with the function I've hijacked the system menu and added a "Check Now" option to it. I need to call _ConsoleCopyText($hWndChild) when that menu item is clicked. This wouldn't be an issue if it was a menu I created myself but as I've hijacked the already existing system menu it's a bit more complicated. Edited July 2, 2014 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Solution Zedna Posted July 2, 2014 Solution Share Posted July 2, 2014 (edited) This topic is still open so I hope moderators reviewed it and it's not against forum rules ... As about system menu look at my example: '?do=embed' frameborder='0' data-embedContent>> Edited July 2, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2014 Moderators Share Posted July 2, 2014 Zedna, I hope moderators reviewed itThey have now - and the thread can stay open. 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...
dbzfanatic Posted July 2, 2014 Author Share Posted July 2, 2014 Thanks Zedna that's just what I needed! Melba thanks for saying it's fine. I'll test this out in a bit and as long as it works properly I'll mark Zedna's answer as what I needed. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] 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