 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
Posted: Thu Apr 30, 2009 7:48 pm Post subject: |
|
|
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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
Posted: Thu Apr 30, 2009 9:01 pm Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Fri May 01, 2009 1:32 am Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
Posted: Fri May 01, 2009 4:31 am Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Fri May 01, 2009 5:53 am Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Fri May 01, 2009 6:47 am Post subject: |
|
|
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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
Posted: Fri May 01, 2009 4:30 pm Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Sat May 02, 2009 1:19 am Post subject: |
|
|
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 |
|
 |
Anxious_Patient
Joined: 31 May 2009 Posts: 7
|
Posted: Sun May 31, 2009 11:22 pm Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Mon Jun 01, 2009 12:06 am Post subject: |
|
|
| 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 |
|
 |
Anxious_Patient
Joined: 31 May 2009 Posts: 7
|
Posted: Mon Jun 01, 2009 1:35 am Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Mon Jun 01, 2009 2:58 am Post subject: |
|
|
| What did you expect? There is no page to go back to. |
|
| Back to top |
|
 |
Anxious_Patient
Joined: 31 May 2009 Posts: 7
|
Posted: Mon Jun 01, 2009 3:23 am Post subject: |
|
|
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|