stampy Posted June 2, 2009 Share Posted June 2, 2009 Read the file first.... $filename = FileOpenDialog('','','(*.*)');<<<<<<<<<<<<<<<you choose how to get the file name in, fileopendialog for example only $file = FileOpen($filename, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached $x = '' While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop $x &= $chars Wend FileClose($file) now the $x variable has the information from the file Link to comment Share on other sites More sharing options...
styles3000 Posted June 2, 2009 Author Share Posted June 2, 2009 (edited) My apologies everyone for my newbie-ness. When ya just starting out,the best way for me to learn is in laymans terms. Edited June 2, 2009 by styles3000 Link to comment Share on other sites More sharing options...
styles3000 Posted June 2, 2009 Author Share Posted June 2, 2009 This is what I got so far , and the file just opened and paused .......... $filename =WinExists("lg0001 - Notepad","") $file = FileOpen($filename, 0) ; Read in 1 character at a time until the EOF is reached $x = '' While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop $x &= $chars Wend FileClose($file) Read the file first.... $filename = FileOpenDialog('','','(*.*)');<<<<<<<<<<<<<<<you choose how to get the file name in, fileopendialog for example only $file = FileOpen($filename, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached $x = '' While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop $x &= $chars Wend FileClose($file) now the $x variable has the information from the file Link to comment Share on other sites More sharing options...
ofLight Posted June 2, 2009 Share Posted June 2, 2009 $var = FileOpenDialog("", @ScriptDir, "All (*.*)" ) $file = FileOpen($var, 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $chars = FileRead($file) FileClose($file) $posStart = StringInStr($chars,'<title>') $posEnd = StringInStr($chars,'</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'','This File doesnt Contain a Title') Else $result = StringMid($chars,$posStart+7,$posEnd-($posStart+7)) MsgBox(0,'',$result) EndIf There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
stampy Posted June 3, 2009 Share Posted June 3, 2009 I've added the fileread code to your other code. I removed your first code opening notepad as I assume it's not needed (replaced with the fileopen code). I've left the fileopendialog but I assume you want to open all files via script. If so you'll need to add that to automate all this. expandcollapse popup;I'm not fully sure what your doing here, but I think you were trying to open the file in notepad. ; However with the new fileread code the file will be open and read in the background. ;>>>>>>>MouseClick("left",239,148,2);This is where the document opens up. ;>>>>>>>WinWait("lg0001 - Notepad","") ;>>>>>>>If Not WinActive("lg0001 - Notepad","") Then WinActivate("lg0001 - Notepad","") ;>>>>>>>WinWaitActive("lg0001 - Notepad","") ;;; $filename = FileOpenDialog('','','(*.*)');<<<<<<<<<<<<<<<you choose how to get the file name in, fileopendialog for example only $file = FileOpen($filename, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached $String = '' While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop $String &= $chars Wend FileClose($file) ;;; $result = StringRegExp($String, "<title>(.+?)</title>", 3); ********** like this MouseMove(270,13);This is where the cursor moves over the maximize button. MouseDown("left") MouseUp("left") MouseMove(767,16) ;------------------------------------------------------------------- ;$String = "<title>Lg Ku990 Viewty Room For A View</title> sca <title>test2</title>" ;$result = StringRegExp($String, "<title>(.+?)</title>", 3) ;for $x=0 to Ubound($result)-1 ;MsgBox(0,'',$result[$x]) ;Next ;----------------------------------------------- ;$x = '<title>Lg Ku990 Viewty Room For A View</title>' ;$posStart = StringInStr($x,'<title>')+7 ;$posEnd = StringInStr($x,'</title>') ;$result = StringMid($x,$posStart,$posEnd-$posStart) ;MsgBox(0,'',$result) ;------------------------------------------------------------- MouseDown("left") MouseUp("left") ;Idea:Look into a funtion finds the 2 tags <title> and </title> that counts ;Send("$result") MouseMove(292,14) MouseDown("left") MouseUp("left") WinWait("classname=Shell_TrayWnd","TF_FloatingLangBar_W") If Not WinActive("classname=Shell_TrayWnd","TF_FloatingLangBar_W") Then WinActivate("classname=Shell_TrayWnd","TF_FloatingLangBar_W") WinWaitActive("classname=Shell_TrayWnd","TF_FloatingLangBar_W") MouseMove(429,14) sleep(3000) MouseDown("left") MouseUp("left") MouseMove(426,-35) MouseDown("left") MouseUp("left") WinWait("lg - Notepad","") If Not WinActive("lg - Notepad","") Then WinActivate("lg - Notepad","") WinWaitActive("lg - Notepad","") Send($result[0]); ********* and this , although this is only the first tags content but i hope its ok Exit Link to comment Share on other sites More sharing options...
styles3000 Posted June 5, 2009 Author Share Posted June 5, 2009 Hey everyone. Thanks for your help. I finally got what I needed to get the desired effect I wanted. The code is below. I appriciate all your efforts. Func _GetTitle() Sleep(250) Opt("WinTitleMatchMode", 2) $text = WinGetText("Notepad") $posStart = StringInStr($text,'<title>') $posEnd = StringInStr($text,'</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = ''; This File doesnt Contain a Title Else $result = StringMid($text,$posStart+7,$posEnd-($posStart+7)) EndIf Return $result EndFunc Func _SendTitle($Title) Sleep(250) ControlSend("Notepad",'','', String($Title)) ControlSend('[Class:Notepad]', '', 'Edit1', $Title) Sleep(250) EndFunc I've added the fileread code to your other code. I removed your first code opening notepad as I assume it's not needed (replaced with the fileopen code). I've left the fileopendialog but I assume you want to open all files via script. If so you'll need to add that to automate all this. expandcollapse popup;I'm not fully sure what your doing here, but I think you were trying to open the file in notepad. ; However with the new fileread code the file will be open and read in the background. ;>>>>>>>MouseClick("left",239,148,2);This is where the document opens up. ;>>>>>>>WinWait("lg0001 - Notepad","") ;>>>>>>>If Not WinActive("lg0001 - Notepad","") Then WinActivate("lg0001 - Notepad","") ;>>>>>>>WinWaitActive("lg0001 - Notepad","") ;;; $filename = FileOpenDialog('','','(*.*)');<<<<<<<<<<<<<<<you choose how to get the file name in, fileopendialog for example only $file = FileOpen($filename, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached $String = '' While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop $String &= $chars Wend FileClose($file) ;;; $result = StringRegExp($String, "<title>(.+?)</title>", 3); ********** like this MouseMove(270,13);This is where the cursor moves over the maximize button. MouseDown("left") MouseUp("left") MouseMove(767,16) ;------------------------------------------------------------------- ;$String = "<title>Lg Ku990 Viewty Room For A View</title> sca <title>test2</title>" ;$result = StringRegExp($String, "<title>(.+?)</title>", 3) ;for $x=0 to Ubound($result)-1 ;MsgBox(0,'',$result[$x]) ;Next ;----------------------------------------------- ;$x = '<title>Lg Ku990 Viewty Room For A View</title>' ;$posStart = StringInStr($x,'<title>')+7 ;$posEnd = StringInStr($x,'</title>') ;$result = StringMid($x,$posStart,$posEnd-$posStart) ;MsgBox(0,'',$result) ;------------------------------------------------------------- MouseDown("left") MouseUp("left") ;Idea:Look into a funtion finds the 2 tags <title> and </title> that counts ;Send("$result") MouseMove(292,14) MouseDown("left") MouseUp("left") WinWait("classname=Shell_TrayWnd","TF_FloatingLangBar_W") If Not WinActive("classname=Shell_TrayWnd","TF_FloatingLangBar_W") Then WinActivate("classname=Shell_TrayWnd","TF_FloatingLangBar_W") WinWaitActive("classname=Shell_TrayWnd","TF_FloatingLangBar_W") MouseMove(429,14) sleep(3000) MouseDown("left") MouseUp("left") MouseMove(426,-35) MouseDown("left") MouseUp("left") WinWait("lg - Notepad","") If Not WinActive("lg - Notepad","") Then WinActivate("lg - Notepad","") WinWaitActive("lg - Notepad","") Send($result[0]); ********* and this , although this is only the first tags content but i hope its ok Exit Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now