AutoHotkey Community

It is currently May 27th, 2012, 5:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: January 28th, 2011, 6:00 pm 
Offline

Joined: July 9th, 2009, 1:13 am
Posts: 140
I am in the final stages of converting a large number of scripts over to AHK_L (I know, I am way behind), and this command is tripping me up. It was given to me by someone in the forums and I never understood what it was doing exactly, but its purpose was to set a javascript box to a number WITH preceding zeroes. Normally the preceding zeroes get trimmed off because javascript treats it like a number, so I assume this command forces it to take it as text.

I can't figure out what the AHK_L equivalent of this command is.

COM_Invoke_(pwb, "document.forms[0].field.value", VT_BSTR:=8, Var)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2011, 6:13 pm 
Easiest way is prolly to just Force a String:
Code:
var := 000456
sd := ComObjCreate("Scripting.Dictionary")
sd.item(1) := var
sd.item(2) := "" var
Loop, 2
   MsgBox, % sd.item(A_Index)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2011, 6:53 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
IIRC, specifying the parameter is no longer necessary, if you specify a literal string it will be sent as a literal string:

Code:
pwb.document.all["search_keywords"].value :=   000122345 ; sends '122345' to the item
pwb.document.all["search_keywords"].value :=   "000122345" ; sends '000122345' to the item

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2011, 7:02 pm 
Offline

Joined: July 9th, 2009, 1:13 am
Posts: 140
sinkfaze wrote:
IIRC, specifying the parameter is no longer necessary, if you specify a literal string it will be sent as a literal string:

Code:
pwb.document.all["search_keywords"].value :=   000122345 ; sends '122345' to the item
pwb.document.all["search_keywords"].value :=   "000122345" ; sends '000122345' to the item


That does work, I just wasn't sure how to use it with a variable. a4u gave me the right idea though:

pwb.document.forms[0].field.value := "" var


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2011, 8:39 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
You shouldn't have to do anything different when using a variable as far as I can tell, these should produce the same result:

Code:
num=000122345
pwb.document.all["search_keywords"].value :=   "000122345"
pwb.document.all["search_keywords"].value :=   num

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2011, 8:41 pm 
Offline

Joined: July 9th, 2009, 1:13 am
Posts: 140
sinkfaze wrote:
You shouldn't have to do anything different when using a variable as far as I can tell, these should produce the same result:

Code:
num=000122345
pwb.document.all["search_keywords"].value :=   "000122345"
pwb.document.all["search_keywords"].value :=   num


It was trimming the zeroes when I tried it that way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2011, 11:30 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Which version of AHK_L are you using? It's not trimming them on my version (1.0.92.02).

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2011, 3:44 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
num=000122345 assigns a string to num whereas num:=000122345 assigns both a string and a cached binary integer. In the latter case, num is passed as an integer, which effectively strips the leading zeroes.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], HotkeyStick, rbrtryn, XstatyK and 86 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group