Sign in to follow this  
Followers 0
the123punch

Internet Explorer Help

20 posts in this topic

Hello Guys,

I am kinda new to this scripting language and I have to admit it is pretty neat.

I am trying to mine some data from a public database online but I am having a little technical difficulty.

The database from which I am mining the data is: http://www.ncbi.nlm.nih.gov/sites/entrez

Basically, I have a list of genes which I need to collect information on. The list is in a text file called hussny.txt

I have to change some select boxes in some instances when the result displayed is not the Summary. So I make my statement on line 30 to change the select box to DocSum if in case it is not set to the summary but it doesnt change it at all. Basically it doesnt work only when in the loop. When I do the same exact statement for a separate gene it does change it. In my next post I will put the code for 1 separate gene, try it and you will see.

I would really appreciate if someone can help me solve my problem because it has been so long that I am trying to fix this.

Attached is my code and the file hussny.txt

From line 36 to 46 there is the test code for 1 separate gene which works. From line 20 to 34 is the code in the for loop that has a problem.

I tried adding a Sleep(10) to make sure the page is loaded before doing anything but it did not solve anything.

Thanks a lot.

My code is the following:

===================================================================

1#include <IE.au3>

2#include <File.au3>

3#include <Array.au3>

4

5

6;Creating Internet Explorer variables

7$oIE = _IECreate ("http://www.ncbi.nlm.nih.gov/sites/entrez")

8_IELoadWait($oIE)

9$oIEForm = _IEFormGetObjByName($oIE, "EntrezForm")

10$oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Pubmed.SearchBar.Db")

11$oIETextBox = ""

12_IEFormElementSetValue($oIESelect, "gene")

13_IELoadWait($oIE)

14

15$aArray = _ArrayCreate(0)

16_FileReadToArray("hussny.txt", $aArray)

17

18

19

20For $i = 1 to $aArray[0] Step +1

21 $oIEForm = _IEFormGetObjByName($oIE, "EntrezForm")

22 $oIETextBox = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.SearchBar.Term")

23 _IEFormElementSetValue($oIETextBox, "")

24

25 Send($aArray[$i] & " Homo sapiens")

26 Send("{ENTER}")

27 _IELoadWait($oIE)

28

29 $oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.Gene_ResultsPanel.Gene_DisplayBar.sPresentation")

30 _IEFormElementSetValue($oIESelect, "DocSum")

31 _IELoadWait($oIE)

32

33 GetData($aArray[$i])

34Next

35

36

37Func GetData($geneNeeded)

38 $sText = _IEBodyReadText($oIE)

39 ;MsgBox(0, "Body Text", $geneNeeded)

40

41 $a = $geneNeeded

42 $filewrite = OpenFile("temp.txt",2)

43

44 FileWrite($filewrite, $sText)

45 FileClose($filewrite)

46

47 Dim $aRecords

48 If Not _FileReadToArray("temp.txt",$aRecords) Then

49 MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

50 Exit

51 EndIf

52

53 $checkline = false

54 $aliases=""

55 $chromosomes=""

56 $otherdesig=""

57 $annotation=""

58 $symbol=""

59 $geneid=""

60 $location=""

61 $mim=""

62 $name=""

63

64 For $x = 1 to $aRecords[0]

65

66 $find = StringInStr($aRecords[$x], "Official Symbol ")

67 $find2 = StringInStr($aRecords[$x], " and Name: ")

68 If($find) Then

69 $symbol = StringMid($aRecords[$x],$find + StringLen("Official Symbol "),$find2 - $find - StringLen("Official Symbol "))

70 ;MsgBox(0, "caca", $symbol)

71 $name = StringMid($aRecords[$x],$find2 + StringLen(" and Name: "))

72 ;MsgBox(0, "caca", $name)

73 EndIf

74

75 $find = StringInStr($aRecords[$x], "Other Aliases: ")

76 If($find) Then

77 $aliases = StringMid($aRecords[$x],$find + StringLen("Other Aliases: "))

78 EndIf

79

80 $find = StringInStr($aRecords[$x], "Other Designations: ")

81 If($find) Then

82 $otherdesig = StringMid($aRecords[$x],$find + StringLen("Other Designations: "))

83 EndIf

84

85 $find = StringInStr($aRecords[$x], "Chromosome: ")

86 $find2 = StringInStr($aRecords[$x], "; Location: ")

87 If($find) Then

88 $chromosomes = StringMid($aRecords[$x],$find + StringLen("Chromosome: "), $find2 - $find - StringLen("Chromosome: "))

89 $location = StringMid($aRecords[$x],$find2 + StringLen("; Location: "))

90 EndIf

91

92 $find = StringInStr($aRecords[$x], "Annotation: ")

93 If($find) Then

94 $annotation = StringMid($aRecords[$x],$find + StringLen("Annotation: "))

95 EndIf

96

97 $find = StringInStr($aRecords[$x], "MIM: ")

98 If($find) Then

99 $mim = StringMid($aRecords[$x],$find + StringLen("MIM: "))

100 EndIf

101

102 $find = StringInStr($aRecords[$x], "GeneID: ")

103 If($find) Then

104 $geneid = StringMid($aRecords[$x],$find + StringLen("GeneID: "))

105 ;MsgBox(0, "caca", $geneid)

106 $checkline = true

107 EndIf

108

109 If ($checkline) Then

110 ExitLoop

111 EndIf

112 Next

113 $dataFile = OpenFile("data.txt", 1)

114

115 $data = $a & ";" & $symbol & ";" & $name & ";" & $aliases & ";" & $otherdesig & ";" & $chromosomes & ";" & $location & ";" & $annotation & ";" & $mim & ";" & $geneid & @CRLF

116 FileWrite($dataFile, $data)

117 FileClose($dataFile)

118EndFunc

119

120#cs

121 MsgBox(0, "Official Symbol:", $symbol)

122 MsgBox(0, "Name:", $name)

123 MsgBox(0, "Other Aliases:", $aliases)

124 MsgBox(0, "Other Designations:", $otherdesig)

125 MsgBox(0, "Chromosome:", $chromosomes)

126 MsgBox(0, "Location:", $location)

127 MsgBox(0, "Annotation:", $annotation)

128 MsgBox(0, "MIM:", $mim)

129 MsgBox(0, "GeneID:", $geneid)

130#ce

131

132

133Func OpenFile($filename,$mode)

134 $file = FileOpen($filename, $mode)

135

136 ; Check if file opened for writing OK

137 If $file = -1 Then

138 MsgBox(0, "Error", "Unable to create file.")

139 Exit

140 EndIf

141

142 Return $file

143EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Should your selection be "Summary"? I don't see "DocSum" as an option.

$oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.Gene_ResultsPanel.Gene_DisplayBar.sPresentation")
_IEFormElementSetValue($oIESelect, "Summary")
_IELoadWait($oIE)
Edited by mikehunt114

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

didn't read all the code, i will when i get home.

but if u want to wait for a page to load i suggest u use the _IELoadWait($oIE) function read the help to know how it works, it's pretty easy.

I'll try to help more when i get home.

Best Regards

Lespoils

Share this post


Link to post
Share on other sites

Should your selection be "Summary"? I don't see "DocSum" as an option.

$oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.Gene_ResultsPanel.Gene_DisplayBar.sPresentation")
_IEFormElementSetValue($oIESelect, "Summary")
_IELoadWait($oIE)

Hi thanks for your reply... if you go through the search and make a View Source in Internet Explorer.. you will see the select box called "Display"... the option that I need is called DocSum... not Summary.

Thanks and let me know if you find anything else.

Share this post


Link to post
Share on other sites

didn't read all the code, i will when i get home.

but if u want to wait for a page to load i suggest u use the _IELoadWait($oIE) function read the help to know how it works, it's pretty easy.

I'll try to help more when i get home.

Best Regards

Lespoils

Hi Lespoils,

I know about _IELoadWait function. and I am using it but it is still not working... That is why I tried the function Sleep. And it still did not wwork.

thanks.

Share this post


Link to post
Share on other sites

If you want you can simulate a search by typing:

SFRS8 Homo Sapiens

Make sure the database selected is Gene.

This specific gene is one of many that isnt working.

thanks

Share this post


Link to post
Share on other sites

<option value="DocSum" cmd="DisplayChanged">Summary</option>

This is an option select with a value of "DocSum" and text "Summary". When manipulating <SELECT> 's, _IEFormElementOptionselect is the way to go, not setting the value. Try:

_IEFormElementOptionselect($oIESelect, "Summary", "byText")oÝ÷ ØêÚºÚ"µÍÒQQÜQ[[Y[Ü[ÛÙ[XÝ
    ÌÍÛÒQTÙ[XÝ    ][ÝÑØÔÝ[I][ÝÊHÙY][[ÙHÈ    ][ÝØU[YI][Ý

Cheers.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

<option value="DocSum" cmd="DisplayChanged">Summary</option>

This is an option select with a value of "DocSum" and text "Summary". When manipulating <SELECT> 's, _IEFormElementOptionselect is the way to go, not setting the value. Try:

_IEFormElementOptionselect($oIESelect, "Summary", "byText")oÝ÷ ØêÚºÚ"µÍÒQQÜQ[[Y[Ü[ÛÙ[XÝ
    ÌÍÛÒQTÙ[XÝ    ][ÝÑØÔÝ[I][ÝÊHÙY][[ÙHÈ    ][ÝØU[YI][Ý

Cheers.

Hi,

Thanks again for your fast reply but I just tried your suggestion and it still is not working. I don't know if you tried it or not but if you try the script you will know what I mean.

To make it easier for yourself when testing, put in the for loop from $i=107 to 108... so it only tries 2 values.. It is at 107 that it doesnt work properly. 107 is the gene that I gave you in the simulation previously.

Thanks.

Share this post


Link to post
Share on other sites

No, I did not try the code. What do you mean when you say it isn't working? Be specific please. Paste the errors you are getting as a start.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Another thing...

For some reason as I mentionned before,

If I try that code outside the loop it works fine and I get my data collected properly.

It is only when I try it as part of the loop that it doesn't work.

Share this post


Link to post
Share on other sites

No, I did not try the code. What do you mean when you say it isn't working? Be specific please. Paste the errors you are getting as a start.

Hi,

What I mean by it is not working is that it is not switching the select box from the value "Full Report" to the value "Summary" and therefore I am not getting the proper data...

There is no error messages..

I think it should be much clearer if you try the code with the specs that I told you for $i =107 to 108..

It only doesn't work if I run it through the loop. When I run it outside the loop (the same exact code) it works.

I dont know why ... it doesnt make sense but it just doesnt work...

Share this post


Link to post
Share on other sites

Hi,

What I mean by it is not working is that it is not switching the select box from the value "Full Report" to the value "Summary" and therefore I am not getting the proper data...

There is no error messages..

I think it should be much clearer if you try the code with the specs that I told you for $i =107 to 108..

It only doesn't work if I run it through the loop. When I run it outside the loop (the same exact code) it works.

I dont know why ... it doesnt make sense but it just doesnt work...

Please... don't... EVER... post... code... with... line... numbering... again!

Could you please post your current version of the code, in codebox or autoit tags please. I would like to check it out, but I'm not willing to work at just getting to your code in the first place.

Thank you.

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You've got some Javascript events happening there that you don't necessarily see. Things change as soon as you enter your first search...most importantly for you it changes which elements in the form are visible (it's like changing the names, but really, some elements look like they are being hidden, and others made visible). Bottom line is, if you re-assign the elements once you are inside your loop, it will get the proper elements. Here's the relevant portion of your script:

#include <IE.au3>
#include <File.au3>
#include <Array.au3>

$aArray = _ArrayCreate(0)
_FileReadToArray("hussny.txt", $aArray)

$url = "http://www.ncbi.nlm.nih.gov/sites/entrez"

$oIE = _IECreate($url, 1)
$oForm = _IEFormGetObjByName($oIE, "EntrezForm")
$oDB = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Pubmed.SearchBar.Db")
$oInput = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Pubmed.SearchBar.Term")
$oGo = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Pubmed.SearchBar.Go")

;Activate Javascript associated with "Gene" selection
_IEFormElementOptionselect($oDB, "Gene", 1, "byText")
$oGo.click
_IELoadWait($oIE)

For $i = 107 To 108
    ;Re-assign variables to newly visible objects
    $oForm = _IEFormGetObjByName($oIE, "EntrezForm")
    $oDB = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Gene.SearchBar.Db")
    $oInput = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Gene.SearchBar.Term")
    $oGo = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Gene.SearchBar.Go")
    _IEFormElementOptionselect($oDB, "Gene", 1, "byText")
    $string = $aArray[$i] & " Homo sapiens"
    _IEFormElementSetValue($oInput, $string)
    $oGo.click
    _IELoadWait($oIE)
    $oForm = _IEFormGetObjByName($oIE, "EntrezForm")
    $oPresentation = _IEFormElementGetObjByName($oForm, "EntrezSystem2.PEntrez.Gene.Gene_ResultsPanel.Gene_DisplayBar.sPresentation")
    _IEFormElementOptionselect($oPresentation, "Summary", 1, "byText")
    _IELoadWait($oIE)
    GetData($aArray[$i])
Next

P.S. If you run your script through Scite, you will get IE.au3 notification errors in the console which help you debug. Another useful tool is the _IEErrorHandlerRegister(), which outputs useful COM notifications to the console.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Hi Lespoils,

I know about _IELoadWait function. and I am using it but it is still not working... That is why I tried the function Sleep. And it still did not wwork.

thanks.

You can also put a timer to _IELoadWait to wait before looking if the page is loaded. so i guess that is better than a sleep or a _IELoadWait alone.

Just to let you know :whistle:

Lespoils

Share this post


Link to post
Share on other sites

Please... don't... EVER... post... code... with... line... numbering... again!

Could you please post your current version of the code, in codebox or autoit tags please. I would like to check it out, but I'm not willing to work at just getting to your code in the first place.

Thank you.

:whistle:

Hi,

The only reason why I put line numbers is so that the people who don't want to download the script could refer to it just by reading it.

I have attached my script as well in case you want to download it and try it.

Thanks for your help.

Share this post


Link to post
Share on other sites

You've got some Javascript events happening there that you don't necessarily see. Things change as soon as you enter your first search...most importantly for you it changes which elements in the form are visible (it's like changing the names, but really, some elements look like they are being hidden, and others made visible). Bottom line is, if you re-assign the elements once you are inside your loop, it will get the proper elements. Here's the relevant portion of your script:

P.S. If you run your script through Scite, you will get IE.au3 notification errors in the console which help you debug. Another useful tool is the _IEErrorHandlerRegister(), which outputs useful COM notifications to the console.

Hi,

Thanks a lot. It seems like you are the lucky winner mikehunt114.

You solved my problem. really appreciated.

I was just wondering how did u make it so that it runs in the background. Because the first way I had done it it would always run in the foreground and I couldnt do anything without disturbing the script.. So basically while the script was mining I couldnt do anything i had to wait for it to finish.

I tried putting the option of IE_Create to 0 (so that it is not visible) but it was giving me errors... So I am wondering how you did it.

Thanks again..

Share this post


Link to post
Share on other sites

You can also put a timer to _IELoadWait to wait before looking if the page is loaded. so i guess that is better than a sleep or a _IELoadWait alone.

Just to let you know :whistle:

Lespoils

Thanks Lespoils,

It is good to know for that additional feature of IELoadWait.

Greatly appreciate your help guys.

Thanks.

Share this post


Link to post
Share on other sites

Hello Guys,

I am kinda new to this scripting language and I have to admit it is pretty neat.

I am trying to mine some data from a public database online but I am having a little technical difficulty.

The database from which I am mining the data is: http://www.ncbi.nlm.nih.gov/sites/entrez

Basically, I have a list of genes which I need to collect information on. The list is in a text file called hussny.txt

I have to change some select boxes in some instances when the result displayed is not the Summary. So I make my statement on line 30 to change the select box to DocSum if in case it is not set to the summary but it doesnt change it at all. Basically it doesnt work only when in the loop. When I do the same exact statement for a separate gene it does change it. In my next post I will put the code for 1 separate gene, try it and you will see.

I would really appreciate if someone can help me solve my problem because it has been so long that I am trying to fix this.

Attached is my code and the file hussny.txt

From line 36 to 46 there is the test code for 1 separate gene which works. From line 20 to 34 is the code in the for loop that has a problem.

I tried adding a Sleep(10) to make sure the page is loaded before doing anything but it did not solve anything.

Thanks a lot.

My code is the following:

===================================================================

1#include <IE.au3>

2#include <File.au3>

3#include <Array.au3>

4

5

6;Creating Internet Explorer variables

7$oIE = _IECreate ("http://www.ncbi.nlm.nih.gov/sites/entrez")

8_IELoadWait($oIE)

9$oIEForm = _IEFormGetObjByName($oIE, "EntrezForm")

10$oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Pubmed.SearchBar.Db")

11$oIETextBox = ""

12_IEFormElementSetValue($oIESelect, "gene")

13_IELoadWait($oIE)

14

15$aArray = _ArrayCreate(0)

16_FileReadToArray("hussny.txt", $aArray)

17

18

19

20For $i = 1 to $aArray[0] Step +1

21 $oIEForm = _IEFormGetObjByName($oIE, "EntrezForm")

22 $oIETextBox = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.SearchBar.Term")

23 _IEFormElementSetValue($oIETextBox, "")

24

25 Send($aArray[$i] & " Homo sapiens")

26 Send("{ENTER}")

27 _IELoadWait($oIE)

28

29 $oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.Gene_ResultsPanel.Gene_DisplayBar.sPresentation")

30 _IEFormElementSetValue($oIESelect, "DocSum")

31 _IELoadWait($oIE)

32

33 GetData($aArray[$i])

34Next

35

36

37Func GetData($geneNeeded)

38 $sText = _IEBodyReadText($oIE)

39 ;MsgBox(0, "Body Text", $geneNeeded)

40

41 $a = $geneNeeded

42 $filewrite = OpenFile("temp.txt",2)

43

44 FileWrite($filewrite, $sText)

45 FileClose($filewrite)

46

47 Dim $aRecords

48 If Not _FileReadToArray("temp.txt",$aRecords) Then

49 MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

50 Exit

51 EndIf

52

53 $checkline = false

54 $aliases=""

55 $chromosomes=""

56 $otherdesig=""

57 $annotation=""

58 $symbol=""

59 $geneid=""

60 $location=""

61 $mim=""

62 $name=""

63

64 For $x = 1 to $aRecords[0]

65

66 $find = StringInStr($aRecords[$x], "Official Symbol ")

67 $find2 = StringInStr($aRecords[$x], " and Name: ")

68 If($find) Then

69 $symbol = StringMid($aRecords[$x],$find + StringLen("Official Symbol "),$find2 - $find - StringLen("Official Symbol "))

70 ;MsgBox(0, "caca", $symbol)

71 $name = StringMid($aRecords[$x],$find2 + StringLen(" and Name: "))

72 ;MsgBox(0, "caca", $name)

73 EndIf

74

75 $find = StringInStr($aRecords[$x], "Other Aliases: ")

76 If($find) Then

77 $aliases = StringMid($aRecords[$x],$find + StringLen("Other Aliases: "))

78 EndIf

79

80 $find = StringInStr($aRecords[$x], "Other Designations: ")

81 If($find) Then

82 $otherdesig = StringMid($aRecords[$x],$find + StringLen("Other Designations: "))

83 EndIf

84

85 $find = StringInStr($aRecords[$x], "Chromosome: ")

86 $find2 = StringInStr($aRecords[$x], "; Location: ")

87 If($find) Then

88 $chromosomes = StringMid($aRecords[$x],$find + StringLen("Chromosome: "), $find2 - $find - StringLen("Chromosome: "))

89 $location = StringMid($aRecords[$x],$find2 + StringLen("; Location: "))

90 EndIf

91

92 $find = StringInStr($aRecords[$x], "Annotation: ")

93 If($find) Then

94 $annotation = StringMid($aRecords[$x],$find + StringLen("Annotation: "))

95 EndIf

96

97 $find = StringInStr($aRecords[$x], "MIM: ")

98 If($find) Then

99 $mim = StringMid($aRecords[$x],$find + StringLen("MIM: "))

100 EndIf

101

102 $find = StringInStr($aRecords[$x], "GeneID: ")

103 If($find) Then

104 $geneid = StringMid($aRecords[$x],$find + StringLen("GeneID: "))

105 ;MsgBox(0, "caca", $geneid)

106 $checkline = true

107 EndIf

108

109 If ($checkline) Then

110 ExitLoop

111 EndIf

112 Next

113 $dataFile = OpenFile("data.txt", 1)

114

115 $data = $a & ";" & $symbol & ";" & $name & ";" & $aliases & ";" & $otherdesig & ";" & $chromosomes & ";" & $location & ";" & $annotation & ";" & $mim & ";" & $geneid & @CRLF

116 FileWrite($dataFile, $data)

117 FileClose($dataFile)

118EndFunc

119

120#cs

121 MsgBox(0, "Official Symbol:", $symbol)

122 MsgBox(0, "Name:", $name)

123 MsgBox(0, "Other Aliases:", $aliases)

124 MsgBox(0, "Other Designations:", $otherdesig)

125 MsgBox(0, "Chromosome:", $chromosomes)

126 MsgBox(0, "Location:", $location)

127 MsgBox(0, "Annotation:", $annotation)

128 MsgBox(0, "MIM:", $mim)

129 MsgBox(0, "GeneID:", $geneid)

130#ce

131

132

133Func OpenFile($filename,$mode)

134 $file = FileOpen($filename, $mode)

135

136 ; Check if file opened for writing OK

137 If $file = -1 Then

138 MsgBox(0, "Error", "Unable to create file.")

139 Exit

140 EndIf

141

142 Return $file

143EndFunc

can i give u a tip... it makes it much more easyer to help you...

when your uploading a script (or code as you called it)

input this before [autoit*] (remove the star)

and input this after it [/autoit*] (remove the star)

so then your code will look like this

1#include <IE.au3>
2#include <File.au3>
3#include <Array.au3>
4
5
6;Creating Internet Explorer variables
7$oIE = _IECreate ("http://www.ncbi.nlm.nih.gov/sites/entrez")
8_IELoadWait($oIE)
9$oIEForm = _IEFormGetObjByName($oIE, "EntrezForm") 
10$oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Pubmed.SearchBar.Db")
11$oIETextBox = ""
12_IEFormElementSetValue($oIESelect, "gene")
13_IELoadWait($oIE)
14
15$aArray = _ArrayCreate(0)
16_FileReadToArray("hussny.txt", $aArray)
17
18
19
20For $i = 1 to $aArray[0] Step +1
21  $oIEForm = _IEFormGetObjByName($oIE, "EntrezForm") 
22  $oIETextBox = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.SearchBar.Term")
23  _IEFormElementSetValue($oIETextBox, "")
24  
25  Send($aArray[$i] & " Homo sapiens")
26  Send("{ENTER}")
27  _IELoadWait($oIE)
28  
29  $oIESelect = _IEFormElementGetObjByName($oIEForm, "EntrezSystem2.PEntrez.Gene.Gene_ResultsPanel.Gene_DisplayBar.sPresentation")
30  _IEFormElementSetValue($oIESelect, "DocSum")
31  _IELoadWait($oIE)
32  
33  GetData($aArray[$i])
34Next
35
36
37Func GetData($geneNeeded)
38  $sText = _IEBodyReadText($oIE)
39  ;MsgBox(0, "Body Text", $geneNeeded)
40  
41  $a = $geneNeeded
42  $filewrite = OpenFile("temp.txt",2)
43
44  FileWrite($filewrite, $sText)
45  FileClose($filewrite)
46
47  Dim $aRecords
48  If Not _FileReadToArray("temp.txt",$aRecords) Then
49     MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
50     Exit
51  EndIf
52
53  $checkline = false
54  $aliases=""
55  $chromosomes=""
56  $otherdesig=""
57  $annotation=""
58  $symbol=""
59  $geneid=""
60  $location=""
61  $mim=""
62  $name=""
63  
64  For $x = 1 to $aRecords[0]
65      
66      $find = StringInStr($aRecords[$x], "Official Symbol ")
67      $find2 = StringInStr($aRecords[$x], " and Name: ")
68      If($find) Then
69          $symbol = StringMid($aRecords[$x],$find + StringLen("Official Symbol "),$find2 - $find - StringLen("Official Symbol "))
70          ;MsgBox(0, "caca", $symbol)
71          $name = StringMid($aRecords[$x],$find2 + StringLen(" and Name: "))
72          ;MsgBox(0, "caca", $name)
73      EndIf
74      
75      $find = StringInStr($aRecords[$x], "Other Aliases: ")
76      If($find) Then
77          $aliases = StringMid($aRecords[$x],$find + StringLen("Other Aliases: "))
78      EndIf
79      
80      $find = StringInStr($aRecords[$x], "Other Designations: ")
81      If($find) Then
82          $otherdesig = StringMid($aRecords[$x],$find + StringLen("Other Designations: "))
83      EndIf
84      
85      $find = StringInStr($aRecords[$x], "Chromosome: ")
86      $find2 = StringInStr($aRecords[$x], "; Location: ")
87      If($find) Then
88          $chromosomes = StringMid($aRecords[$x],$find + StringLen("Chromosome: "), $find2 - $find - StringLen("Chromosome: "))
89          $location = StringMid($aRecords[$x],$find2 + StringLen("; Location: "))
90      EndIf
91      
92      $find = StringInStr($aRecords[$x], "Annotation: ")
93      If($find) Then
94          $annotation = StringMid($aRecords[$x],$find + StringLen("Annotation: "))
95      EndIf
96      
97      $find = StringInStr($aRecords[$x], "MIM: ")
98      If($find) Then
99          $mim = StringMid($aRecords[$x],$find + StringLen("MIM: "))
100     EndIf
101     
102     $find = StringInStr($aRecords[$x], "GeneID: ")
103     If($find) Then
104         $geneid = StringMid($aRecords[$x],$find + StringLen("GeneID: "))
105         ;MsgBox(0, "caca", $geneid)
106         $checkline = true
107     EndIf
108     
109     If ($checkline) Then
110         ExitLoop
111     EndIf
112 Next
113 $dataFile = OpenFile("data.txt", 1)
114 
115 $data = $a & ";" & $symbol & ";" & $name & ";" & $aliases & ";" & $otherdesig & ";" & $chromosomes & ";" & $location & ";" & $annotation & ";" & $mim & ";" & $geneid & @CRLF
116 FileWrite($dataFile, $data)
117 FileClose($dataFile)
118EndFunc
119
120#cs
121 MsgBox(0, "Official Symbol:", $symbol)
122 MsgBox(0, "Name:", $name)
123 MsgBox(0, "Other Aliases:", $aliases)
124 MsgBox(0, "Other Designations:", $otherdesig)
125 MsgBox(0, "Chromosome:", $chromosomes)
126 MsgBox(0, "Location:", $location)
127 MsgBox(0, "Annotation:", $annotation)
128 MsgBox(0, "MIM:", $mim)
129 MsgBox(0, "GeneID:", $geneid)
130#ce  
131
132
133Func OpenFile($filename,$mode)
134 $file = FileOpen($filename, $mode)
135
136 ; Check if file opened for writing OK
137 If $file = -1 Then
138     MsgBox(0, "Error", "Unable to create file.")
139     Exit
140 EndIf
141 
142 Return $file
143EndFunc

sorry i cant help you any more... Don't have the time...

Share this post


Link to post
Share on other sites

I was just wondering how did u make it so that it runs in the background. Because the first way I had done it it would always run in the foreground and I couldnt do anything without disturbing the script.. So basically while the script was mining I couldnt do anything i had to wait for it to finish.

I tried putting the option of IE_Create to 0 (so that it is not visible) but it was giving me errors... So I am wondering how you did it.

That would be the $f_visible option of _IECreate(). I didn't even know I posted it like that, but I use it often...when I don't need to see the IE object...just results. It works like this:

$oIE = _IECreate($url, 0, 1)         ;first option (0), says not to try to attach to existing instances....second option (1) says IE is visible
$oIE = _IECreate($url, 1, 1)                  ;tries to attach, IE visible
$oIE = _IECreate($url, 1, 0)                  ;tries to attach, IE not visible
$oIE = _IECreate($url, 0, 0)                  ;doesn't try to attach, IE not visible

Hope that clears it up for you.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

The only reason why I put line numbers is so that the people who don't want to download the script could refer to it just by reading it.

I have attached my script as well in case you want to download it and try it.

I get it. But if you'll look around the forum a little, you won't see anybody else doing it, and it really reduces your chances of getting help. Not to zero, but certainly lowers your chances.

Downloading (by simple copy/paste) a poster's script, and pasting it into SciTE for a pas with Tidy and maybe SyntaxCheck is the FIRST thing I do when looking at a problem. ESPECIALLY if it's over a hundred lines long. If somebody want to do that with code posted as you did it, they have to manually strip the line numbering or code a script to do that before even attempting to address your issue. That's a huge disincentive to help.

Just say'n... :whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0