Loading ...
Sorry, an error occurred while loading the content.

Re: AW: [libertybasic] GetWindowThreadProcessID

Expand Messages
  • Greg Bilik
    Stefan, Thank you very much. A few attempts ago I tried something like that because of my experience with the enumwindow callback, unfortunately I guess I had
    Message 1 of 17 , Oct 4, 2005
    • 0 Attachment
      Stefan,

      Thank you very much. A few attempts ago I tried something like that because of my experience with the enumwindow callback, unfortunately I guess I had that incorrect also.

      Thanks again.

      Greg

      pendl2megabit <pendl2megabit@...> wrote:
      Greg,
      the correct form is:
      '---code start
      struct lpdwProcessId, value as ulong

      calldll #user32,"GetWindowThreadProcessId",_
      returnedHandle as ulong,_
      lpdwProcessId as struct,_
      gwtresult as ulong

      idThread = lpdwProcessId.value.struct

      calldll #user32,"GetGUIThreadInfo",_
      idThread as ulong,_
      GUIThreadinfo as struct,_
      guires as boolean

      frmx=GUIThreadinfo.x.struct
      frmy=GUIThreadinfo.y.struct
      '---code end

      The process ID is a lpdw (=long pointer to double word), you must use a
      struct with only one member of type ulong for this.
      In general, you must use a struct or any umeric value, tht should be filled
      by the API function and is not the return parameter.

      ---
      Stefan Pendl


      -----Ursprüngliche Nachricht-----
      Von: libertybasic@yahoogroups.com

      Hi again!

      Same initial problem the API call below should end Id not ID. Some
      times I can't see the forest because I keep running into a tree.
      Anyway, got aroung the LB runtime error. However, the API call
      doesn't seem to be working as I think it should.

      Here's my dilemma as described before, pardon my repitition. I
      require a user to place the caret in the first field in a form
      generated by a thrid party web site. (They have to enter userid pw
      info anyway.) I'm trying to read the position of the caret so the
      user doesn't have to repeatedly place the caret in the first field.
      In researching MSDN I think I have found a way to do this,
      GetCaretPos doesn't work, as discussed with Stefan and Alyce.

      According to MSDN the GetGUIThreadInfo API should provide this
      information. Here's a little on that API from MSDN:

      ---snip

      *** I'm trying to use the left and top values

      As you can see, it requires the identifier of the thread you want the
      information for. To get this use the GetWindowThreadProcessId API,
      which I am doing. (The MSDN explanation is in the email below.)

      Here is my LB code used to return the information:

      calldll #user32,"GetWindowThreadProcessId",_
      returnedHandle as ulong,_
      id as long,_
      gwtresult as long

      calldll #user32,"GetGUIThreadInfo",_
      gwtresult as long,_
      GUIThreadinfo as struct,_
      guires as boolean
      frmx=GUIThreadinfo.x.struct
      frmy=GUIThreadinfo.y.struct

      I fairly confident I'm using a valid gwtresult because I've printed
      the value out. When I keep the same window open with the form the
      value stays constant. When I close this window and open it again, I
      get a new value for gtwresult which in my mind is consistent. The
      problem is the x and y values I get don't seem to change ifI call the
      GetWindowThreadProcessId API or not. Which implies to me that
      GetGUIThreadInfo is returning the information for the foreground
      thread and not the one I am providing to it.

      Has anyone tried to do something like this or have a better
      understanding of these two API's than I seem to have.

      I appreciate any help, guidance, prayers or anything that may be
      helpful.

      Thanks.

      Greg






      ___________________________________________________________
      Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de




      Yahoo! Groups Links








      ---------------------------------
      Yahoo! for Good
      Click here to donate to the Hurricane Katrina relief effort.

      [Non-text portions of this message have been removed]
    • Greg Bilik
      Hey Stefan, Now that I m back on my computer I am able to try the code you sent. It seems to be working fine, thanks again for the correction. However, the
      Message 2 of 17 , Oct 4, 2005
      • 0 Attachment
        Hey Stefan,

        Now that I'm back on my computer I am able to try the code you sent. It seems to be working fine, thanks again for the correction. However, the results it's providing are at best confusing. Maybe if I give a little detail to the sequence of events and the code again, you or someone may be able to point to my brain cramp.

        1. I open my IE browser from the desktop and log into the website where the form I need to fill out exists and place the caret in the first field of the form.

        2. I open LB, since I am still coding, and load the program I am working on, also from the desktop.

        3. I run the program. I think these steps are important because of Windows threads and processes, of which I know I don't know enough.

        In the program I have the following code:

        returnedHandle is the handle of my IE window from the enumWndProc callback function

        calldll #user32, "SetFocus",_
        returnedHandle as ulong,_
        result as long

        if frsttime<>0 then [skipcurs]

        calldll #user32,"GetWindowThreadProcessId",_
        returnedHandle as ulong,_
        ProcId as struct,_
        gwtresult as ulong
        idThread = ProcId.value.struct

        calldll #user32,"GetGUIThreadInfo",_
        idThread as ulong,_
        GUIThreadinfo as struct,_
        guires as boolean
        frmx=GUIThreadinfo.x.struct
        frmy=GUIThreadinfo.y.struct

        When I execute this code the results of some of the variables returned in GUIThreadinfo are:

        Using idThread in GetGUIThreadInfo call
        idThread-380 Caret-0 returnedHandle-131586
        Active-0 Focus-0 GetWindThreadProcID result-1152
        x-0
        y-0
        Right-0
        Bottom-0

        My problem with these results is that at least Focus which is the handle of the window that has the kybd focus should = returnedHandle, since I just set the focus there. However when the code continues the program writes the data I have in a test file correctly, starting at the first field in the form on the website.
        the next time through the form the above code is skipped and the following code is executed:

        mseInp.dx.struct=x
        mseInp.dy.struct=y
        mseInp.dwFlags.struct=32768
        call sendmouse 'put mouse at previous spot
        mseInp.dx.struct=0
        mseInp.dy.struct=0
        mseInp.dwFlags.struct=2
        call sendmouse 'left button down
        mseInp.dx.struct=0
        mseInp.dy.struct=0
        mseInp.dwFlags.struct=4
        call sendmouse 'left button up

        this code should move the mouse to the coorinates and do a left click down and up. I have shortened the x and y leaving out the struct information.

        This kind of works except that the continuing data in the file begins writing at the first field of the third row of the form. Which happens to coincide with the location of the continue button on my executing programs window. (dumb luck - if I move my execution window the data is written below wherever the cursor was when CONTINUE was clicked.)

        Now, if I change the GetGUIThreadInfo call as follows:

        calldll #user32,"GetGUIThreadInfo",_
        gwtresult as ulong,_
        GUIThreadinfo as struct,_
        guires as boolean

        where gwtresult is the result from the GetWindowThreadProcessId, I get the following:

        Using gwtresult in GetGUIThreadInfo call
        idThread-380 Caret-131534 returnedHandle-131586
        Active-131586 Focus-131534 GetWindThreadProcID result-1152
        x-222
        y-341
        Right-223
        Bottom-357

        Now, at least Focus is different but it is still not returnedHandle as I think it should be because of the SetFocu call.

        As for the continuation of this run, it behave exactly as if I used idThread in the GetGUIThreadInfo call, i.e. the data the second time through is written directly below my CONTINUE button in the program. At least with this I think I understand where x and y are coming from, although I'm not too sure about that either.

        Maybe by writing all this out I'll think of something. I'll keep trying anyway. Any thoughts you or anyone has would be greatly appreciated.

        Thanks.

        Greg


        pendl2megabit
        wrote:
        Greg,
        the correct form is:
        '---code start
        struct lpdwProcessId, value as ulong

        calldll #user32,"GetWindowThreadProcessId",_
        returnedHandle as ulong,_
        lpdwProcessId as struct,_
        gwtresult as ulong

        idThread = lpdwProcessId.value.struct

        calldll #user32,"GetGUIThreadInfo",_
        idThread as ulong,_
        GUIThreadinfo as struct,_
        guires as boolean

        frmx=GUIThreadinfo.x.struct
        frmy=GUIThreadinfo.y.struct
        '---code end

        The process ID is a lpdw (=long pointer to double word), you must use a
        struct with only one member of type ulong for this.
        In general, you must use a struct or any umeric value, tht should be filled
        by the API function and is not the return parameter.

        ---
        Stefan Pendl


        -----Ursprüngliche Nachricht-----



        ---------------------------------
        Yahoo! for Good
        Click here to donate to the Hurricane Katrina relief effort.

        [Non-text portions of this message have been removed]
      • pendl2megabit
        Greg, generated a test code myself to check this out. You have been right about the result of GetWindowThreadProcessId being the ID needed :-(Seems that we
        Message 3 of 17 , Oct 4, 2005
        • 0 Attachment
          Greg,
          generated a test code myself to check this out.
          You have been right about the result of GetWindowThreadProcessId being the
          ID needed :-(

          Seems that we have a problem when the web page contains frames, because the
          returned coordinates are in respect to the client window, not to the main
          window.

          I used the following code with various web sites.

          There seems to be some work left.

          ---
          Stefan Pendl

          '---code start
          struct GUIThreadInfo, _
          cbSize as ulong, _
          flags as ulong, _
          hwndActive as ulong, _
          hwndFocus as ulong, _
          hwndCapture as ulong, _
          hwndMenuOwner as ulong, _
          hwndMoveSize as ulong, _
          hwndCaret as ulong, _
          left as long, _
          top as long, _
          right as long, _
          bottom as long

          struct Rect, _
          left as long, _
          top as long, _
          right as long, _
          bottom as long

          struct WindowHandle, value as ulong
          struct WindowTitle, value$ as ptr
          struct lpdwProcessId, value as ulong

          callback lpEnumFunc, EnumWindowsProc(handle, ulong), boolean

          WindowTitle.value$.struct = "Microsoft Internet Explorer"

          calldll #user32, "EnumWindows", _
          lpEnumFunc as ulong, _
          lParam$ as ptr, _
          result as boolean

          WindowHandle = WindowHandle.value.struct

          print "GetActiveWindow handle: "; WindowHandle
          print

          calldll #user32, "BringWindowToTop", _
          WindowHandle as ulong, _
          result as boolean

          if result = 0 then call DisplayError

          calldll #user32, "GetWindowThreadProcessId", _
          WindowHandle as ulong, _
          lpdwProcessId as struct, _
          idThread as ulong

          print "GetWindowThreadProcessId result: "; idThread
          print

          GUIThreadInfo.cbSize.struct = len(GUIThreadInfo.struct)

          calldll #user32, "GetGUIThreadInfo", _
          idThread as ulong, _
          GUIThreadInfo as struct, _
          result as boolean

          print "GetGUIThreadInfo result: "; result
          print

          if result = 0 then
          call DisplayError
          else
          print "cbSize: "; GUIThreadInfo.cbSize.struct
          print "flags: "; GUIThreadInfo.flags.struct
          print "hwndActive: "; GUIThreadInfo.hwndActive.struct
          print "hwndFocus: "; GUIThreadInfo.hwndFocus.struct
          print "hwndCapture: "; GUIThreadInfo.hwndCapture.struct
          print "hwndMenuOwner: "; GUIThreadInfo.hwndMenuOwner.struct
          print "hwndMoveSize: "; GUIThreadInfo.hwndMoveSize.struct
          print "hwndCaret: "; GUIThreadInfo.hwndCaret.struct
          print "left: "; GUIThreadInfo.left.struct
          print "top: "; GUIThreadInfo.top.struct
          print "right: "; GUIThreadInfo.right.struct
          print "bottom: "; GUIThreadInfo.bottom.struct
          print

          CaretX = int((GUIThreadInfo.right.struct +
          GUIThreadInfo.left.struct) / 2)
          CaretY = int((GUIThreadInfo.bottom.struct +
          GUIThreadInfo.top.struct) / 2)

          WindowHandle = GUIThreadInfo.hwndCaret.struct

          calldll #user32, "GetWindowRect", _
          WindowHandle as ulong, _
          Rect as struct, _
          result as boolean

          print "GetWindowRect result: "; result
          print

          if result = 0 then
          call DisplayError
          else
          print "left: "; Rect.left.struct
          print "top: "; Rect.top.struct
          print "right: "; Rect.right.struct
          print "bottom: "; Rect.bottom.struct
          print
          end if

          PosX = Rect.left.struct + CaretX
          PosY = Rect.top.struct + CaretY

          calldll #user32, "SetCursorPos", _
          PosX as long, _
          PosY as long, _
          result as boolean

          if result = 0 then call DisplayError
          end if

          print "Finished ..."
          end

          function EnumWindowsProc(Handle, lParam)
          nMaxCount = 1024
          lpString$ = space$(nMaxCount); chr$(0)

          calldll #user32, "GetWindowTextA", _
          Handle as ulong, _
          lpString$ as ptr, _
          nMaxCount as ulong, _
          result as ulong

          Caption$ = upper$(left$(lpString$, result))
          SearchString$ = upper$(winstring(WindowTitle.value$.struct))

          if instr(Caption$, SearchString$) then
          WindowHandle.value.struct = Handle
          EnumWindowsProc = 0
          else
          EnumWindowsProc = 1
          end if
          end function

          sub DisplayError
          calldll #kernel32, "GetLastError", _
          ErrorCode as ulong

          dwFlags = _FORMAT_MESSAGE_FROM_SYSTEM
          nSize = 1024
          lpBuffer$ = space$(nSize); chr$(0)
          dwMessageID = ErrorCode

          calldll #kernel32, "FormatMessageA", _
          dwFlags as ulong, _
          lpSource as ulong, _
          dwMessageID as ulong, _
          dwLanguageID as ulong, _
          lpBuffer$ as ptr, _
          nSize as ulong, _
          Arguments as ulong, _
          result as ulong

          print "Error "; ErrorCode; ": "; left$(lpBuffer$, result)
          end sub
          '---code end


          -----Ursprüngliche Nachricht-----
          Von: libertybasic@yahoogroups.com

          Hey Stefan,

          Now that I'm back on my computer I am able to try the code you sent. It
          seems to be working fine, thanks again for the correction. However, the
          results it's providing are at best confusing. Maybe if I give a little
          detail to the sequence of events and the code again, you or someone may be
          able to point to my brain cramp.

          1. I open my IE browser from the desktop and log into the website where the
          form I need to fill out exists and place the caret in the first field of the
          form.

          2. I open LB, since I am still coding, and load the program I am working on,
          also from the desktop.

          3. I run the program. I think these steps are important because of Windows
          threads and processes, of which I know I don't know enough.

          In the program I have the following code:

          returnedHandle is the handle of my IE window from the enumWndProc callback
          function

          calldll #user32, "SetFocus",_
          returnedHandle as ulong,_
          result as long

          if frsttime<>0 then [skipcurs]

          calldll #user32,"GetWindowThreadProcessId",_
          returnedHandle as ulong,_
          ProcId as struct,_
          gwtresult as ulong
          idThread = ProcId.value.struct

          calldll #user32,"GetGUIThreadInfo",_
          idThread as ulong,_
          GUIThreadinfo as struct,_
          guires as boolean
          frmx=GUIThreadinfo.x.struct
          frmy=GUIThreadinfo.y.struct

          When I execute this code the results of some of the variables returned in
          GUIThreadinfo are:

          Using idThread in GetGUIThreadInfo call
          idThread-380 Caret-0 returnedHandle-131586
          Active-0 Focus-0 GetWindThreadProcID result-1152
          x-0
          y-0
          Right-0
          Bottom-0

          My problem with these results is that at least Focus which is the handle of
          the window that has the kybd focus should = returnedHandle, since I just set
          the focus there. However when the code continues the program writes the
          data I have in a test file correctly, starting at the first field in the
          form on the website.
          the next time through the form the above code is skipped and the following
          code is executed:

          mseInp.dx.struct=x
          mseInp.dy.struct=y
          mseInp.dwFlags.struct=32768
          call sendmouse 'put mouse at
          previous spot
          mseInp.dx.struct=0
          mseInp.dy.struct=0
          mseInp.dwFlags.struct=2
          call sendmouse 'left button down
          mseInp.dx.struct=0
          mseInp.dy.struct=0
          mseInp.dwFlags.struct=4
          call sendmouse 'left button up

          this code should move the mouse to the coorinates and do a left click down
          and up. I have shortened the x and y leaving out the struct information.

          This kind of works except that the continuing data in the file begins
          writing at the first field of the third row of the form. Which happens to
          coincide with the location of the continue button on my executing programs
          window. (dumb luck - if I move my execution window the data is written
          below wherever the cursor was when CONTINUE was clicked.)

          Now, if I change the GetGUIThreadInfo call as follows:

          calldll #user32,"GetGUIThreadInfo",_
          gwtresult as ulong,_
          GUIThreadinfo as struct,_
          guires as boolean

          where gwtresult is the result from the GetWindowThreadProcessId, I get the
          following:

          Using gwtresult in GetGUIThreadInfo call
          idThread-380 Caret-131534 returnedHandle-131586
          Active-131586 Focus-131534 GetWindThreadProcID result-1152
          x-222
          y-341
          Right-223
          Bottom-357

          Now, at least Focus is different but it is still not returnedHandle as I
          think it should be because of the SetFocu call.

          As for the continuation of this run, it behave exactly as if I used idThread
          in the GetGUIThreadInfo call, i.e. the data the second time through is
          written directly below my CONTINUE button in the program. At least with
          this I think I understand where x and y are coming from, although I'm not
          too sure about that either.

          Maybe by writing all this out I'll think of something. I'll keep trying
          anyway. Any thoughts you or anyone has would be greatly appreciated.

          Thanks.

          Greg



          ___________________________________________________________
          Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx
        • Greg Bilik
          Stefan, Thanks for looking into this. I m pretty sure there is a way to get the information about the browser window. I thought GetGUIThreadInfo was it.
          Message 4 of 17 , Oct 5, 2005
          • 0 Attachment
            Stefan,

            Thanks for looking into this. I'm pretty sure there is a way to get the information about the browser window. I thought GetGUIThreadInfo was it. I'll keep looking and trying and post anything I come up with.

            Thanks again.

            Greg

            pendl2megabit <pendl2megabit@...> wrote:
            Greg,
            generated a test code myself to check this out.
            You have been right about the result of GetWindowThreadProcessId being the
            ID needed :-(

            Seems that we have a problem when the web page contains frames, because the
            returned coordinates are in respect to the client window, not to the main
            window.

            I used the following code with various web sites.

            There seems to be some work left.

            ---
            Stefan Pendl

            '---code start
            struct GUIThreadInfo, _
            cbSize as ulong, _
            flags as ulong, _
            hwndActive as ulong, _
            hwndFocus as ulong, _
            hwndCapture as ulong, _
            hwndMenuOwner as ulong, _
            hwndMoveSize as ulong, _
            hwndCaret as ulong, _
            left as long, _
            top as long, _
            right as long, _
            bottom as long

            struct Rect, _
            left as long, _
            top as long, _
            right as long, _
            bottom as long

            struct WindowHandle, value as ulong
            struct WindowTitle, value$ as ptr
            struct lpdwProcessId, value as ulong

            callback lpEnumFunc, EnumWindowsProc(handle, ulong), boolean

            WindowTitle.value$.struct = "Microsoft Internet Explorer"

            calldll #user32, "EnumWindows", _
            lpEnumFunc as ulong, _
            lParam$ as ptr, _
            result as boolean

            WindowHandle = WindowHandle.value.struct

            print "GetActiveWindow handle: "; WindowHandle
            print

            calldll #user32, "BringWindowToTop", _
            WindowHandle as ulong, _
            result as boolean

            if result = 0 then call DisplayError

            calldll #user32, "GetWindowThreadProcessId", _
            WindowHandle as ulong, _
            lpdwProcessId as struct, _
            idThread as ulong

            print "GetWindowThreadProcessId result: "; idThread
            print

            GUIThreadInfo.cbSize.struct = len(GUIThreadInfo.struct)

            calldll #user32, "GetGUIThreadInfo", _
            idThread as ulong, _
            GUIThreadInfo as struct, _
            result as boolean

            print "GetGUIThreadInfo result: "; result
            print

            if result = 0 then
            call DisplayError
            else
            print "cbSize: "; GUIThreadInfo.cbSize.struct
            print "flags: "; GUIThreadInfo.flags.struct
            print "hwndActive: "; GUIThreadInfo.hwndActive.struct
            print "hwndFocus: "; GUIThreadInfo.hwndFocus.struct
            print "hwndCapture: "; GUIThreadInfo.hwndCapture.struct
            print "hwndMenuOwner: "; GUIThreadInfo.hwndMenuOwner.struct
            print "hwndMoveSize: "; GUIThreadInfo.hwndMoveSize.struct
            print "hwndCaret: "; GUIThreadInfo.hwndCaret.struct
            print "left: "; GUIThreadInfo.left.struct
            print "top: "; GUIThreadInfo.top.struct
            print "right: "; GUIThreadInfo.right.struct
            print "bottom: "; GUIThreadInfo.bottom.struct
            print

            CaretX = int((GUIThreadInfo.right.struct +
            GUIThreadInfo.left.struct) / 2)
            CaretY = int((GUIThreadInfo.bottom.struct +
            GUIThreadInfo.top.struct) / 2)

            WindowHandle = GUIThreadInfo.hwndCaret.struct

            calldll #user32, "GetWindowRect", _
            WindowHandle as ulong, _
            Rect as struct, _
            result as boolean

            print "GetWindowRect result: "; result
            print

            if result = 0 then
            call DisplayError
            else
            print "left: "; Rect.left.struct
            print "top: "; Rect.top.struct
            print "right: "; Rect.right.struct
            print "bottom: "; Rect.bottom.struct
            print
            end if

            PosX = Rect.left.struct + CaretX
            PosY = Rect.top.struct + CaretY

            calldll #user32, "SetCursorPos", _
            PosX as long, _
            PosY as long, _
            result as boolean

            if result = 0 then call DisplayError
            end if

            print "Finished ..."
            end

            function EnumWindowsProc(Handle, lParam)
            nMaxCount = 1024
            lpString$ = space$(nMaxCount); chr$(0)

            calldll #user32, "GetWindowTextA", _
            Handle as ulong, _
            lpString$ as ptr, _
            nMaxCount as ulong, _
            result as ulong

            Caption$ = upper$(left$(lpString$, result))
            SearchString$ = upper$(winstring(WindowTitle.value$.struct))

            if instr(Caption$, SearchString$) then
            WindowHandle.value.struct = Handle
            EnumWindowsProc = 0
            else
            EnumWindowsProc = 1
            end if
            end function

            sub DisplayError
            calldll #kernel32, "GetLastError", _
            ErrorCode as ulong

            dwFlags = _FORMAT_MESSAGE_FROM_SYSTEM
            nSize = 1024
            lpBuffer$ = space$(nSize); chr$(0)
            dwMessageID = ErrorCode

            calldll #kernel32, "FormatMessageA", _
            dwFlags as ulong, _
            lpSource as ulong, _
            dwMessageID as ulong, _
            dwLanguageID as ulong, _
            lpBuffer$ as ptr, _
            nSize as ulong, _
            Arguments as ulong, _
            result as ulong

            print "Error "; ErrorCode; ": "; left$(lpBuffer$, result)
            end sub
            '---code end


            -----Ursprüngliche Nachricht-----
            Von: libertybasic@yahoogroups.com

            Hey Stefan,

            Now that I'm back on my computer I am able to try the code you sent. It
            seems to be working fine, thanks again for the correction. However, the
            results it's providing are at best confusing. Maybe if I give a little
            detail to the sequence of events and the code again, you or someone may be
            able to point to my brain cramp.

            1. I open my IE browser from the desktop and log into the website where the
            form I need to fill out exists and place the caret in the first field of the
            form.

            2. I open LB, since I am still coding, and load the program I am working on,
            also from the desktop.

            3. I run the program. I think these steps are important because of Windows
            threads and processes, of which I know I don't know enough.

            In the program I have the following code:

            returnedHandle is the handle of my IE window from the enumWndProc callback
            function

            calldll #user32, "SetFocus",_
            returnedHandle as ulong,_
            result as long

            if frsttime<>0 then [skipcurs]

            calldll #user32,"GetWindowThreadProcessId",_
            returnedHandle as ulong,_
            ProcId as struct,_
            gwtresult as ulong
            idThread = ProcId.value.struct

            calldll #user32,"GetGUIThreadInfo",_
            idThread as ulong,_
            GUIThreadinfo as struct,_
            guires as boolean
            frmx=GUIThreadinfo.x.struct
            frmy=GUIThreadinfo.y.struct

            When I execute this code the results of some of the variables returned in
            GUIThreadinfo are:

            Using idThread in GetGUIThreadInfo call
            idThread-380 Caret-0 returnedHandle-131586
            Active-0 Focus-0 GetWindThreadProcID result-1152
            x-0
            y-0
            Right-0
            Bottom-0

            My problem with these results is that at least Focus which is the handle of
            the window that has the kybd focus should = returnedHandle, since I just set
            the focus there. However when the code continues the program writes the
            data I have in a test file correctly, starting at the first field in the
            form on the website.
            the next time through the form the above code is skipped and the following
            code is executed:

            mseInp.dx.struct=x
            mseInp.dy.struct=y
            mseInp.dwFlags.struct=32768
            call sendmouse 'put mouse at
            previous spot
            mseInp.dx.struct=0
            mseInp.dy.struct=0
            mseInp.dwFlags.struct=2
            call sendmouse 'left button down
            mseInp.dx.struct=0
            mseInp.dy.struct=0
            mseInp.dwFlags.struct=4
            call sendmouse 'left button up

            this code should move the mouse to the coorinates and do a left click down
            and up. I have shortened the x and y leaving out the struct information.

            This kind of works except that the continuing data in the file begins
            writing at the first field of the third row of the form. Which happens to
            coincide with the location of the continue button on my executing programs
            window. (dumb luck - if I move my execution window the data is written
            below wherever the cursor was when CONTINUE was clicked.)

            Now, if I change the GetGUIThreadInfo call as follows:

            calldll #user32,"GetGUIThreadInfo",_
            gwtresult as ulong,_
            GUIThreadinfo as struct,_
            guires as boolean

            where gwtresult is the result from the GetWindowThreadProcessId, I get the
            following:

            Using gwtresult in GetGUIThreadInfo call
            idThread-380 Caret-131534 returnedHandle-131586
            Active-131586 Focus-131534 GetWindThreadProcID result-1152
            x-222
            y-341
            Right-223
            Bottom-357

            Now, at least Focus is different but it is still not returnedHandle as I
            think it should be because of the SetFocu call.

            As for the continuation of this run, it behave exactly as if I used idThread
            in the GetGUIThreadInfo call, i.e. the data the second time through is
            written directly below my CONTINUE button in the program. At least with
            this I think I understand where x and y are coming from, although I'm not
            too sure about that either.

            Maybe by writing all this out I'll think of something. I'll keep trying
            anyway. Any thoughts you or anyone has would be greatly appreciated.

            Thanks.

            Greg



            ___________________________________________________________
            Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx




            Yahoo! Groups Links








            ---------------------------------
            Yahoo! for Good
            Click here to donate to the Hurricane Katrina relief effort.

            [Non-text portions of this message have been removed]
          • Greg Bilik
            Stefan, I believe I am a little closer to understanding what is going on with this, not quite there yet, but closer. Apparently, there is something related to
            Message 5 of 17 , Oct 5, 2005
            • 0 Attachment
              Stefan,

              I believe I am a little closer to understanding what is going on with this, not quite there yet, but closer. Apparently, there is something related to the SendInput command for a mouse that I really don't quite understand. I copied my GetGUIThreadInfo and related print code to the section where I try to move the mouse and click it. It seems that I am successfully sending the mouse messages into the queue, Mouse Result-1 below means that 1 event was inserted into the queue. Unfortunately, I don't know which queue. As you can see the Mouse handle, hwndCapture from GUIThreadInfo is 0. According to MSDN that is the handle of the window that has captured the mouse. Here is the info from the last run of my code:

              GetCurrentThreadId result 2-3828
              Using gwtresult in GetGUIThreadInfo call
              Thread-3708 Caret-2294236 Returned-328110
              Active-328110 Focus-2294236 GetWindThreadProcID res-3132
              Mouse handle-0
              x-222
              y-323
              Right-223
              Bottom-357
              GetCurrentThreadId result 1-3828
              Mouse Result-1
              Mouse Result-1
              Mouse Result-1
              GetCurrentThreadId result 2-3828
              Using gwtresult in GetGUIThreadInfo call
              Thread-3708 Caret-2294236 Returned-328110
              Active-328110 Focus-2294236 GetWindThreadProcID res-3132
              Mouse handle-0
              x-222
              y-322
              Right-372
              Bottom-456

              The x and y values, which is what I am using to move the mouse have been manipulated by me to see what would happen. The first time I ran this code, the second value for x was 371 and y was 323. Then I subtracted the difference from the original x and y, 149 for x and 133 for y. As you can see the x and y parameters are pretty much equal to the original x and y values. However, that changed nothing in the execution of the program. The data still begins to write on the form directly below where I click on the continue box in my program. Apparently, I am not moving the mouse relative to the form page. I'm still a bit confused but at least I think I understand a little more. If you or anyone have any ideas, please feel free to chime in. Sometimes it helps if I have to put into words what is happening and there aren't too many people around here who understand what I'm talking about.

              Also, the value of IdThread, Thread above, 3708, which is the output field of GetWindowThreadProcessId is the process ID of the Internet Explorer process. I checked task manager, processes tab, to find this out. At least some things make sense.

              Thanks.

              Greg

              pendl2megabit <pendl2megabit@...> wrote:
              Greg,
              generated a test code myself to check this out.
              You have been right about the result of GetWindowThreadProcessId being the
              ID needed :-(

              Seems that we have a problem when the web page contains frames, because the
              returned coordinates are in respect to the client window, not to the main
              window.

              I used the following code with various web sites.

              There seems to be some work left.

              ---
              Stefan Pendl

              '---code start
              struct GUIThreadInfo, _
              cbSize as ulong, _
              flags as ulong, _
              hwndActive as ulong, _
              hwndFocus as ulong, _
              hwndCapture as ulong, _
              hwndMenuOwner as ulong, _
              hwndMoveSize as ulong, _
              hwndCaret as ulong, _
              left as long, _
              top as long, _
              right as long, _
              bottom as long

              struct Rect, _
              left as long, _
              top as long, _
              right as long, _
              bottom as long

              struct WindowHandle, value as ulong
              struct WindowTitle, value$ as ptr
              struct lpdwProcessId, value as ulong

              callback lpEnumFunc, EnumWindowsProc(handle, ulong), boolean

              WindowTitle.value$.struct = "Microsoft Internet Explorer"

              calldll #user32, "EnumWindows", _
              lpEnumFunc as ulong, _
              lParam$ as ptr, _
              result as boolean

              WindowHandle = WindowHandle.value.struct

              print "GetActiveWindow handle: "; WindowHandle
              print

              calldll #user32, "BringWindowToTop", _
              WindowHandle as ulong, _
              result as boolean

              if result = 0 then call DisplayError

              calldll #user32, "GetWindowThreadProcessId", _
              WindowHandle as ulong, _
              lpdwProcessId as struct, _
              idThread as ulong

              print "GetWindowThreadProcessId result: "; idThread
              print

              GUIThreadInfo.cbSize.struct = len(GUIThreadInfo.struct)

              calldll #user32, "GetGUIThreadInfo", _
              idThread as ulong, _
              GUIThreadInfo as struct, _
              result as boolean

              print "GetGUIThreadInfo result: "; result
              print

              if result = 0 then
              call DisplayError
              else
              print "cbSize: "; GUIThreadInfo.cbSize.struct
              print "flags: "; GUIThreadInfo.flags.struct
              print "hwndActive: "; GUIThreadInfo.hwndActive.struct
              print "hwndFocus: "; GUIThreadInfo.hwndFocus.struct
              print "hwndCapture: "; GUIThreadInfo.hwndCapture.struct
              print "hwndMenuOwner: "; GUIThreadInfo.hwndMenuOwner.struct
              print "hwndMoveSize: "; GUIThreadInfo.hwndMoveSize.struct
              print "hwndCaret: "; GUIThreadInfo.hwndCaret.struct
              print "left: "; GUIThreadInfo.left.struct
              print "top: "; GUIThreadInfo.top.struct
              print "right: "; GUIThreadInfo.right.struct
              print "bottom: "; GUIThreadInfo.bottom.struct
              print

              CaretX = int((GUIThreadInfo.right.struct +
              GUIThreadInfo.left.struct) / 2)
              CaretY = int((GUIThreadInfo.bottom.struct +
              GUIThreadInfo.top.struct) / 2)

              WindowHandle = GUIThreadInfo.hwndCaret.struct

              calldll #user32, "GetWindowRect", _
              WindowHandle as ulong, _
              Rect as struct, _
              result as boolean

              print "GetWindowRect result: "; result
              print

              if result = 0 then
              call DisplayError
              else
              print "left: "; Rect.left.struct
              print "top: "; Rect.top.struct
              print "right: "; Rect.right.struct
              print "bottom: "; Rect.bottom.struct
              print
              end if

              PosX = Rect.left.struct + CaretX
              PosY = Rect.top.struct + CaretY

              calldll #user32, "SetCursorPos", _
              PosX as long, _
              PosY as long, _
              result as boolean

              if result = 0 then call DisplayError
              end if

              print "Finished ..."
              end

              function EnumWindowsProc(Handle, lParam)
              nMaxCount = 1024
              lpString$ = space$(nMaxCount); chr$(0)

              calldll #user32, "GetWindowTextA", _
              Handle as ulong, _
              lpString$ as ptr, _
              nMaxCount as ulong, _
              result as ulong

              Caption$ = upper$(left$(lpString$, result))
              SearchString$ = upper$(winstring(WindowTitle.value$.struct))

              if instr(Caption$, SearchString$) then
              WindowHandle.value.struct = Handle
              EnumWindowsProc = 0
              else
              EnumWindowsProc = 1
              end if
              end function

              sub DisplayError
              calldll #kernel32, "GetLastError", _
              ErrorCode as ulong

              dwFlags = _FORMAT_MESSAGE_FROM_SYSTEM
              nSize = 1024
              lpBuffer$ = space$(nSize); chr$(0)
              dwMessageID = ErrorCode

              calldll #kernel32, "FormatMessageA", _
              dwFlags as ulong, _
              lpSource as ulong, _
              dwMessageID as ulong, _
              dwLanguageID as ulong, _
              lpBuffer$ as ptr, _
              nSize as ulong, _
              Arguments as ulong, _
              result as ulong

              print "Error "; ErrorCode; ": "; left$(lpBuffer$, result)
              end sub
              '---code end


              -----Ursprüngliche Nachricht-----
              Von: libertybasic@yahoogroups.com

              Hey Stefan,

              Now that I'm back on my computer I am able to try the code you sent. It
              seems to be working fine, thanks again for the correction. However, the
              results it's providing are at best confusing. Maybe if I give a little
              detail to the sequence of events and the code again, you or someone may be
              able to point to my brain cramp.

              1. I open my IE browser from the desktop and log into the website where the
              form I need to fill out exists and place the caret in the first field of the
              form.

              2. I open LB, since I am still coding, and load the program I am working on,
              also from the desktop.

              3. I run the program. I think these steps are important because of Windows
              threads and processes, of which I know I don't know enough.

              In the program I have the following code:

              returnedHandle is the handle of my IE window from the enumWndProc callback
              function

              calldll #user32, "SetFocus",_
              returnedHandle as ulong,_
              result as long

              if frsttime<>0 then [skipcurs]

              calldll #user32,"GetWindowThreadProcessId",_
              returnedHandle as ulong,_
              ProcId as struct,_
              gwtresult as ulong
              idThread = ProcId.value.struct

              calldll #user32,"GetGUIThreadInfo",_
              idThread as ulong,_
              GUIThreadinfo as struct,_
              guires as boolean
              frmx=GUIThreadinfo.x.struct
              frmy=GUIThreadinfo.y.struct

              When I execute this code the results of some of the variables returned in
              GUIThreadinfo are:

              Using idThread in GetGUIThreadInfo call
              idThread-380 Caret-0 returnedHandle-131586
              Active-0 Focus-0 GetWindThreadProcID result-1152
              x-0
              y-0
              Right-0
              Bottom-0

              My problem with these results is that at least Focus which is the handle of
              the window that has the kybd focus should = returnedHandle, since I just set
              the focus there. However when the code continues the program writes the
              data I have in a test file correctly, starting at the first field in the
              form on the website.
              the next time through the form the above code is skipped and the following
              code is executed:

              mseInp.dx.struct=x
              mseInp.dy.struct=y
              mseInp.dwFlags.struct=32768
              call sendmouse 'put mouse at
              previous spot
              mseInp.dx.struct=0
              mseInp.dy.struct=0
              mseInp.dwFlags.struct=2
              call sendmouse 'left button down
              mseInp.dx.struct=0
              mseInp.dy.struct=0
              mseInp.dwFlags.struct=4
              call sendmouse 'left button up

              this code should move the mouse to the coorinates and do a left click down
              and up. I have shortened the x and y leaving out the struct information.

              This kind of works except that the continuing data in the file begins
              writing at the first field of the third row of the form. Which happens to
              coincide with the location of the continue button on my executing programs
              window. (dumb luck - if I move my execution window the data is written
              below wherever the cursor was when CONTINUE was clicked.)

              Now, if I change the GetGUIThreadInfo call as follows:

              calldll #user32,"GetGUIThreadInfo",_
              gwtresult as ulong,_
              GUIThreadinfo as struct,_
              guires as boolean

              where gwtresult is the result from the GetWindowThreadProcessId, I get the
              following:

              Using gwtresult in GetGUIThreadInfo call
              idThread-380 Caret-131534 returnedHandle-131586
              Active-131586 Focus-131534 GetWindThreadProcID result-1152
              x-222
              y-341
              Right-223
              Bottom-357

              Now, at least Focus is different but it is still not returnedHandle as I
              think it should be because of the SetFocu call.

              As for the continuation of this run, it behave exactly as if I used idThread
              in the GetGUIThreadInfo call, i.e. the data the second time through is
              written directly below my CONTINUE button in the program. At least with
              this I think I understand where x and y are coming from, although I'm not
              too sure about that either.

              Maybe by writing all this out I'll think of something. I'll keep trying
              anyway. Any thoughts you or anyone has would be greatly appreciated.

              Thanks.

              Greg



              ___________________________________________________________
              Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx




              Yahoo! Groups Links








              ---------------------------------
              Yahoo! for Good
              Click here to donate to the Hurricane Katrina relief effort.

              [Non-text portions of this message have been removed]
            • pendl2megabit
              Greg, may be you could use ActiveX to get this working ???Information at: http://babek.info/libertybasicfiles/lbnews/nl130/activex.htm and
              Message 6 of 17 , Oct 5, 2005
              • 0 Attachment
                Greg,
                may be you could use ActiveX to get this working ???

                Information at:
                http://babek.info/libertybasicfiles/lbnews/nl130/activex.htm
                and
                http://babek.info/libertybasicfiles/lbnews/nl131/activex2.html

                ---
                Stefan Pendl


                -----Ursprüngliche Nachricht-----
                Von: libertybasic@yahoogroups.com

                Stefan,

                I believe I am a little closer to understanding what is going on with this,
                not quite there yet, but closer. Apparently, there is something related to
                the SendInput command for a mouse that I really don't quite understand. I
                copied my GetGUIThreadInfo and related print code to the section where I try
                to move the mouse and click it. It seems that I am successfully sending the
                mouse messages into the queue, Mouse Result-1 below means that 1 event was
                inserted into the queue. Unfortunately, I don't know which queue. As you
                can see the Mouse handle, hwndCapture from GUIThreadInfo is 0. According to
                MSDN that is the handle of the window that has captured the mouse. Here is
                the info from the last run of my code:

                GetCurrentThreadId result 2-3828
                Using gwtresult in GetGUIThreadInfo call
                Thread-3708 Caret-2294236 Returned-328110
                Active-328110 Focus-2294236 GetWindThreadProcID res-3132
                Mouse handle-0
                x-222
                y-323
                Right-223
                Bottom-357
                GetCurrentThreadId result 1-3828
                Mouse Result-1
                Mouse Result-1
                Mouse Result-1
                GetCurrentThreadId result 2-3828
                Using gwtresult in GetGUIThreadInfo call
                Thread-3708 Caret-2294236 Returned-328110
                Active-328110 Focus-2294236 GetWindThreadProcID res-3132
                Mouse handle-0
                x-222
                y-322
                Right-372
                Bottom-456

                The x and y values, which is what I am using to move the mouse have been
                manipulated by me to see what would happen. The first time I ran this code,
                the second value for x was 371 and y was 323. Then I subtracted the
                difference from the original x and y, 149 for x and 133 for y. As you can
                see the x and y parameters are pretty much equal to the original x and y
                values. However, that changed nothing in the execution of the program. The
                data still begins to write on the form directly below where I click on the
                continue box in my program. Apparently, I am not moving the mouse relative
                to the form page. I'm still a bit confused but at least I think I
                understand a little more. If you or anyone have any ideas, please feel free
                to chime in. Sometimes it helps if I have to put into words what is
                happening and there aren't too many people around here who understand what
                I'm talking about.

                Also, the value of IdThread, Thread above, 3708, which is the output field
                of GetWindowThreadProcessId is the process ID of the Internet Explorer
                process. I checked task manager, processes tab, to find this out. At least
                some things make sense.

                Thanks.

                Greg






                ___________________________________________________________
                Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
              • Greg Bilik
                Hey Stefan, Thanks. I ll look into it. I did discover something interesting though in running a few tests. I m using a test dataset which will fill the 12
                Message 7 of 17 , Oct 6, 2005
                • 0 Attachment
                  Hey Stefan,

                  Thanks. I'll look into it. I did discover something interesting though in running a few tests. I'm using a test dataset which will fill the 12 by 4 form completely once and then only three rows the second time through. The first time through I place the caret in the first field of the form. Get the position and print out the position and handle information and write the form - no problem. When I go back to the form for the rest of the data if I place the cursor in the first field as before and then continue. The position data which is done after the mouse move is the same as the first run. When the form comes up I can see the caret in the first field and then it jumps down to the first field row three. Just a little bit of interesting data I've found trying different things out.

                  Thanks again.

                  Greg

                  pendl2megabit <pendl2megabit@...> wrote:
                  Greg,
                  may be you could use ActiveX to get this working ???

                  Information at:
                  http://babek.info/libertybasicfiles/lbnews/nl130/activex.htm
                  and
                  http://babek.info/libertybasicfiles/lbnews/nl131/activex2.html

                  ---
                  Stefan Pendl


                  -----Ursprüngliche Nachricht-----
                  Von: libertybasic@yahoogroups.com

                  Stefan,

                  I believe I am a little closer to understanding what is going on with this,
                  not quite there yet, but closer. Apparently, there is something related to
                  the SendInput command for a mouse that I really don't quite understand. I
                  copied my GetGUIThreadInfo and related print code to the section where I try
                  to move the mouse and click it. It seems that I am successfully sending the
                  mouse messages into the queue, Mouse Result-1 below means that 1 event was
                  inserted into the queue. Unfortunately, I don't know which queue. As you
                  can see the Mouse handle, hwndCapture from GUIThreadInfo is 0. According to
                  MSDN that is the handle of the window that has captured the mouse. Here is
                  the info from the last run of my code:

                  GetCurrentThreadId result 2-3828
                  Using gwtresult in GetGUIThreadInfo call
                  Thread-3708 Caret-2294236 Returned-328110
                  Active-328110 Focus-2294236 GetWindThreadProcID res-3132
                  Mouse handle-0
                  x-222
                  y-323
                  Right-223
                  Bottom-357
                  GetCurrentThreadId result 1-3828
                  Mouse Result-1
                  Mouse Result-1
                  Mouse Result-1
                  GetCurrentThreadId result 2-3828
                  Using gwtresult in GetGUIThreadInfo call
                  Thread-3708 Caret-2294236 Returned-328110
                  Active-328110 Focus-2294236 GetWindThreadProcID res-3132
                  Mouse handle-0
                  x-222
                  y-322
                  Right-372
                  Bottom-456

                  The x and y values, which is what I am using to move the mouse have been
                  manipulated by me to see what would happen. The first time I ran this code,
                  the second value for x was 371 and y was 323. Then I subtracted the
                  difference from the original x and y, 149 for x and 133 for y. As you can
                  see the x and y parameters are pretty much equal to the original x and y
                  values. However, that changed nothing in the execution of the program. The
                  data still begins to write on the form directly below where I click on the
                  continue box in my program. Apparently, I am not moving the mouse relative
                  to the form page. I'm still a bit confused but at least I think I
                  understand a little more. If you or anyone have any ideas, please feel free
                  to chime in. Sometimes it helps if I have to put into words what is
                  happening and there aren't too many people around here who understand what
                  I'm talking about.

                  Also, the value of IdThread, Thread above, 3708, which is the output field
                  of GetWindowThreadProcessId is the process ID of the Internet Explorer
                  process. I checked task manager, processes tab, to find this out. At least
                  some things make sense.

                  Thanks.

                  Greg






                  ___________________________________________________________
                  Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de




                  Yahoo! Groups Links










                  ---------------------------------
                  Yahoo! for Good
                  Click here to donate to the Hurricane Katrina relief effort.

                  [Non-text portions of this message have been removed]
                • pendl2megabit
                  Greg, seems the form is acting odd. There must be something left in the message queue, that initiates this jump ???--- Stean Pendl-----Ursprüngliche
                  Message 8 of 17 , Oct 6, 2005
                  • 0 Attachment
                    Greg,
                    seems the form is acting odd.
                    There must be something left in the message queue, that initiates this jump
                    ???

                    ---
                    Stean Pendl


                    -----Ursprüngliche Nachricht-----
                    Von: libertybasic@yahoogroups.com

                    Hey Stefan,

                    Thanks. I'll look into it. I did discover something interesting though in
                    running a few tests. I'm using a test dataset which will fill the 12 by 4
                    form completely once and then only three rows the second time through. The
                    first time through I place the caret in the first field of the form. Get
                    the position and print out the position and handle information and write the
                    form - no problem. When I go back to the form for the rest of the data if I
                    place the cursor in the first field as before and then continue. The
                    position data which is done after the mouse move is the same as the first
                    run. When the form comes up I can see the caret in the first field and then
                    it jumps down to the first field row three. Just a little bit of
                    interesting data I've found trying different things out.

                    Thanks again.

                    Greg






                    ___________________________________________________________
                    Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
                  • gjbilik
                    Hey Stefan, I m not too sure if the form is acting weird. I may have the information I need already from the GetGUIThreadInfo call. As I ve been doing all
                    Message 9 of 17 , Oct 7, 2005
                    • 0 Attachment
                      Hey Stefan,

                      I'm not too sure if the form is acting weird. I may have the
                      information I need already from the GetGUIThreadInfo call. As I've
                      been doing all along I put the caret in the first field before my
                      program begins. I always get the same values for x and y from
                      GetGUIThread, 222 for x and 3411 for y. These may be the correct
                      coordinates. I had experienced that the program would begin writing
                      the second time through right under my continue button on my
                      application. That may have been a freak occurence. When I move my
                      application window before pressing continue I still get the 222 and
                      341 values for x and y. So, those may be the correct coordinates of
                      the caret on the form at the beginning of the program.

                      After reading about MOUSE_Events and thresholds, etc., I am now
                      trying to get these values on my PC using SystemParametersInfo and
                      SPI_GETMOUSE. If the values of x and y are greater than the
                      thresholds Windows multiplies the x and y values by 2 or 4
                      depending. I'm just having a little difficulty with the
                      SystemParameters.. API call, (another message). Hopefully, that is
                      the problem. I'm not putting too much into that hope. But...

                      Thanks for all your help. I'll let you and everyone else know if I
                      figure out how to do this.

                      Greg
                      --- In libertybasic@yahoogroups.com, "pendl2megabit"
                      <pendl2megabit@y...> wrote:
                      >
                      > Greg,
                      > seems the form is acting odd.
                      > There must be something left in the message queue, that initiates
                      this jump
                      > ???
                      >
                      > ---
                      > Stean Pendl
                      >
                      >
                      > -----Ursprüngliche Nachricht-----
                      > Von: libertybasic@yahoogroups.com
                      >
                      > Hey Stefan,
                      >
                      > Thanks. I'll look into it. I did discover something interesting
                      though in
                      > running a few tests. I'm using a test dataset which will fill the
                      12 by 4
                      > form completely once and then only three rows the second time
                      through. The
                      > first time through I place the caret in the first field of the
                      form. Get
                      > the position and print out the position and handle information and
                      write the
                      > form - no problem. When I go back to the form for the rest of the
                      data if I
                      > place the cursor in the first field as before and then continue.
                      The
                      > position data which is done after the mouse move is the same as the
                      first
                      > run. When the form comes up I can see the caret in the first field
                      and then
                      > it jumps down to the first field row three. Just a little bit of
                      > interesting data I've found trying different things out.
                      >
                      > Thanks again.
                      >
                      > Greg
                      >
                      >
                      >
                      >
                      >
                      >
                      > ___________________________________________________________
                      > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
                      anmelden: http://mail.yahoo.de
                      >
                    • gjbilik
                      Hi Stefan, Just plodding along and using the newsgroup as a sounding board in case anyone has any ideas. Did a little more checking on the results I m getting
                      Message 10 of 17 , Oct 8, 2005
                      • 0 Attachment
                        Hi Stefan,

                        Just plodding along and using the newsgroup as a sounding board in
                        case anyone has any ideas.

                        Did a little more checking on the results I'm getting from
                        GetGUIThreadInfo:

                        Using gwtresult in GetGUIThreadInfo call
                        Thread-3436 Caret-1245712 Returned-2163220
                        Active-2163220 Focus-1245712 GetWindThreadProcID res-1408
                        Mouse handle-0
                        x-222
                        y-341
                        Right-223
                        Bottom-357

                        Previously, I was concerned that the handle of the Caret and Focus
                        were not the same as the Active and Returned values as seen above.
                        Again the Returned handle value is from the enumWndProc callback
                        function. I performed the GetWindowThreadProcessId call on the Caret
                        handle, it turns out that the Caret and Focus handle are just
                        different handles in the same process. So, although the values are
                        different all the information above relates to the Internet Explorer
                        application which is displaying the form I am trying to place the
                        caret in. Still working to see if the multiplying factor mentioned
                        below is causing my difficulties.

                        Greg
                        --- In libertybasic@yahoogroups.com, "gjbilik" <gjbilik@y...> wrote:
                        >
                        > Hey Stefan,
                        >
                        > I'm not too sure if the form is acting weird. I may have the
                        > information I need already from the GetGUIThreadInfo call. As I've
                        > been doing all along I put the caret in the first field before my
                        > program begins. I always get the same values for x and y from
                        > GetGUIThread, 222 for x and 3411 for y. These may be the correct
                        > coordinates. I had experienced that the program would begin writing
                        > the second time through right under my continue button on my
                        > application. That may have been a freak occurence. When I move my
                        > application window before pressing continue I still get the 222 and
                        > 341 values for x and y. So, those may be the correct coordinates
                        of
                        > the caret on the form at the beginning of the program.
                        >
                        > After reading about MOUSE_Events and thresholds, etc., I am now
                        > trying to get these values on my PC using SystemParametersInfo and
                        > SPI_GETMOUSE. If the values of x and y are greater than the
                        > thresholds Windows multiplies the x and y values by 2 or 4
                        > depending. I'm just having a little difficulty with the
                        > SystemParameters.. API call, (another message). Hopefully, that is
                        > the problem. I'm not putting too much into that hope. But...
                        >
                        > Thanks for all your help. I'll let you and everyone else know if I
                        > figure out how to do this.
                        >
                        > Greg
                        > --- In libertybasic@yahoogroups.com, "pendl2megabit"
                        > <pendl2megabit@y...> wrote:
                        > >
                        > > Greg,
                        > > seems the form is acting odd.
                        > > There must be something left in the message queue, that initiates
                        > this jump
                        > > ???
                        > >
                        > > ---
                        > > Stean Pendl
                        > >
                        > >
                      • Greg Bilik
                        Stefan, I believe I ve finally figured this out. At least it works on my Laptop. I ll have to test it on a different PC that I have access to with a
                        Message 11 of 17 , Oct 13, 2005
                        • 0 Attachment
                          Stefan,

                          I believe I've finally figured this out. At least it works on my Laptop. I'll have to test it on a different PC that I have access to with a different size screen.

                          Anyway, here's my thought process and what seems to work. A good part of it came from the test code you generated the other day and something you said in your message, i.e. client coordinates. The left, top, right and bottom results retrieved by the GetGUIThreadInfo call are in coordiantes relative to the window specified by the hwndCaret member which is also returned from that call. I then called GetWindowRect for the hwndCaret member. Which returns the screen coordinates for that window. I then thought that since the GetGUIThreadInfo coords are relative to the GetWindowRect coords by adding them together I should get the actual screen coords of the caret from GetGUIThreadInfo. On the second pass thru the data after calling SetCursorPos using these new coords I perform a left mouse down and up and, voila, the data begins writing in the correct field on the form. Here is the code which has worked so far:

                          struct GUIThreadinfo,_ 'structure for get GUI thread info API
                          cbsize as long,_
                          flags As long,_
                          hwndActive As ulong,_
                          hwndFocus As ulong,_
                          hwndCapture As ulong,_
                          hwndMenuOwner As ulong,_
                          hwndMoveSize As ulong,_
                          hwndCaret As ulong,_
                          x As Long,_ 'left
                          y As Long,_ 'top
                          Right As Long,_
                          Bottom As Long
                          GUIThreadinfo.cbsize.struct=48
                          struct Rect, _
                          left as long, _
                          top as long, _
                          right as long, _
                          bottom as long

                          '
                          'Define the mouse input structure
                          '
                          struct mseInp,_
                          type as ulong,_
                          dx as long,_ 'x coord
                          dy as long,_ 'y coord
                          msdata as ulong,_
                          dwFlags as ulong,_
                          time as ulong,_
                          dwExtra as ulong

                          mseInp.type.struct=0
                          mseInp.msdata.struct=0
                          mseInp.dwExtra.struct=0

                          '
                          ' Bring up form window and set focus to it.
                          '
                          CmdShow = _SW_MINIMIZE
                          calldll #user32, "ShowWindow", _
                          returnedHandle as ulong, _
                          CmdShow as ulong, _
                          result as boolean

                          CmdShow = _SW_SHOWMAXIMIZED
                          calldll #user32, "ShowWindow", _
                          returnedHandle as ulong, _
                          CmdShow as ulong, _
                          result as boolean

                          if frsttime<>0 then [skipcurs] ' process code below first time through

                          calldll #user32,"GetWindowThreadProcessId",_
                          returnedHandle as ulong,_
                          ProcId as struct,_
                          gwtresult as ulong

                          idThread = ProcId.value.struct

                          calldll #user32,"GetGUIThreadInfo",_
                          gwtresult as ulong,_
                          GUIThreadinfo as struct,_
                          guires as boolean
                          frmx=GUIThreadinfo.x.struct
                          frmy=GUIThreadinfo.y.struct
                          print "Using gwtresult in GetGUIThreadInfo call 1"
                          print "Thread-";idThread;" Caret-";GUIThreadinfo.hwndCaret.struct;" Returned-";returnedHandle
                          print "Active-";GUIThreadinfo.hwndActive.struct;" Focus-";GUIThreadinfo.hwndFocus.struct;" GetWindThreadProcID res-";gwtresult
                          print "Mouse handle-";GUIThreadinfo.hwndCapture.struct
                          print "x-";frmx
                          print "y-";frmy
                          print "Right-";GUIThreadinfo.Right.struct
                          print "Bottom-";GUIThreadinfo.Bottom.struct

                          WindowHandle = GUIThreadinfo.hwndCaret.struct

                          calldll #user32, "GetWindowRect", _
                          WindowHandle as ulong, _
                          Rect as struct, _
                          result as boolean
                          print "GetWindowRect result: "; result
                          if result = 0 then
                          call DisplayError
                          else
                          print "left: "; Rect.left.struct
                          print "top: "; Rect.top.struct
                          print "right: "; Rect.right.struct
                          print "bottom: "; Rect.bottom.struct
                          print
                          end if
                          frsttime=1 'finished with finding caret position

                          goto [proc]

                          [skipcurs]

                          PosX=frmx+Rect.left.struct 'add coords of hwndCaret member to relative coords
                          PosY=frmy+Rect.top.struct

                          calldll #user32, "SetCursorPos", _
                          PosX as long, _
                          PosY as long, _
                          SCPresult as boolean
                          if SCPresult = 0 then
                          print "SetCursorPos Error"
                          call DisplayError
                          else
                          print "SetCursorPos"
                          print "PosX=";PosX
                          print "PosY=";PosY
                          end if

                          mseInp.dx.struct=0
                          mseInp.dy.struct=0
                          mseInp.dwFlags.struct=32770
                          call sendmouse 'left button down

                          mseInp.dx.struct=0
                          mseInp.dy.struct=0
                          mseInp.dwFlags.struct=32774
                          call sendmouse 'left button up

                          Now onto the next step in the process. Thanks for all your help.

                          Greg


                          ---------------------------------
                          Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

                          [Non-text portions of this message have been removed]
                        • pendl2megabit
                          Gre, hope you will get this working ;-D Seems to be a good article for the newsletter, eg. Controlling a different application with LB ;-)--- Stefan Pendl
                          Message 12 of 17 , Oct 13, 2005
                          • 0 Attachment
                            Gre,
                            hope you will get this working ;-D
                            Seems to be a good article for the newsletter, eg. "Controlling a different
                            application with LB" ;-)

                            ---
                            Stefan Pendl


                            -----Ursprungliche Nachricht-----
                            Von: libertybasic@yahoogroups.com

                            Stefan,

                            I believe I've finally figured this out. At least it works on my Laptop.
                            I'll have to test it on a different PC that I have access to with a
                            different size screen.

                            Anyway, here's my thought process and what seems to work. A good part of it
                            came from the test code you generated the other day and something you said
                            in your message, i.e. client coordinates. The left, top, right and bottom
                            results retrieved by the GetGUIThreadInfo call are in coordiantes relative
                            to the window specified by the hwndCaret member which is also returned from
                            that call. I then called GetWindowRect for the hwndCaret member. Which
                            returns the screen coordinates for that window. I then thought that since
                            the GetGUIThreadInfo coords are relative to the GetWindowRect coords by
                            adding them together I should get the actual screen coords of the caret from
                            GetGUIThreadInfo. On the second pass thru the data after calling
                            SetCursorPos using these new coords I perform a left mouse down and up and,
                            voila, the data begins writing in the correct field on the form. Here is
                            the code which has worked so far:

                            ---snip

                            Now onto the next step in the process. Thanks for all your help.

                            Greg







                            ___________________________________________________________
                            Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
                          • Greg Bilik
                            Stefan, Thanks. If I can get everything figured out I will submit something to those who control the newsletter. Right now I have three issues left before I
                            Message 13 of 17 , Oct 14, 2005
                            • 0 Attachment
                              Stefan,

                              Thanks. If I can get everything figured out I will submit something to those who control the newsletter. Right now I have three issues left before I can do everything I need to do.

                              1. On the bottom of the form there are two buttons a preview button and a proceed button. I need to find these buttons with my code and click on one of them, hence my question about Child windows as a possibility.

                              2. After pressing the proceed button, cut and paste the text from the result page to a notepad file. I'm thinking this may not be too bad.

                              3. Go back two times and then forward once to get to a new blank form page. If you just go back once the form doesn;t reset. Also my asumption here is that if I can find the button in 1 above then I can find the place to click to go to the form page.

                              I'll let you know how things work out.

                              Greg

                              pendl2megabit <pendl2megabit@...> wrote:
                              Gre,
                              hope you will get this working ;-D
                              Seems to be a good article for the newsletter, eg. "Controlling a different
                              application with LB" ;-)

                              ---
                              Stefan Pendl


                              -----Ursprungliche Nachricht-----
                              Von: libertybasic@yahoogroups.com

                              Stefan,

                              I believe I've finally figured this out. At least it works on my Laptop.
                              I'll have to test it on a different PC that I have access to with a
                              different size screen.

                              Anyway, here's my thought process and what seems to work. A good part of it
                              came from the test code you generated the other day and something you said
                              in your message, i.e. client coordinates. The left, top, right and bottom
                              results retrieved by the GetGUIThreadInfo call are in coordiantes relative
                              to the window specified by the hwndCaret member which is also returned from
                              that call. I then called GetWindowRect for the hwndCaret member. Which
                              returns the screen coordinates for that window. I then thought that since
                              the GetGUIThreadInfo coords are relative to the GetWindowRect coords by
                              adding them together I should get the actual screen coords of the caret from
                              GetGUIThreadInfo. On the second pass thru the data after calling
                              SetCursorPos using these new coords I perform a left mouse down and up and,
                              voila, the data begins writing in the correct field on the form. Here is
                              the code which has worked so far:

                              ---snip

                              Now onto the next step in the process. Thanks for all your help.

                              Greg







                              ___________________________________________________________
                              Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de




                              Yahoo! Groups Links











                              ---------------------------------
                              Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

                              [Non-text portions of this message have been removed]
                            • gjbilik
                              Hi Stefan et al! If only us programming types would look past our noses every once in a while we might actually be a little more efficient. I ve spent the
                              Message 14 of 17 , Oct 29, 2005
                              • 0 Attachment
                                Hi Stefan et al!

                                If only us programming types would look past our noses every once in
                                a while we might actually be a little more efficient. I've spent the
                                better part of the last month or so trying to find a button on a web
                                page where I have already filled out the information on the form. I
                                also believe that in one of my previous notes here I mentioned that
                                when I tab from the last information field I can see the radio and
                                submit buttons highlighted, but that caret and cursor information was
                                useless. Well, in reading a little about CGI forms, uselessly
                                downloading the .NET SDK framwork (hopefully usefulin the future),
                                and trying endless obscure API calls a though hit me. Why not tab
                                the cursor (or whatever it is) over to the submit button and press
                                the enter key. I can do that, that's easy, SendInput VK_RETURN.
                                And, voila, that is the same as pressing the submit button. While
                                I'm not sure if I don't tab to the correct submit button, there are
                                two, that the form will react the same way, I'm not sure I want to
                                press the prgramming fates too much. I think I remember reading in
                                the CGI book that you can set a default for when the enter button is
                                pressed. I'll have to look a little closer at the HTML which creates
                                the form.

                                Doing this does limit the program a bit. There are two radio buttons
                                which give an option for the output. I think for the time being
                                trying to tackle that may be a little too much. Although I will tab
                                to the radio button and send the enter key to see what happens.

                                Now onto the next part. Getting the output from the new web page
                                which results from submitting the form. I've already looked at the
                                HTML for this page and it is only text, nothing else. I may use the
                                temp files or may try to figure out how to read the text from the
                                page. How hard can that be?

                                Anyway, I wanted to thank everyone who helped me with this to this
                                point. Either by clearing my head of misconceptions, giving me
                                corrected code to use or just letting me put my thoughts into words.

                                Thanks again.

                                Greg
                                --- In libertybasic@yahoogroups.com, "pendl2megabit"
                                <pendl2megabit@y...> wrote:
                                >
                                > Gre,
                                > hope you will get this working ;-D
                                > Seems to be a good article for the newsletter, eg. "Controlling a
                                different
                                > application with LB" ;-)
                                >
                                > ---
                                > Stefan Pendl
                                >
                                >
                                > -----Ursprungliche Nachricht-----
                                > Von: libertybasic@yahoogroups.com
                                >
                                > Stefan,
                                >
                                > I believe I've finally figured this out. At least it works on my
                                Laptop.
                                > I'll have to test it on a different PC that I have access to with a
                                > different size screen.
                                >
                                > Anyway, here's my thought process and what seems to work. A good
                                part of it
                                > came from the test code you generated the other day and something
                                you said
                                > in your message, i.e. client coordinates. The left, top, right and
                                bottom
                                > results retrieved by the GetGUIThreadInfo call are in coordiantes
                                relative
                                > to the window specified by the hwndCaret member which is also
                                returned from
                                > that call. I then called GetWindowRect for the hwndCaret member.
                                Which
                                > returns the screen coordinates for that window. I then thought
                                that since
                                > the GetGUIThreadInfo coords are relative to the GetWindowRect
                                coords by
                                > adding them together I should get the actual screen coords of the
                                caret from
                                > GetGUIThreadInfo. On the second pass thru the data after calling
                                > SetCursorPos using these new coords I perform a left mouse down and
                                up and,
                                > voila, the data begins writing in the correct field on the form.
                                Here is
                                > the code which has worked so far:
                                >
                                > ---snip
                                >
                                > Now onto the next step in the process. Thanks for all your help.
                                >
                                > Greg
                                >
                                >
                                >
                                >
                                >
                                >
                                >
                                > ___________________________________________________________
                                > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
                                anmelden: http://mail.yahoo.de
                                >
                              Your message has been successfully submitted and would be delivered to recipients shortly.