nend Posted March 6, 2017 Share Posted March 6, 2017 (edited) Hi guys, I have used _WinAPI_SetParent to connect a window to the Windows background/desktop. #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]') Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, 100, 100, -1, $WS_EX_TOOLWINDOW) ; Attach window to the desktop (always on bottom) _WinAPI_SetParent($hForm, $hParent) GUISetState(@SW_SHOWNOACTIVATE) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE I'd used this script from the help file and a lot of time it won't show the window, the program start but the just the window won't show. If the window is not showing I pressed 2 times on the "task view" button on the Windows taskbar and it wil the show the window. I can't find logic in it when the window show or when it nog showing. I inserted in a program and a lot of people says they have the same issues. I used it on a Windows 10 64 bit Has anyone a idea why this happens? Edited March 6, 2017 by nend Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 (edited) Shows every time for me. You are aware it appears under all your other open apps right? Same OS Edited March 6, 2017 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 (edited) Yeah I'm aware of that, sometimes it works for me for me for a day or longer but when it stops working the only thing what works is to press 2 times on the "task view" button on the Windows taskbar and than it appears again. I have the same problem on 2 pc almost clean installed. Edited March 6, 2017 by nend Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 (edited) @JohnOne I found a way to reproduce the problem. Start the script and open a second virtual desktop, click on the taskview button and go to the second desktop. Close the second desktop and you wil see that the Window has disapear. If you stop the script and restart it it will not show again untill you pressed 2 times on the taskview button even when you has only one desktop. This behaviour keeps coming up until you restart window. Edited March 6, 2017 by nend Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 I confirm the issue. Weird. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 I'm curious Is this a Windows bug or has it something to do with AutoIT? Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 I suspect windows, hopefully someone might test the issue in win 7. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 (edited) I believe it to be windows. It appears that the gui is actually swallowed by the other desktop (if that's a good term) Run your test, create a new desk top and switch to it, you will see your gui. It's as though the handle to a second desktop is being reused in some weird and freaky fashion, bug if you ask me. EDIT: If I'm correct it could actually lead to a security risk, I don't believe you are supposed to be able to script across desktops, at least not without jumping through hoops. Edited March 6, 2017 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 It not only happens when you switch desktops, it would also take place a lot of time when you use 1 desktop. This was the only point I can reproduce it, but if your pc is on for a long time and your working with it it also happens. Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 (edited) Do you confirm you gui is created on a phantom desktop, then when you create a new one, it is on it? I also believe that when the window appears it is because _WinAPI_SetParent failed. Edited March 6, 2017 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 It looks like the taskview triggers the window to show. I don't think it's rendered on a other desktop. Even if I have 1 desktop it happens and when I use the taskview button it appears. Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 Looks like you simply not getting proper desktop handle. Solution... #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Local $hParent = _WinAPI_GetDesktopWindow ( ) ; <<<< Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, 100, 100, -1, $WS_EX_TOOLWINDOW) ; Attach window to the desktop (always on bottom) ConsoleWrite (_WinAPI_SetParent($hForm, $hParent) & @LF) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 (edited) I would like to say it works.... but it don't. Normally as it works the window attach to the desktop and is the lowest in the z order (except for the desktop) Now the window is vissible but the window is not attach to the desktop. That is just were I want this function for Edited March 6, 2017 by nend Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 This line sets @error Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]') Where do you even get that from? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Array.au3> ;$aWins = WinList() ;_ArrayDisplay($aWins) Local $hParent = WinGetHandle ( "[CLASS:Progman;TITLE:Program Manager]") ConsoleWrite("Error: " & @error & @LF) ConsoleWrite("Progman: " & $hParent & @LF) Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, 100, 100, -1, $WS_EX_TOOLWINDOW, $hParent) ; <<<< ;Local $oldparent = _WinAPI_SetParent($hForm, $hParent) ;ConsoleWrite("Error: " & @error & @LF) ;ConsoleWrite ("Old parent: " & $oldparent & @LF) Local $newparent = _WinAPI_GetParent($hForm) ConsoleWrite("Error: " & @error & @LF) ConsoleWrite("New parent: " & $newparent & @LF) GUISetState(@SW_SHOWNOACTIVATE) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 (edited) 32 minutes ago, JohnOne said: This line sets @error Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]') Where do you even get that from? This is from the helpfile (if you search for _WinAPI_GetParent) from AutoIT, the script at the first post in this tread comes from the helpfile. Edited March 6, 2017 by nend Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 It was erroring for me at first, but I was messing around a lot. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 I happy to see that you tryd to find the problem, I'm was allready busy with this for 2 days and I was stuck. Link to comment Share on other sites More sharing options...
JohnOne Posted March 6, 2017 Share Posted March 6, 2017 (edited) The above code makes your gui child of the handle you get in wingethandle now? The code shows it does. Edited March 6, 2017 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nend Posted March 6, 2017 Author Share Posted March 6, 2017 (edited) It returns this: Error: 0 Progman: 0x00010122 Error: 0 New parent: 0x00010122 Edited March 6, 2017 by nend 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