randallc Posted September 19, 2006 Share Posted September 19, 2006 Hi, Can't find this in help or forum... "Wait for next Window which has focus?" anyone know the command? Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Uten Posted September 19, 2006 Share Posted September 19, 2006 WinWaitNotActive($current) ? Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
randallc Posted September 19, 2006 Author Share Posted September 19, 2006 (edited) WinWaitNotActive($current) ?are you sure? I thought there would be a gap while the next Window came up, where there would be other windows active but not necessarily be given "focus" by the application? [That makes me think; is thre a way to check when "controls" are given focus rather than windows?] Randall Edited September 19, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 19, 2006 Moderators Share Posted September 19, 2006 (edited) are you sure? I thought there would be a gap while the next Window came up, where there would be other windows active but not necessarily be given "focus" by the application? [That makes me think; is thre a way to check when "controls" are given focus rather than windows?] RandallThis is along the lines of what Uten was getting at I think, but it allows you to continue on with your script.Global $current = WinGetTitle('') While 1 If Not WinActive($current) And _ BitAND(WinGetState(WinGetHandle('')), 2) Then $current = WinGetTitle('') EndIf Sleep(10) ToolTip('Window with focus = ' & $current & @CR & _ 'Control with focus = ' & ControlGetFocus($current), 0, 0) WEnd Edit: And to answer your other question ... ControlGetFocus() would work there And if you want to change the focus, I made a udf to help there: http://www.autoitscript.com/forum/index.ph...c=32781&hl= Edited September 19, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
randallc Posted September 19, 2006 Author Share Posted September 19, 2006 Wow, Thanks SmOke_N, I haven't looked at these functions much here, but want to convert some Macro Express ones; This should do the trick; I'll give it a try. randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 19, 2006 Moderators Share Posted September 19, 2006 Wow,Thanks SmOke_N, I haven't looked at these functions much here, but want to convert some Macro Express ones; This should do the trick; I'll give it a try.randallYou keep up the work on the migrational stuff and I'm happy to do the native Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Uten Posted September 19, 2006 Share Posted September 19, 2006 Just another thought if SmOKe_N's sugestion did not get you where you wanted (I'm shure it did). The Win* family of functions suport RegExp arguments so It should be possible to write a negative RegExp listing all the windows you do not expect to have focus. As I understand it a window has focus when the tilebar has "focus" color. But I think I understand what randallc is getting at when he metions a gap. At that point I think the desktop or any of the "windows" minimized to the taskbar (including the tray) has focus. I don't think (but I'm not sure) that you will get a situation where "nothing" has "focus". Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 19, 2006 Moderators Share Posted September 19, 2006 As I understand it a window has focus when the tilebar has "focus" color. But I think I understand what randallc is getting at when he metions a gap. At that point I think the desktop or any of the "windows" minimized to the taskbar (including the tray) has focus. I don't think (but I'm not sure) that you will get a situation where "nothing" has "focus".That's what the BitAnd() and <> '' is for with mine, to make sure there is no "gap". Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
randallc Posted September 19, 2006 Author Share Posted September 19, 2006 (edited) Hi, So conversion not easy so far; So can we emulate Macro Express; do you feel like a challenge?.... Can you put that script into some udfs which do; 1. WaitControlGainFocus/WaitControlLoseFocus 2. WaitControlVisible/WaitControlNotVisible 3. WaitControlEnabled/WaitControlDisabled [Would we need opt WinMatch mode 4? ?best] best, Randall [MacroExpress GUI for writing the commands in attached Word zip] Edited September 19, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 19, 2006 Moderators Share Posted September 19, 2006 (edited) Hi, So conversion not easy so far; So can we emulate Macro Express; do you feel like a challenge?.... Can you put that script into some udfs which do; 1. WaitControlGainFocus/WaitControlLoseFocus 2. WaitControlVisible/WaitControlNotVisible 3. WaitControlEnabled/WaitControlDisabled [Would we need opt WinMatch mode 4? ?best] best, Randall [MacroExpress GUI for writing the commands in attached Word zip]Something like (For Controls): expandcollapse popupIf _IsCtrlTrue(WinGetTitle(''), 350, 1) Then MsgBox(64, 'Scintilla1', 'IsEnabled');Assuming you are opening in SciTe Func _IsCtrlTrue($hWnd, $iCID, $iCommand = 1);1 = IsEnabled, 2 = IsVisible, 3 = Has Focus Local $aCIDs = _WinGetCtrlInfo($hWnd) Local $aCommands[3] = ['', 'IsEnabled', 'IsVisible'] If IsArray($aCIDs) Then For $iCC = 1 To $aCIDs[0][0] If $aCIDs[$iCC][1] = $iCID And $iCommand < 3 Then If ControlCommand($hWnd, '', $aCIDs[$iCC][0], _ $aCommands[$iCommand], '') Then Return 1 ElseIf $aCIDs[$iCC][1] = $iCID And $iCommand = 3 Then If ControlGetFocus($hWnd) = $aCIDs[$iCC][0] Then Return 1 EndIf Next EndIf Return 0 EndFunc Func _WinGetCtrlInfo($hWin) If IsString($hWin) Then $hWin = WinGetHandle($hWin) Local $sClassList = WinGetClassList($hWin), $iAdd, $aDLL, $sHold Local $aSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $aReturn[1][2] For $iCount = $aSplitClass[0] To 1 Step - 1 Local $nCount = 0 While 1 $nCount += 1 If ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount) = '' Then ExitLoop If Not StringInStr(Chr(1) & $sHold, Chr(1) & $aSplitClass[$iCount] & $nCount & Chr(1)) Then $sHold &= $aSplitClass[$iCount] & $nCount & Chr(1) $iAdd += 1 ReDim $aReturn[$iAdd][2] $aReturn[$iAdd - 1][0] = $aSplitClass[$iCount] & $nCount $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', _ ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount)) If @error = 0 Then $aReturn[$iAdd - 1][1] = $aDLL[0] Else $aReturn[$iAdd - 1][1] = '' EndIf EndIf WEnd Next $aReturn[0][0] = $iAdd - 1 Return $aReturn EndFunc? Edit: This is on assumption you are sending a Control ID and not a ClassNameNN, you'll need to change some things up if you are doing it the other way around. Edited September 19, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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