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 

COM javascript question element focus

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
VibrantLife



Joined: 29 Oct 2009
Posts: 47

PostPosted: Sun Nov 22, 2009 3:03 am    Post subject: COM javascript question element focus Reply with quote

Hello,

When i put this into the addressbar and press Enter
Code:
javascript:function ChangeColor(){document.body.style.background="yellow"};ChangeColor();

The background changed into Yellow.

But when i put this:
Code:
javascript: alert(document.forms[0].elements[0].value)
MsgBox % COM_Invoke(pwb, "document.forms[0].elements[0].value")

Nothing happens.

I really like to learn more about Com and javascript.
Because it seems quite powerfull.

I have a question about focus on to an inputbox

I lookup the inputbox with Webrecorder:

on Text of element
is:
Code:
[value]=
<INPUT style="WIDTH: 300px" id=ctl00_K_H_MA_FA_IA_achterNaamEdit class=clsTextBox maxLength=40 name=ctl00$K$H$MA$FA$IA$a

and on iWeb function:

Code:
msgbox % iWeb_getDomObj(pwb,"ctl00_K_H_MA_FA_IA_achterNaamEdit")
iWeb_clickDomObj(pwb,"ctl00_K_H_MA_FA_IA_achterNaamEdit")
iWeb_setDomObj(pwb,"ctl00_K_H_MA_FA_IA_achterNaamEdit", "")


What kind of code i need to focus first to this Inputbox after loaded?

Like?:

Code:
javascript: document.all.ctl00_K_H_MA_FA_IA_achterNaamEdit.focus()
COM_Invoke(pwb, "document.all.ctl00_K_H_MA_FA_IA_achterNaamEdit.focus")


How can i incorporate this into a existent ahk script,
to test this?

Thanx!
_________________
The signature is away at the moment, please leave a message after the beep...
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 2428

PostPosted: Sun Nov 22, 2009 4:53 am    Post subject: Reply with quote

You're close:

Code:
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus")

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
VibrantLife



Joined: 29 Oct 2009
Posts: 47

PostPosted: Sun Nov 22, 2009 3:16 pm    Post subject: Reply with quote

sinkfaze wrote:
You're close:

Code:
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus")


Alright Very Happy this works

Code:
#include COM.ahk
#include iweb.ahk
#z::
WinWait, Invoeren persoon - Windows Internet Explorer,
IfWinNotActive, Invoeren persoon - Windows Internet Explorer, , WinActivate, Invoeren persoon - Windows Internet Explorer,
WinWaitActive, Invoeren persoon - Windows Internet Explorer,

COM_Init()
pwb:=iWeb_getwin("test.htm")
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus")
COM_Term()
return



Is there a way to set iWeb_getwin to the Title name like?:
iWeb_getwin("Invoeren persoon - Windows Internet Explorer")

Because when i now do it like:

Code:

#include COM.ahk
#include iweb.ahk
#z::
WinWait, Invoeren persoon - Windows Internet Explorer,
IfWinNotActive, Invoeren persoon - Windows Internet Explorer, , WinActivate, Invoeren persoon - Windows Internet Explorer,
WinWaitActive, Invoeren persoon - Windows Internet Explorer,

COM_Init()
pwb:=iWeb_getwin("Invoeren persoon - Windows Internet Explorer")
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus")
COM_Term()
return


I get a error like:
The COM object may not be a valid dispatch Object!
_________________
The signature is away at the moment, please leave a message after the beep...
Back to top
View user's profile Send private message
tank



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

PostPosted: Sun Nov 22, 2009 4:26 pm    Post subject: Reply with quote

omit the suffix
- Windows Internet Explorer
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
VibrantLife



Joined: 29 Oct 2009
Posts: 47

PostPosted: Sun Nov 22, 2009 4:36 pm    Post subject: Reply with quote

tank wrote:
omit the suffix
- Windows Internet Explorer


Hi,

I tried that:

Code:
#include COM.ahk
#include iweb.ahk
#z::
WinWait, Invoeren persoon - Windows Internet Explorer,
IfWinNotActive, Invoeren persoon - Windows Internet Explorer, , WinActivate, Invoeren persoon - Windows Internet Explorer,
WinWaitActive, Invoeren persoon - Windows Internet Explorer,

COM_Init()
pwb:=iWeb_getwin("Invoeren persoon")
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus")
COM_Term()
return


But gives the same error:
Arrow The COM object may not be a valid dispatch Object!
_________________
The signature is away at the moment, please leave a message after the beep...
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 2428

PostPosted: Sun Nov 22, 2009 4:42 pm    Post subject: Reply with quote

VibrantLife wrote:
But gives the same error:
Arrow The COM object may not be a valid dispatch Object!


What is the exact error message(s)?
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
VibrantLife



Joined: 29 Oct 2009
Posts: 47

PostPosted: Sun Nov 22, 2009 5:00 pm    Post subject: Reply with quote

sinkfaze wrote:
VibrantLife wrote:
But gives the same error:
Arrow The COM object may not be a valid dispatch Object!


What is the exact error message(s)?




With webrecorder i searched for: Invoeren persoon
and it says:
[innertext]=Invoeren persoon

Could that be the issue¿
_________________
The signature is away at the moment, please leave a message after the beep...
Back to top
View user's profile Send private message
VibrantLife



Joined: 29 Oct 2009
Posts: 47

PostPosted: Sun Nov 22, 2009 6:39 pm    Post subject: Reply with quote

Never mind the titlename i just use the urlname instead its ok.

I tried to give the inputbox the value of the clipboard like:

Code:
#include COM.ahk
#include iweb.ahk
COM_CoInitialize()
WinWait, Invoeren persoon - Windows Internet Explorer,
IfWinNotActive, Invoeren persoon - Windows Internet Explorer, , WinActivate, Invoeren persoon - Windows Internet Explorer,
WinWaitActive, Invoeren persoon - Windows Internet Explorer,


pwb:=iWeb_getwin("test.htm")
sleep 500

COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus"),
iWeb_setDomObj(pwb,"ctl00_K_H_MA_FA_IA_achterNaamEdit", "%clipboard%")
; this isn't work all to good either: jscript = javascript: document.getElementById("ctl00_K_H_MA_FA_IA_achterNaamEdit").value="%clipboard%";
COM_Release(objIE)
COM_Term()
return


But it send literally: %clipboard% instead of the clipboard content haha
omg i'm a real noobie.
_________________
The signature is away at the moment, please leave a message after the beep...
Back to top
View user's profile Send private message
tank



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

PostPosted: Sun Nov 22, 2009 7:03 pm    Post subject: Reply with quote

Code:
iWeb_setDomObj(pwb,"ctl00_K_H_MA_FA_IA_achterNaamEdit", clipboard)

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



Joined: 29 Oct 2009
Posts: 47

PostPosted: Sun Nov 22, 2009 7:39 pm    Post subject: Reply with quote

tank wrote:
Code:
iWeb_setDomObj(pwb,"ctl00_K_H_MA_FA_IA_achterNaamEdit", clipboard)


Ah thanks!!
_________________
The signature is away at the moment, please leave a message after the beep...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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