AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Embed an Internet Explorer control in your AHK Gui via COM
Goto page Previous  1, 2, 3 ... 17, 18, 19, 20, 21  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Thu Apr 30, 2009 7:48 pm    Post subject: Reply with quote

ok i give up
how on earth can i modify the following code to allow ctrl+character combo
below allows a ctrl v but blocks v when it is used without ctrl

Code:
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
  If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x11 || wParam = 0x56 || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down
  {
      WinGetClass, Class, ahk_id %hWnd%
      If  (Class = "Internet Explorer_Server")
          {
             Global pipa
             VarSetCapacity(Msg, 28)
             NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
             NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
             DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
             Return 0
          }
  }
}

_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Thu Apr 30, 2009 9:01 pm    Post subject: Reply with quote

ok so this is what i came up with it mostly works accepts ctrl v c and x
Code:
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
   ;http://www.asciitable.com/
   global preKey
   If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x11 || wParam = 0x56 || wParam = 0x43 || wParam = 0x58 || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down
   {
      WinGetClass, Class, ahk_id %hWnd%
      If   ((preKey <> 0x11) && (wParam = 0x56 || wParam = 0x43 || wParam = 0x58)){
         preKey:=0
         Return
      }
      preKey:= wParam=0x11 ? wParam : 0
      If  (Class = "Internet Explorer_Server")
      {
         Global pipa
         VarSetCapacity(Msg, 28)
         NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
         NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
         DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
         Return 0
      }

   }
}

_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Fri May 01, 2009 1:32 am    Post subject: Reply with quote

tank wrote:
ok so this is what i came up with it mostly works accepts ctrl v c and x
You can check whether ctrl modifier is pressed or not using GetKeyState(). In this case, however, I recommend monitoring WM_HOTKEY instead after registering the hotkeys using RegisterHotKey API.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Fri May 01, 2009 3:52 am    Post subject: Reply with quote

Thanks Sean
i didnt think of getkeystate
RegisterHotKey API is well way over my head I'm afraid
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Fri May 01, 2009 4:31 am    Post subject: Reply with quote

Sean wrote:
tank wrote:
ok so this is what i came up with it mostly works accepts ctrl v c and x
You can check whether ctrl modifier is pressed or not using GetKeyState(). In this case, however, I recommend monitoring WM_HOTKEY instead after registering the hotkeys using RegisterHotKey API.
Thanks a ton Sean here is the final working product
Code:
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
   ;http://www.asciitable.com/
   If  (wParam = 0x09 || wParam = 0x0D || (GetKeyState("Control", "P") && wParam)  || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down
   {
      WinGetClass, Class, ahk_id %hWnd%
      If  (Class = "Internet Explorer_Server")
      {
         Global pipa
         VarSetCapacity(Msg, 28)
         NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
         NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
         DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
         Return 0
      }

   }
}

_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Fri May 01, 2009 5:53 am    Post subject: Reply with quote

tank wrote:
here is the final working product
I suppose it may be better just letting the control decide if it's an accelerator. BTW, I think it's a bug of ATL not to do all these by itself.
Code:
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
   If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x2E || wParam = 0x26 || wParam = 0x28 || wParam = 0x43 || wParam = 0x56 || wParam = 0x58)
   {
      WinGetClass, Class, ahk_id %hWnd%
      If  (Class = "Internet Explorer_Server")
      {
         Global pipa
         VarSetCapacity(Msg, 28)
         NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
         NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
         DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
         Return 0
      }
   }
}
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Fri May 01, 2009 6:23 am    Post subject: Reply with quote

@sean your version actually blocks the characters x c and v when used alone?? am i missing something? Confused
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Fri May 01, 2009 6:47 am    Post subject: Reply with quote

Oops, sorry. Another discrepancy between my custom code and the posted one. Anyway, I changed it to check all the keys now. I was a bit concerned about lagging of keystrokes in doing this, so if experience a lag, then fall back to use only the chosen keys.
Code:
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
;   If   (wParam = 0x08 || wParam = 0x09 || wParam = 0x0D || wParam = 0x26 || wParam = 0x28 || wParam = 0x2E || wParam = 0x43 || wParam = 0x56 || wParam = 0x58)
   WinGetClass, Class, ahk_id %hWnd%
   If   (Class = "Internet Explorer_Server")
   {
      Global pipa
      VarSetCapacity(Msg, 28), NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12), NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
      If   DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)=0
      Return   0
   }
}
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Fri May 01, 2009 4:30 pm    Post subject: Reply with quote

Sean wrote:
I was a bit concerned about lagging of keystrokes in doing this,
Works perfectly
add an IF=0 wow how could any one but you really known it would be so simple
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Sat May 02, 2009 1:19 am    Post subject: Reply with quote

And, that's not the end of the story. If add more monitoring messages, can also use Alt+Left/Right.
Code:
OnMessage(WM_SYSKEYDOWN:=0x0104, "WM_KEYDOWN"), OnMessage(WM_SYSKEYUP:=0x0105, "WM_KEYDOWN")
Back to top
View user's profile Send private message
Anxious_Patient



Joined: 31 May 2009
Posts: 7

PostPosted: Sun May 31, 2009 11:22 pm    Post subject: Reply with quote

Sean wrote:
Don't use IE.ahk, it's no longer maintained. I don't even keep it in my machine, neither CoHelper.ahk nor COM.ahk.

Sean, I see that you don't maintain IE.ahk. Could the function IE_GoBack be used on existing Internet Explorer windows? All the examples I seen were using it for an Embeded IE Control.
I simply want to replace the
Code:
Send {Altdown}{Left}{AltUp}
in my code with a function. I am using Tanks IE7 functions for everything else and it is working great. I see Tank has updated his IE7 to iWeb. I plan on leaving my script using IE7 because it is working so well.

My script is able to navigate an IE webpage even with the webpage minimized. I just need this one last thing fixed.

I tried a few things. Of course this is wrong but it is all I have for now.
Code:
COM_Init()
OnExit,Term
pwb := COM_CreateObject("InternetExplorer.Application")

^f5::
Ie_GoBack(pwb)
MsgBox Wait see if it goes back a page
Return


IE_GoBack(pwb)
 {
  DllCall(NumGet(NumGet(1*pwb)+28), "Uint", pwb)
 }

Term:
COM_term()
ExitApp
thanks in advance
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Mon Jun 01, 2009 12:06 am    Post subject: Reply with quote

Anxious_Patient wrote:
Could the function IE_GoBack be used on existing Internet Explorer windows?
Sure. BTW, better use this instead.
Code:
COM_Invoke(pwb, "GoBack")
Back to top
View user's profile Send private message
Anxious_Patient



Joined: 31 May 2009
Posts: 7

PostPosted: Mon Jun 01, 2009 1:35 am    Post subject: Reply with quote

I removed Ie_GoBack(pwb) and put COM_Invoke(pwb, "GoBack") in its place. Here is the error message I get.

---------------------------
COM Error Notification
---------------------------
Function Name: "GoBack"
ERROR: Unspecified error

(0x80004005)
PROG:
DESC:
HELP: ,0

Will Continue?
---------------------------
Yes No
---------------------------

I do have com.ahk in the lib folder.
Code:

COM_Init()
OnExit,Term
pwb := COM_CreateObject("InternetExplorer.Application")

^f5::
COM_Invoke(pwb, "GoBack")
;Ie_GoBack(pwb)
MsgBox Wait see if it goes back a page
Return




Term:
COM_term()
ExitApp

Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Mon Jun 01, 2009 2:58 am    Post subject: Reply with quote

What did you expect? There is no page to go back to.
Back to top
View user's profile Send private message
Anxious_Patient



Joined: 31 May 2009
Posts: 7

PostPosted: Mon Jun 01, 2009 3:23 am    Post subject: Reply with quote

Sean wrote:
What did you expect? There is no page to go back to.
As my first post indicated I am using an existing Internet Explorer web page.

I have my web page open when I press the hotkey.
I added more code to demostrate what I am trying to do.
Code:
COM_Init()
OnExit,Term
SetTitleMatchMode,2

^f5::
IfWinNotExist,google
MsgBox Please open google then click ok
Loop
 {
  random,Num,14,17
  IE7_Click_Element(IE7_Get("google"),num)
  IE7_readyState(myPageHandle)
  Gosub GetHtmlSourceCode
  IfInString,HtmlCode,Keyword
   {
    ;parse source code for more keywords
    ;do something based on those keywords
   }
  pwb := COM_CreateObject("InternetExplorer.Application")
  COM_Invoke(pwb, "GoBack")
  ;GOBACK a page
  sleep 1800000
 }

Term:
COM_term()
ExitApp

GetHtmlSourceCode:
if (!hIESvr or class != "Internet Explorer_Server")
 return
COM_Error(0)
WM_HTML_GETOBJECT := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
SendMessage, WM_HTML_GETOBJECT,,,, ahk_id %hIESvr%
lResult := ErrorLevel
DllCall("oleacc\ObjectFromLresult", "uint", lResult, "uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "uint*", pDoc)
DocEle:=COM_Invoke(pDoc, "documentElement")
htmlcode:=COM_Invoke(DocEle,"innerHTML")
COM_Release(DocEle)
COM_Release(pDoc)
return
thanks for your help
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 17, 18, 19, 20, 21  Next
Page 18 of 21

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group