Page 2 of 2
Re: Window Focus ?
Posted: Wed Jun 20, 2012 7:53 pm
by netmaestro
If you're on Windows, this should help. If not, not so much:
Code: Select all
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
PostMessage_(WindowID(0),#WM_SYSCOMMAND, #SC_RESTORE, 0)
SetForegroundWindow_(WindowID(0))
EndProcedure
OpenWin()
CreateThread(@max(),0)
Repeat
Until WaitWindowEvent()=#WM_CLOSE
Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:01 pm
by Nubcake
I tested your code and it still gives the same results as before but if you comment out the webgadget and set the focus in the IDE it works , what's the problem there? I'm on Windows
Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:16 pm
by IdeasVacuum
...netmaestro's code is working fine on my machine - WinXP 32bit.
Is it a problem with, say specifically Win7? What Windows are you using Nubcake?
Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:19 pm
by Nubcake
IdeasVacuum wrote:...netmaestro's code is working fine on my machine - WinXP 32bit.
Is it a problem with, say specifically Win7? What Windows are you using Nubcake?
Win 7 Ultimate 64bit - It works for you? Even with the webgadget ? did you set the focus in/on the pb window/ide
Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:28 pm
by IdeasVacuum
It works for you?
yes
Even with the webgadget ?
yes
did you set the focus in/on the pb window/ide
yes
So, are you compiling a 32bit app on 64bit windows or a 64 bit app? That might be significant.
Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:36 pm
by Nubcake
IdeasVacuum wrote:It works for you?
yes
Even with the webgadget ?
yes
did you set the focus in/on the pb window/ide
yes
So, are you compiling a 32bit app on 64bit windows or a 64 bit app? That might be significant.
32 bit

Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:50 pm
by netmaestro
Ok, another try then:
Code: Select all
Global tid
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
AttachThreadInput_(GetCurrentThreadId_(), tid, #True)
SendMessage_(WindowID(0),#WM_SYSCOMMAND, #SC_RESTORE, 0)
SetForegroundWindow_(WindowID(0))
SetFocus_(WindowID(0))
EndProcedure
OpenWin()
tid = GetCurrentThreadId_()
CreateThread(@max(),0)
Repeat
Until WaitWindowEvent()=#WM_CLOSE
Re: Window Focus ?
Posted: Wed Jun 20, 2012 8:52 pm
by Nubcake
netmaestro wrote:Ok, another try then:
Code: Select all
Global tid
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
AttachThreadInput_(GetCurrentThreadId_(), tid, #True)
SendMessage_(WindowID(0),#WM_SYSCOMMAND, #SC_RESTORE, 0)
SetForegroundWindow_(WindowID(0))
SetFocus_(WindowID(0))
EndProcedure
OpenWin()
tid = GetCurrentThreadId_()
CreateThread(@max(),0)
Repeat
Until WaitWindowEvent()=#WM_CLOSE
Doesn't work

Anyone else have this problem ?
Re: Window Focus ?
Posted: Wed Jun 20, 2012 9:03 pm
by netmaestro
Let's go postal on it then:
Code: Select all
Global tid, r
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
AttachThreadInput_(GetCurrentThreadId_(), tid, #True)
SendMessage_(WindowID(0),#WM_SYSCOMMAND, #SC_RESTORE, 0)
SetForegroundWindow_(WindowID(0))
SetFocus_(WindowID(0))
ShowCursor_(0)
GetCursorPos_(cp.POINT)
SetCursorPos_(WindowX(0)+2, WindowY(0)+2)
keybd_event_(#VK_LBUTTON,0,0,0)
keybd_event_(#VK_LBUTTON,0,#KEYEVENTF_KEYUP,0)
SetCursorPos_(cp\x, cp\y)
ShowCursor_(1)
r=1
EndProcedure
OpenWin()
tid = GetCurrentThreadId_()
CreateThread(@max(),0)
Repeat
If r
r=0
If GetFocus_() = WindowID(0)
Debug "Success"
Else
Debug "No success"
EndIf
EndIf
Until WaitWindowEvent()=#WM_CLOSE
Re: Window Focus ?
Posted: Wed Jun 20, 2012 9:06 pm
by Nubcake
netmaestro wrote:Let's go postal on it then:
Code: Select all
Global tid, r
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
AttachThreadInput_(GetCurrentThreadId_(), tid, #True)
SendMessage_(WindowID(0),#WM_SYSCOMMAND, #SC_RESTORE, 0)
SetForegroundWindow_(WindowID(0))
SetFocus_(WindowID(0))
ShowCursor_(0)
GetCursorPos_(cp.POINT)
SetCursorPos_(WindowX(0)+2, WindowY(0)+2)
keybd_event_(#VK_LBUTTON,0,0,0)
keybd_event_(#VK_LBUTTON,0,#KEYEVENTF_KEYUP,0)
SetCursorPos_(cp\x, cp\y)
ShowCursor_(1)
r=1
EndProcedure
OpenWin()
tid = GetCurrentThreadId_()
CreateThread(@max(),0)
Repeat
If r
r=0
If GetFocus_() = WindowID(0)
Debug "Success"
Else
Debug "No success"
EndIf
EndIf
Until WaitWindowEvent()=#WM_CLOSE
Success for both (when not in ide and when in ide) however when in the ide only SetForeGroundWindow() works ; the window flashes in the taskbar but is not brought up over the other windows like before.
Re: Window Focus ?
Posted: Wed Jun 20, 2012 11:50 pm
by RASHAD
See if it works for you
Code: Select all
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
SendMessage_(#HWND_BROADCAST, #WM_SYSCOMMAND, #SC_HOTKEY, WindowID(0))
EndProcedure
OpenWin()
CreateThread(@max(),0)
Repeat
Until WaitWindowEvent()=#WM_CLOSE
Re: Window Focus ?
Posted: Wed Jun 20, 2012 11:52 pm
by Nubcake
RASHAD wrote:See if it works for you
Code: Select all
Procedure OpenWin()
If OpenWindow(0,0,0,320,240,"",#PB_Window_Minimize | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(1,0,0,320,240,"")
EndIf
EndProcedure
Procedure max(a)
Delay(2000) ; <------------------- Use this time to click the IDE window bar to set focus
SendMessage_(#HWND_BROADCAST, #WM_SYSCOMMAND, #SC_HOTKEY, WindowID(0))
EndProcedure
OpenWin()
CreateThread(@max(),0)
Repeat
Until WaitWindowEvent()=#WM_CLOSE
Works! Thanks RASHAD!

Re: Window Focus ?
Posted: Wed Jun 20, 2012 11:54 pm
by IdeasVacuum
Another Rescue by Rashad!
(works on XP too)