Jump to content
ModemJunki

Check if Win10 system is LEGACY or UEFI installed

Recommended Posts

So there was a topic on the General Help and Support board where the poster mentioned it was not easy to check if the system was installed with UEFI or legacy mode and it got me looking down a rabbit hole. Apparently you can't just whip up a simple WMI query to find that out.

But I did find that you can read the output of bcdedit.exe to check if the system is using winload.efi or winload.exe, so then I got stuck because bcdedit doesn't play nice with StdoutRead. Finally I discovered that toggling Wow64DisableWow64FsRedirection would make it all work together.

I hope this helps someone. Maybe it can be simplified, I'm no expert. 🤨

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
$aArray = StringSplit(_getDOSOutput("bcdedit.exe"), @CRLF)
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0)

For $i = 1 To UBound($aArray) - 1
    Select
        Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=C:') And StringInStr($aArray[$i + 4], 'winload.efi')
            ConsoleWrite("UEFI mode" & @CRLF)
        Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=C:') And StringInStr($aArray[$i + 4], 'winload.exe')
            ConsoleWrite("Legacy BIOS" & @CRLF)
    EndSelect
Next

Func _getDOSOutput($command, $wd = '') ; https://www.autoitscript.com/forum/topic/190249-get-result-of-shellexecute/
    Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, $wd, @SW_HIDE, 2 + 4)
    While 1
        $text &= StdoutRead($Pid, False, False)
        If @error Then ExitLoop
        Sleep(10)
    WEnd
    Return StringStripWS($text, 7)
EndFunc   ;==>_getDOSOutput

 


Always carry a towel.

Share this post


Link to post
Share on other sites

Just a heads up, this will fail if the system partition drive letter is not C (it can be changed by the user)


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

maybe  this will do the trick  https://www.autoitscript.com/forum/topic/180322-_isuefiboot%E2%80%94%E2%80%94detemine-the-current-os-is-boot-in-uefi-mode-or-not/


董小姐,你微笑的时候很美,就像安河桥下,清澈的水...

Share this post


Link to post
Share on other sites
On 10/18/2019 at 11:14 PM, TheDcoder said:

Just a heads up, this will fail if the system partition drive letter is not C (it can be changed by the user)

Yes, absolutely correct! But we can fix it with EnvGet (and of course, this requires admin).

#RequireAdmin

$systemdrive = EnvGet('systemdrive')

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
$aArray = StringSplit(_getDOSOutput("bcdedit.exe"), @CRLF)
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0)

For $i = 1 To UBound($aArray) - 1
    Select
        Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=' & $systemdrive) And StringInStr($aArray[$i + 4], 'winload.efi')
            ConsoleWrite("UEFI mode" & @CRLF)
        Case StringInStr($aArray[$i], 'Windows Boot Loader') And StringInStr($aArray[$i + 3], 'device partition=' & $systemdrive) And StringInStr($aArray[$i + 4], 'winload.exe')
            ConsoleWrite("Legacy BIOS" & @CRLF)
    EndSelect
Next

Func _getDOSOutput($command, $wd = '') ; https://www.autoitscript.com/forum/topic/190249-get-result-of-shellexecute/
    Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, $wd, @SW_HIDE, 2 + 4)
    While 1
        $text &= StdoutRead($Pid, False, False)
        If @error Then ExitLoop
        Sleep(10)
    WEnd
    Return StringStripWS($text, 7)
EndFunc   ;==>_getDOSOutput

 


Always carry a towel.

Share this post


Link to post
Share on other sites
5 hours ago, czyt said:

maybe  this will do the trick  https://www.autoitscript.com/forum/topic/180322-_isuefiboot%E2%80%94%E2%80%94detemine-the-current-os-is-boot-in-uefi-mode-or-not/ 

Nice, I like the idea of a true/false return.

 


Always carry a towel.

Share this post


Link to post
Share on other sites
3 hours ago, coffeeturtle said:

Any ideas if the system returns true UEFI is enabled, but you are not able to enter UEFI ... just the legacy BIOS. How to correct this?

 

I think this would be hardware specific. Not all systems have an UEFI shell in their firmware.


Always carry a towel.

Share this post


Link to post
Share on other sites
5 minutes ago, ModemJunki said:

I think this would be hardware specific. Not all systems have an UEFI shell in their firmware.

Thanks. I used to be able to access the UEFI settings. The last thing I did was turn off the WiFi card as it wasn't necessary at the time in the UEFI settings. Of course, now I need to turn it back on and going though the Legacy BIOS the setting isn't there.

I believe the machine was still Windows 7, but upgraded to Windows 10 when the free offer was first available.

I know these forums aren't really the place for this discussion, but I was hoping since the OP and others here were familiar with obtaining the setting, they may have been involved with projects that might have had similar experiences as mine.

Share this post


Link to post
Share on other sites
14 minutes ago, ModemJunki said:

I think this would be hardware specific. Not all systems have an UEFI shell in their firmware.

As I wrote my previous response a light bulb went off in my head. I think I am now on the right path to fixing my issue (and solve the mystery why I may have lost UEFI):

Quote

Prior to the Windows 10 Creators Update, in order to enable UEFI this would require a wipe and reinstall. This is because Microsoft Windows requires GUID Partition Table (GPT) disk partitioning when booting in UEFI mode, where as Master Boot Record (MBR) is required when booting in BIOS mode. Previously there is no Microsoft-supported solution to perform a non-destructive conversion to GPT.

With the Windows 10 Creators Update, we are releasing a tool called MBR2GPT.

Quote

😁

 

Share this post


Link to post
Share on other sites
1 hour ago, coffeeturtle said:

As I wrote my previous response a light bulb went off in my head. I think I am now on the right path to fixing my issue (and solve the mystery why I may have lost UEFI):

 

You must not have BitLocker encryption on the disk -> but I have done this very conversion to several machines in the past. Have a look here for detailed how-to:

https://www.tenforums.com/tutorials/81502-convert-windows-10-legacy-bios-uefi-without-data-loss.html

This won't give you access to the UEFI shell in your BIOS, however, if that is what you are missing.


Always carry a towel.

Share this post


Link to post
Share on other sites
20 minutes ago, ModemJunki said:

You must not have BitLocker encryption on the disk -> but I have done this very conversion to several machines in the past. Have a look here for detailed how-to:

https://www.tenforums.com/tutorials/81502-convert-windows-10-legacy-bios-uefi-without-data-loss.html

This won't give you access to the UEFI shell in your BIOS, however, if that is what you are missing.

Thank you so much!  The option to go into UEFI is there, but when I hit enter on it, it doesn't do anything. I'm guessing since the OS is on an MBR HDD as opposed to GPT. Maybe?

Share this post


Link to post
Share on other sites
25 minutes ago, coffeeturtle said:

Thank you so much!  The option to go into UEFI is there, but when I hit enter on it, it doesn't do anything. I'm guessing since the OS is on an MBR HDD as opposed to GPT. Maybe?

That seems unlikely to me. A quick test might be to unplug the machine and temporarily disconnect the hard disk - but if you have a TPM controlling Bitlocker encryption this is not a safe thing to do if you don't have a recovery key handy!

Perhaps an email to the vendor support for the system or mainboard is in order (or perhaps they have a help forum).


Always carry a towel.

Share this post


Link to post
Share on other sites
7 hours ago, coffeeturtle said:

I'm guessing since the OS is on an MBR HDD as opposed to GPT. Maybe?

GPT is a must if you ever want to use UEFI, this is one of the first things you do when planning to install UEFI-based OSes :D


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites
On 10/23/2019 at 10:41 PM, TheDcoder said:

GPT is a must if you ever want to use UEFI, this is one of the first things you do when planning to install UEFI-based OSes :D

I think that @coffeeturtle is trying to access UEFI shell or settings in BIOS, but I'm not sure by the description. You don't need a HDD connected for accessing the UEFI part of firmware.

 


Always carry a towel.

Share this post


Link to post
Share on other sites
On 10/23/2019 at 4:27 PM, ModemJunki said:

That seems unlikely to me. A quick test might be to unplug the machine and temporarily disconnect the hard disk - but if you have a TPM controlling Bitlocker encryption this is not a safe thing to do if you don't have a recovery key handy!

Perhaps an email to the vendor support for the system or mainboard is in order (or perhaps they have a help forum).

Thanks. It used to work though. I think it was my fault when I was cloning the drive to use an SSD. I must have reverted the drive to MBR instead of GPT. Even if this isn't the issue, I think I would like to have the drive back as a GPT drive anyway...and hopefully I can use UEFI again as well-icing on the cake.

Since we last talked, I went ahead and cloned the SSD to an HDD I still had as a backup and precaution before attempting anything. Won't have much time this weekend, but I can update you to how it goes using your instructions if I get anything done.

Share this post


Link to post
Share on other sites
1 minute ago, coffeeturtle said:

I went ahead and cloned the SSD to an HDD I still had as a backup and precaution before attempting anything

That is very wise. 🙂 Good luck with the task!


Always carry a towel.

Share this post


Link to post
Share on other sites
15 hours ago, ModemJunki said:

I think that @coffeeturtle is trying to access UEFI shell or settings in BIOS, but I'm not sure by the description. You don't need a HDD connected for accessing the UEFI part of firmware. 

Oh, I see. In that case ignore my comments about requirement for GPT (it is only valid when you want to install an OS in UEFI mode).


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites
20 hours ago, TheDcoder said:

Oh, I see. In that case ignore my comments about requirement for GPT (it is only valid when you want to install an OS in UEFI mode).

GPT conversion is a go!

On 10/25/2019 at 10:28 AM, ModemJunki said:

That is very wise. 🙂 Good luck with the task!

Thank you. The mbr2gpt /convert /allowfullOS  command worked without a hitch and more smoothly than I anticipated. The drive is now listed as GPT and my BIOS Mode = UEFI.

There are some other things I have to check out, but all is good! Thank you again!

Share this post


Link to post
Share on other sites

@coffeeturtle Very nice. Back when I did it, MBR2GPT did not exist... so I had to go the old route and back up all my important files (I did not have a spare drive back then) and then totally reformat the drive to GPT :(

If I had known better, I would have been using GPT from the start!


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Fernandin
      Let me get it straight...
      I've been having such a great experience with AutoIt, it helped me a lot at my work. And now, I gotta make some configurations in the BIOS of many computers at my work. So, I'd like to know,  is it possible to use AutoIt (or some programming language) to write an algorithm that when compiled and transefered to a pen drive, it's "plug and run"? 
    • By czyt
      May it helps those who needed.
       
      #include <WinAPI.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsUEFIBoot ; Description ...: Detemine the Current OS is boot in UEFI mode or not ; Syntax ........: _IsUEFIBoot() ; Parameters ....: ; Return values .: True:OS is boot in UEFI ; False: OS is boot in Legacy BIOS ; Author ........: czyt ; Modified ......: ; Remarks .......: ; Related .......: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DllCall~Information+Booted~UEFI~or~BIOS.txt ; Link ..........: ; Example .......: MsgBox(0,'(*^__^*) The OS is in UEFI Boot mode?',_IsUEFIBoot()) ; =============================================================================================================================== Func _IsUEFIBoot() Local Const $ERROR_INVALID_FUNCTION=0x1 DllCall("Kernel32.dll", "dword", "GetFirmwareEnvironmentVariableW", "wstr", "", "wstr", '{00000000-0000-0000-0000-000000000000}', "wstr", Null, "dword", 0) If _WinAPI_GetLastError() = $ERROR_INVALID_FUNCTION Then Return False Else Return True EndIf EndFunc  
    • By DavidLago
      Hello. 
      Not sure this is the right forum. If I'm wrong, please, let me know.
      I have a task that I really don't know where to begin at. I have a legacy application built in VB6 (yeah, I know) and lately it has been reported to slow down some of the hours of the day and I'm supposed to have a end-user-experience log for this.
      I have worked with IE before, doing things like _IEFormGetCollection, then _IEFormElementGetCollection, and manipulating @extended tags, also, _IEFormElementGetObjByName, _IEFormElementSetValue and _IEFormSubmit at the end. Another example is _IEImgGetCollection, then working with the variable properties, like $xyz.src.
      What I need to do is basically the same.
      - Collecting GUIForms or elements and Setting values into forms (like _IEFormElementSetValue) 
      - Submitting the info to generate an order on another frame of the GUI, and measure the timing.
       
      What I need to know:
      What function or section to be based upon. I have searched in the help file for over a hour with no luck. I've found some stuff within _WinAPI, GDIPlus, and GUIReference, though I wasn't able to find a suitable function to work with this. I have also searched and read some topics in our forum, but most of them refers to AutoIt GUIs. If I missed something, please, educate me.
      Of course, I'll post whatever I can share about what could be helpful for other users.
    • By Tripredacus
      I've been getting reports from manufacturing that some of our applications have been generating an error, such as:

      AUTOIT ERROR LINE 1165(X:\windows\system32\program.exe) ERROR: Subscript used w/ non-array variable
    • By Mikeman27294
      Hey everybody.
      I have been using GUIOnEventMode for a while now, and have never come across this problem. When I am running my script, if I click a button with an event assigned to it, then it seems to queue the events until I right click on the autoit tray icon and tell it to exit, and then it runs the appropriate events for the functions, and then continues to run the script until it reaches the next GUI, and then the same happens. This is the script (Ofcourse I have removed the company name from it though). I am using 3.3.8.0 on Windows 7 Home Premium 64 bit, running the 32 bit AutoIT Executable.

      #AutoIt3Wrapper_UseX64=N #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <Misc.au3> #include <String.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnEsc", 0) Opt("TrayAutoPause", 0) _GDIPlus_Startup() OnAutoItExitRegister('_OnExit') Global $TestGui = 0, $DataGuiArray[10], $ProdNumGuiArray[6], $GUIArray[19], $Selected, $FilePath, $File, $Product, $PInfo, $PWarranty, $PDetails, $PCode, $PWrap, $PMain, $PName, $PCost, $PImages, $ImagesString, $Repeat, $PDetails, $PBrand, $PDelivery, $PWholeSale, $PSearchTags, $PWholesale, $SEOKeywords, $SEODesc, $PNum = "NO PRODUCT NUMBER", $PNumLimit, $MichaelBot = "MichaelBot/1.0 (+http://http://www.Michaelonline.com.au/)", $ThisImage = 0, $Pic, $ImagesGuiArray[5], $ImagesDirectory = "C:\Users\"&@UserName&"\Desktop\Images", $PImagesArray Global $UsePNum = 0, $Mode = 0 HttpSetUserAgent($MichaelBot) If $TestGui = 1 Then _CreateGUI() EndIf If $UsePNum = 1 Then _ProdNum() EndIf _Start() Func _ProdNum() $ProdNumGuiArray[0] = GUICreate("Automatic Product Numbers", 120, 120) $ProdNumGuiArray[1] = GUICtrlCreateLabel("From", 20, 20, 30, 21) $ProdNumGuiArray[2] = GUICtrlCreateInput("", 50, 17, 50, 21) $ProdNumGuiArray[3] = GUICtrlCreateLabel("To", 20, 50, 21) $ProdNumGuiArray[4] = GUICtrlCreateInput("", 50, 47, 50, 21) $ProdNumGuiArray[5] = GUICtrlCreateButton("OK", 40, 80, 40, 30) GUICtrlSetOnEvent($ProdNumGuiArray[5], "_CheckProdNum") GUISetOnEvent(-3, "_Exit") GUISetState(@SW_SHOW, $ProdNumGuiArray[0]) Local $Msg = 0 While 1 WEnd EndFunc Func _CheckProdNum() GUISetState(@SW_HIDE, $ProdNumGuiArray[0]) If GUICtrlRead($ProdNumGuiArray[2]) = "" Or GUICtrlRead($ProdNumGuiArray[4]) = "" Then MsgBox(0,"","Please insert a number in both input boxes.") Else If Number(GUICtrlRead($ProdNumGuiArray[2])) > Number(GUICtrlRead($ProdNumGuiArray[4])) Then MsgBox(0,"","The first number should be smaller than the second.") Else $PNum = Number(GUICtrlRead($ProdNumGuiArray[2])) $PNum -= 1 $PNumLimit = Number(GUICtrlRead($ProdNumGuiArray[4])) GUIDelete($ProdNumGuiArray[0]) _Start() EndIf EndIf EndFunc Func _Start() If $UsePNum = 1 Then If $PNum <> "NO PRODUCT NUMBER" Then If $PNum > $PNumLimit Then _ProdNum() Else $PNum += 1 EndIf EndIf EndIf Local $URL = 'http://www.oo.com.au/Vivitar-iTwist-X018-Digital-Ca_P42902C901.cfm';InputBox("URL", "Please input the product's URL.", ClipGet()) If $URL = "" Then MsgBox(0,"","No URL Supplied.") _Start() EndIf If Not _IsURL($URL) Then MsgBox(0,"","Given string is not URL.") _Start() EndIf If StringInStr($URL, "?") Then $URL = StringLeft($URL, StringInStr($URL, "?")) EndIf If Not StringInStr($URL, "http://") Then $URL = 'http://'&$URL EndIf Local $FilePath = @ScriptDir&"\File\File.html" ;~ ABOVE IS VALIDATION FOR THE URL ClipPut("") ;~ DOWNLOADING THE WEBPAGE InetGet($URL, $FilePath, 16, 0) If FileExists(@ScriptDir&"\File\File.htm") Then FileMove(@ScriptDir&"\File\File.htm", $FilePath, 9) EndIf ;~ ENSURING THAT THE CORRECT FILE EXISTS $File=FileRead($FilePath) ;~ GETTING THE FILE CONTENTS If $File = '' Then ;~ IF FILE NOT DOWNLOADED FROM OO ATTEMPT DOWNLOAD FROM GOOGLE CACHE MsgBox(0,"Error","Could Not Download from OO.com.au"&@CRLF&"Now attempting download from Google Cache.") If StringInStr($URL, 'http://') Then ;~ REMOVE HTTP FROM URL $URL = StringTrimLeft($URL, 7) EndIf $URL = StringTrimRight($URL, 9)&".cfm" ;~ REMOVE ARGUMENTS AND PARAMETERS FROM URL HttpSetUserAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1') ;~ SET USER AGENT TO FIREFOX TO AVOID GOOGLE CACHE ERRORS InetGet('http://webcache.googleusercontent.com/search?q=cache:'&$URL, $FilePath, 16, 0) ;~ ATTEMPT TO DOWNLOAD FILE FROM GOOGLE CACHE If FileExists(@ScriptDir&"\File\File.htm") Then FileMove(@ScriptDir&"\File\File.htm", $FilePath, 9) EndIf ;~ ENSURING THAT THE CORRECT FILE EXISTS HttpSetUserAgent($MichaelBot) ;~ RESETTING THE USER AGENT TO MichaelBOT $File=FileRead($FilePath) ;~ GETTING THE FILE CONTENTS If $File = '' Then ;~ IF FILE NOT DOWNLOADED FROM GOOGLE CACHE THEN DOWNLOAD MANUALLY MsgBox(0,"Error","Could Not Download from Google Cache"&@CRLF&"Please save the file manually to "&$FilePath&".") While Not FileExists($FilePath) If FileExists(@ScriptDir&"\File\File.htm") Then FileMove(@ScriptDir&"\File\File.htm", $FilePath, 9) EndIf ;~ ENSURING THAT THE CORRECT FILE EXISTS Sleep(1000) WEnd ;~ WAITING FOR USER TO DOWNLOAD FILE MsgBox(0,"","File detected. Attempting to use file as source.") $File=FileRead($FilePath) ;~ GETTING THE FILE CONTENTS If StringInStr(StringStripWS($File, 8), "Ashardaswetrywestillaren'tperfect.Wesuggestthatyoutryagainorcontactus.We'resorryforanyinconveniencethismaycause.We'lltryourbesttomakesureitdoesnothappenagain.") Then MsgBox(0,"ERROR","It appears that OO.com.au is down!"&@CRLF&"Attempting alternate download methods.") EndIf If $File = '' Or StringInStr(StringStripWS($File, 8), "Ashardaswetrywestillaren'tperfect.Wesuggestthatyoutryagainorcontactus.We'resorryforanyinconveniencethismaycause.We'lltryourbesttomakesureitdoesnothappenagain.") Then ;~ IF OO IS OFFLINE OR IF USER COULD NOT DOWNLOAD FROM OO $Msgbox = MsgBox(4,"Error", "Program could not read contents of file."&@CRLF&"Would you like to attempt to manually load the file's HTML into the program?") ;~ PRESENT USER WITH THE OPTION TO PASTE THE HTML INTO THE PROGRAM If $Msgbox = 6 Then ;~ IF USER ACCEPTS $File = InputBox("Insert HTML", "Please insert the page's source.", "") ;~ PRESENT USER WITH AN INPUT BOX TO PASTE THE HTML If $File = '' Then ;~ IF THE USER PASTED NOTHING MsgBox(0,"","Failed to retrieve page source from input box."&@CRLF&"Now Exiting.") Exit ;~ GIVE UP ON THE USER. MIGHT BE A GOOD IDEA TO BE PERSISTENT AND PLACE IN WHILE LOOP----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- EndIf Else ;~ IF USER DECLINES MsgBox(0,"","As the program could not retrieve the requested data, it will not exit.") Exit ;~ EXIT EndIf EndIf EndIf EndIf If StringInStr($File, 'images/refurbished.gif') Then ;~ ENSURE THAT THE PRODUCT IS NOT REFURBISHED MsgBox(0,"REFURBISHED", "Error - This product has been refurbished!");http://www.oo.com.au/Kodak-M531-Digital-Camera-14_P89056C901.cfm ;~ FileDelete($File) _Start() ;~ IF THE PRODUCT IS REFURBISHED, THEN MOVE USER ON TO NEXT PRODUCT EndIf ;~ MsgBox(0,"",$File) ;~ FileDelete($FilePath) _GetData() EndFunc Func _GetData() $ThisImage = 0 $Pic = 0 $Product = _HTMLGetElementByID($File, 'product') $PInfo = _HTMLGetElementByID($Product, 'p_info') $PWarranty = _HTMLGetElementByID($PInfo, 'p_warranty') $PWarranty = _HTMLGetWarranty($PWarranty) $PDetails = _HTMLGetElementByID($PInfo, 'p_details') $PBrand = _HTMLGetBrand($PDetails) If $PBrand = '' Then $PBrand = 'Michael' $PCode = _HTMLGetProductCode($PDetails) $PWrap = _HTMLGetElementByID($Product, 'p_wrap') $PMain = _HTMLGetElementByID($PWrap, 'p_main') $PName = StringTrimLeft(StringTrimRight($PMain, StringLen($PMain) - StringInStr($PMain, '</h1>')+1), StringInStr($PMain, '<h1>')+3) $PCost = _HTMLGetCost($PMain) $PWholeSale = $PCost $PCost = _Price($PCost) $PDelivery = _Delivery($PMain) $PImages = _HTMLGetElementByID($PWrap, 'p_imgs') $PImages = _HTMLGetImages($PImages) $PImagesArray = StringSplit($PImages, "|", 3) ;~ MsgBox(0,"",$PCode) For $Repeat = 0 To UBound($PImagesArray)-1 $PImagesArray[$Repeat] = 'http://img.oo.com.au/prod/'&$PCode&'/'&$Repeat+1&'b.jpg' Next $PDetails = _HTMLGetDescription($PDetails, $PWarranty) $PSearchTags = _GetSearchTags($PName) $SEOKeywords = _GetSEOKeywords($PName) $SEODesc = _GetSEODescription($PDetails) _Images() EndFunc Func _CreateGUI() ;GUI WINDOW $GUIArray[0] = GUICreate(" ", 170, 580, @DesktopWidth-200, 75) WinSetOnTop($GuiArray[0], "", 1) ;BASIC DETAILS $GUIArray[1] = GUICtrlCreateRadio("Product Name", 22, 25) $GUIArray[2] = GUICtrlCreateRadio("Product Code", 22, 45) ;PRICE DETAILS $GUIArray[3] = GUICtrlCreateRadio("Final Price", 22, 90) ;DESCRIPTION $GUIArray[4] = GUICtrlCreateRadio("Description", 22, 135) ;IMAGES $GUIArray[5] = GUICtrlCreateRadio("Images", 22, 180) ;Copies the image URL into an array ;ADVANCED DETAILS $GUIArray[6] = GUICtrlCreateRadio("Wholesale Price", 22, 225) $GUIArray[7] = GUICtrlCreateRadio("Brand", 22, 245) $GUIArray[8] = GUICtrlCreateRadio("Notes", 22, 265) $GUIArray[9] = GUICtrlCreateRadio("Product Search Tags", 22, 285) $GuiArray[10] = GUICtrlCreateRadio("Product Identifiers", 22, 305) ;POSTAGE $GUIArray[11] = GUICtrlCreateRadio("Fixed Cost", 22, 350) ;SEARCH ENGINE OPTIMISATION $GUIArray[12] = GUICtrlCreateRadio("Title", 22, 395) $GUIArray[13] = GUICtrlCreateRadio("Keywords", 22, 415) $GUIArray[14] = GUICtrlCreateRadio("Description", 22, 435) $GUIArray[15] = GUICtrlCreateRadio("Custom URL", 22, 455) ;BUTTONS $GUIArray[16] = GUICtrlCreateButton("View Data", 10, 490, 150, 22) GUICtrlSetOnEvent($GuiArray[16], "_DataGUI") $GuiArray[17] = GUICtrlCreateButton("New Product", 10, 520, 150, 22) GUICtrlSetOnEvent($GuiArray[17], '_ReStart') ;STATUSBAR $GuiArray[18] = _GUICtrlStatusBar_Create($GuiArray[0]) _GUICtrlStatusBar_SetText($GuiArray[18], $PNum) ;GROUPS GUICtrlCreateGroup("Basic Details", 10, 10, 150, 60) GUICtrlCreateGroup("Price Details", 10, 75, 150, 40) GUICtrlCreateGroup("Description", 10, 120, 150, 40) GUICtrlCreateGroup("Images", 10, 165, 150, 40) GUICtrlCreateGroup("Advanced Details", 10, 210, 150, 120) GUICtrlCreateGroup("Postage", 10, 335, 150, 40) GUICtrlCreateGroup("Search Engine Optimisation", 10, 380, 150, 100) ;GUI BEHAVIORS GUICtrlSetState($GUIArray[1], 1) GUISetOnEvent(-3, "_Exit") GUISetState(@SW_SHOW, $GuiArray[0]) ;CONTINUING WITH THE SCRIPT If $TestGui = 0 Then _Main() EndIf While 1 WEnd EndFunc Func _Main() WinsetOnTop(" ", "", 1) If $PBrand = '' Then GUICtrlSetState($GuiArray[7], $GUI_DISABLE) EndIf While 1 For $Repeat = 1 To 16 ;Getting selected radio box If GUICtrlRead($GuiArray[$Repeat]) = 1 Then ; MsgBox(0,"",$Selected) $Selected = $Repeat ExitLoop EndIf Next Switch $Selected Case 1 ;Product Name ClipPut($PName) While GUICtrlRead($GuiArray[1]) = 1 ;~ If _IsPressed(11) And _IsPressed(56) Then ;~ GUICtrlSetState($GuiArray[3], $GUI_CHECKED) ;~ EndIf WEnd Case 2 ;Product Code ClipPut($PNum) While GUICtrlRead($GuiArray[2]) = 1 If _IsPressed(11) And _IsPressed(56) Then While _IsPressed(11) And _IsPressed(56) WEnd Sleep(100) Send("{TAB}") Send("10") EndIf WEnd Case 3 ;Product Cost ClipPut($PCost) While GUICtrlRead($GuiArray[3]) = 1 WEnd Case 4 ;Product Description ClipPut($PDetails) While GUICtrlRead($GuiArray[4]) = 1 WEnd Case 5 ;Images ClipPut($PImagesArray[0]) $ThisImage = 0 While GUICtrlRead($GuiArray[5]) = 1 If _IsPressed(11) And _IsPressed(56) Then $ThisImage += 1 If $ThisImage = UBound($PImagesArray) Then ClipPut("") Else ClipPut($PImagesArray[$ThisImage]) EndIf EndIf WEnd Case 6 ;Wholesale ClipPut($PWholeSale) While GUICtrlRead($GuiArray[6]) = 1 WEnd Case 7 ;Brand ClipPut($PBrand) While GUICtrlRead($GuiArray[7]) = 1 WEnd Case 8 ;Notes ClipPut('Product Code: '&$PCode) While GUICtrlRead($GuiArray[8]) = 1 WEnd Case 9 ;Product Search Tags ClipPut(StringLeft($PSearchTags, StringInStr($PSearchTags, "|", 0, 1)-1)) $ThisPSearchTags = $PSearchTags While GUICtrlRead($GuiArray[9]) = 1 If _IsPressed(11) And _IsPressed(56) Then Sleep(100) $ThisPSearchTags = StringTrimLeft($ThisPSearchTags, StringInStr($ThisPSearchTags, "|")) ClipPut(StringLeft($ThisPSearchTags, StringInStr($ThisPSearchTags, "|")-1)) While _IsPressed(11) And _IsPressed(56) WEnd EndIf If ClipGet() = '' Then While GUICtrlRead($GuiArray[9]) = 1 WEnd EndIf WEnd Case 10 ;Product Identifyer ClipPut($PCode) While GUICtrlRead($GuiArray[10]) = 1 WEnd Case 11 ;Fixed Cost Postage ClipPut($PDelivery) While GUICtrlRead($GuiArray[10]) = 1 WEnd Case 12 ;SEO Title ClipPut($PName) While GUICtrlRead($GuiArray[11]) = 1 WEnd Case 13 ;SEO Keywords ClipPut($SEOKeywords) While GUICtrlRead($GuiArray[12]) = 1 WEnd Case 14 ;SEO Description ClipPut($SEODesc) While GUICtrlRead($GuiArray[13]) = 1 WEnd Case 15 ;Custom URL ClipPut($PNum) While GUICtrlRead($GuiArray[14]) = 1 WEnd EndSwitch WEnd EndFunc Func _DataGUI() $DataGuiArray[0] = GUICreate("", @DesktopWidth*0.75, @DesktopHeight*0.75, 0, 0, 0x010F0000) $DataGuiArray[1] = GUICtrlCreateListView("Name|Data", 0, 0, @DesktopWidth, @DesktopHeight) GUICtrlSetResizing($GuiArray[1], '102') $DataGuiArray[2] = GUICtrlCreateListViewItem("Product Name|"&$PName, $GuiArray[1]) $DataGuiArray[3] = GUICtrlCreateListViewItem("Product Cost|"&$PCost, $GuiArray[1]) $DataGuiArray[4] = GUICtrlCreateListViewItem("Delivery Cost|"&$PDelivery, $GuiArray[1]) $DataGuiArray[5] = GUICtrlCreateListViewItem("Description|"&$PDetails, $GuiArray[1]) $DataGuiArray[6] = GUICtrlCreateListViewItem("Wholesale|"&$PWholeSale, $GuiArray[1]) If $PBrand = "" Then $DataGuiArray[7] = GUICtrlCreateListViewItem("Brand|BRAND UNKNOWN", $GuiArray[1]) GUICtrlSetBkColor($DataGuiArray[7], 0xff5040) Else $DataGuiArray[7] = GUICtrlCreateListViewItem("Brand|"&$PBrand, $DataGuiArray[1]) EndIf $DataGuiArray[8] = GUICtrlCreateListViewItem("Warranty|"&$PWarranty, $DataGuiArray[1]) GuiSetOnEvent(-3, "_Exit") GUISetState(@SW_SHOW, $DataGuiArray[0]) Return EndFunc Func _HTMLGetElementByID($html_code, $div_id) Local $o_htmlfile = ObjCreate('HTMLFILE') If Not IsObj($o_htmlfile) Then Return SetError(-1, 0, '') EndIf $o_htmlfile.open() $o_htmlfile.write($html_code) $o_htmlfile.close() Local $div = $o_htmlfile.getElementByID($div_id) If Not IsObj($div) Then Return SetError(0, 0, '') EndIf Return $div.outerHTML EndFunc Func _HTMLGetDescription($Desc, $Warranty) $Desc = StringStripWS($Desc, 3) $Desc = StringReplace($Desc, "<p>", "") $Desc = StringReplace($Desc, "</p>", "<br />") $Title = StringTrimLeft($Desc, StringInStr($Desc, '<h2>')+3) $Title = StringTrimRight($Title, StringLen($Title) - StringInStr($Title, '</h2>')+1) $Title = '<div style="text-align: center;"><strong><span style="font-size: 20px; font-family: arial; color: #3333ff;">'&$Title&'</span></strong></div>' ;~ MsgBox(0, "Title", $Title) $Desc = StringTrimRight($Desc, (StringLen($Desc) - StringInStr($Desc, "<h4"))+1) $Desc = '<span style="font-size: 12px; font-family: arial;"><br />'&StringTrimLeft($Desc, StringInStr($Desc, "<DIV class=clear></DIV>")+24) $DescBody = StringLeft($Desc, StringInStr($Desc, '<h3>')-1) ;~ MsgBox(0, "DescBody", $DescBody) $Desc = StringTrimLeft($Desc, StringInStr($Desc, '<h3>')-1) $Desc = StringReplace($Desc, "<h3>", "<strong>") $Desc = StringReplace($Desc, "</h3>", "</strong>") $Desc = StringReplace($Desc, '<strong>Product Features</strong>', '<strong>Product Features</strong>') $Desc = StringReplace($Desc, '<strong>Features</strong>', '<strong>Product Features</strong>') $Desc = StringReplace($Desc, "<strong>Specifications</strong>", "<strong>Product Specifications</strong>") $Desc = StringReplace($Desc, "<strong>Contents</strong>", "<strong>Package Contents</strong>") $Desc = StringReplace($Desc, "<strong>Package Contains</strong>", "<strong>Package Contents</strong>") $Desc = StringReplace($Desc, "<strong>Contains</strong>", "<strong>Package Contents</strong>") If $Warranty = "This product comes with a warranty covered by either oo.com.au or the supplier of this product." Then $Desc &= "This product comes with a warranty.</span>" Else $Desc &= $Warranty&"</span>" EndIf $Desc = StringReplace($Desc, '</li></ul>', '</li>'&@CRLF&'</ul>') $DescBody = StringStripWS($DescBody, 7) While StringRight($DescBody, 6) = '<br />' $DescBody = StringTrimRight($DescBody, 6) $DescBody = StringStripWS($DescBody, 7) WEnd While StringRight($DescBody, 6) = '<br /><br />' $DescBody = StringReplace($DescBody, '<br /><br />', '<br />') $DescBody = StringStripWS($DescBody, 7) WEnd $DescBody = StringReplace($DescBody, '<br />', '<br /><br />'&@CRLF) $DescArray = StringSplit($Desc, @CR&@LF&@CRLF, 2) ;~ _ArrayDisplay($DescArray) $Desc = "" For $Repeat = 0 To UBound($DescArray)-1 $DescArray[$Repeat] = StringStripWS($DescArray[$Repeat], 3) If StringLeft($DescArray[$Repeat], 5) = ' <li>' And StringRight($DescArray[$Repeat], 5) <> '</li>' Then $DescArray[$Repeat] = ' '&$DescArray[$Repeat]&'</li>' EndIf If $DescArray[$Repeat] <> "" Then $Desc &= $DescArray[$Repeat]&@CRLF EndIf Next ;~ MsgBox(0, "DotPoints", $Desc) $Title = StringStripWS($Title, 3) $DescBody = StringStripWS($DescBody, 3)&'<br /><br />' $Desc = StringStripWS($Desc, 3) $Desc = StringReplace($Desc, '<li>', ' <li>') $Desc = StringReplace($Desc, '</li>', '</li>') $Desc = StringReplace($Desc, '<strong>', '<strong>') $Desc = StringReplace($Desc, '</strong>', '</strong>') $Desc = StringReplace($Desc, '<ul>', '<ul>') $Desc = StringReplace($Desc, '</ul>', '</ul>') Return $Title&@CRLF&$DescBody&@CRLF&$Desc EndFunc Func _HTMLGetProductCode($Desc) $Code = StringTrimRight($Desc, StringLen($Desc)-StringInStr($Desc, '</h4>')+1) $Code = StringRight($Code, StringLen($Code) - StringInStr($Code, 'Product Code:')-13) Return $Code EndFunc Func _HTMLGetImages($Images) $Images = StringTrimLeft($Images, StringInStr($Images, 'http')-1) Local $ImagesString = StringLeft($Images, StringInStr($Images, '.jpg')+3)&'|' While StringLeft($Images, StringInStr($Images, '.jpg')+3) <> StringRight($ImagesString, StringLen($ImagesString) - StringInStr($ImagesString, '|', 0, 1))&'|' If StringInStr($Images, 'http', 0, 2)-1 = '-1' Then ExitLoop EndIf $Images = StringTrimLeft($Images, StringInStr($Images, 'http', 0, 2)-1) $ImagesString &= StringLeft($Images, StringInStr($Images, '.jpg')+3)&'|' WEnd $ImagesString = StringTrimRight($ImagesString, 1) ;~ MsgBox(0,"", $Images) ;~ MsgBox(0,"Images",$ImagesString) Return $ImagesString EndFunc Func _HTMLGetBrand($Desc) Local $Brand = "" If StringInStr($Desc, '<div class="brand">') Then $Brand = StringTrimRight(StringTrimLeft($Desc, StringInStr($Desc, '<div class="brand">')-1), StringLen($Desc) - StringInStr($Desc, "</a>", 0, 2)+1) $Brand = StringRight($Brand, StringLen($Brand) - StringInStr($Brand, "More ")-4) ElseIf StringInStr($Desc, '<div class=brand>') Then $Brand = StringTrimRight(StringTrimLeft($Desc, StringInStr($Desc, '<div class=brand>')-1), StringLen($Desc) - StringInStr($Desc, "</a>", 0, 2)+1) $Brand = StringRight($Brand, StringLen($Brand) - StringInStr($Brand, "More ")-4) ElseIf StringInStr($Desc, 'Brand: ') Then $Brand = StringTrimLeft($Desc, StringInStr($Desc, 'Brand: ')+6) $Brand = StringLeft($Brand, StringInStr($Brand, '</li>')-1) EndIf Return $Brand EndFunc Func _HTMLGetWarranty($Warranty) $Warranty = StringTrimLeft(StringTrimRight($Warranty, StringLen($Warranty) - StringInStr($Warranty, '</p>')+1), StringInStr($Warranty, '<p>')+2) If $Warranty = 'This product comes with a warranty covered by either oo.com.au or the supplier of this product.' Then $Warranty = 'This product comes with a warranty.' EndIf Return $Warranty EndFunc Func _HTMLGetCost($Main) If StringInStr($Main, '<P class=was>') Then $Cost = StringTrimRight(StringTrimLeft($Main, StringInStr($Main, '<P class=was>')+24), StringLen(StringTrimLeft($Main, StringInStr($Main, '<P class=was>')+24))-StringInStr(StringTrimLeft($Main, StringInStr($Main, '<P class=was>')+24), '</span>')+1) Else $Cost = StringTrimLeft(StringTrimRight($Main, StringLen($Main)-StringInStr($Main, "</strong>")+1), StringInStr($Main, "<P class=price>Our Price: <strong>")+34) EndIf Return $Cost EndFunc Func _Images() Local $Image, $Width, $Height ;~ _ArrayDisplay($PImagesArray) $ImagesGuiArray[0] = GUICreate("Images", 600, 680) GUISetBkColor(0xd0d0d0, $ImagesGuiArray[0]) $ImagesGuiArray[1] = GUICtrlCreateButton("<", 245, 610, 30, 30) GUICtrlSetOnEvent($ImagesGuiArray[1], '_PrevImage') $ImagesGuiArray[2] = GUICtrlCreateButton("Edit", 285, 610, 30, 30) GUICtrlSetOnEvent($ImagesGuiArray[2], '_EditImage') $ImagesGuiArray[3] = GUICtrlCreateButton(">", 325, 610, 30, 30) GUICtrlSetOnEvent($ImagesGuiArray[3], '_NextImage') $ImagesGuiArray[4] = GUICtrlCreateLabel("", 245, 645, 105, 30, 0x01) GUICtrlSetState($ImagesGuiArray[1], 128) If UBound($PImagesArray) = 1 Then GUICtrlSetState($ImagesGuiArray[3], 128) EndIf If UBound($PImagesArray)>8 Then $PImagesArrayLimit = 8 Else $PImagesArrayLimit = UBound($PImagesArray)-1 EndIf _CreateImage() GUISetOnEvent(-3, "_Exit") GUISetState(@SW_SHOW, $ImagesGuiArray[0]) While 1 WEnd EndFunc Func _CreateImage() If StringLeft($PImagesArray[0], 4) = 'http' Then InetGet($PImagesArray[0], @TempDir&"\Pic.jpg", 16, 0) Else FileWrite(@TempDir&"\Pic.jpg", FileRead($ImagesDirectory&"\"&$PNum&" 0.jpg")) EndIf $Image = _GDIPlus_ImageLoadFromFile(@TempDir&"\Pic.jpg") $Width = _GDIPlus_ImageGetWidth($Image) $Height = _GDIPlus_ImageGetHeight($Image) If $Width > $Height Then $Height = 600*($Height/$Width) $Width = 600 ElseIf $Height > $Width Then $Width = 600*($Height/$Width) $Height = 600 Else $Height = 600 $Width = 600 EndIf _GDIPlus_ImageDispose($Image) $Pic = GUICtrlCreatePic(@TempDir&"\Pic.jpg", 0, 0, $Width, $Height) $ThisImage = 0 GUICtrlSetData($ImagesGuiArray[4], "Image 1 of "&UBound($PImagesArray)) Return EndFunc Func _NextImage() GUICtrlSetState($ImagesGuiArray[1], 255) $ThisImage += 1 GUICtrlSetData($ImagesGuiArray[4], "Image "&$ThisImage&" of "&UBound($PImagesArray)) If StringLeft($PImagesArray[$ThisImage], 4) = 'http' Then InetGet($PImagesArray[$ThisImage], @TempDir&"\Pic.jpg", 16, 0) Else FileDelete(@TempDir&"\Pic.jpg") FileWrite(@TempDir&"\Pic.jpg", FileRead($ImagesDirectory&"\"&$PNum&" "&$ThisImage&".jpg")) EndIf $Image = _GDIPlus_ImageLoadFromFile(@TempDir&"\Pic.jpg") $Width = _GDIPlus_ImageGetWidth($Image) $Height = _GDIPlus_ImageGetHeight($Image) If $Width > $Height Then $Height = 600*($Height/$Width) $Top = 300 - (0.5*$Height) $Width = 600 $Left = 0 ElseIf $Height > $Width Then $Width = 600*($Width/$Height) $Left = 300 - (0.5*$Width) $Height = 600 $Top = 0 Else $Left = 0 $Top = 0 $Height = 600 $Width = 600 EndIf _GDIPlus_ImageDispose($Image) GUICtrlDelete($Pic) $Pic = GUICtrlCreatePic(@TempDir&"\Pic.jpg", $Left, $Top, $Width, $Height) If $ThisImage = UBound($PImagesArray)-1 Then GUICtrlSetState($ImagesGuiArray[3], 128) EndIf Return EndFunc Func _EditImage() Local $Label, $ImageURL GUICtrlDelete($Pic) $Label = GUICtrlCreateLabel("Waiting for Microsoft Paint to close.", 220, 290) RunWait("mspaint "&@TempDir&"\Pic.jpg", @TempDir, @SW_SHOW) $PImagesArray[$ThisImage] = $ImagesDirectory&"\"&$PNum&" "&$ThisImage&".jpg" FileDelete($ImagesDirectory&"\"&$PNum&" "&$ThisImage&".jpg") FileWrite($ImagesDirectory&"\"&$PNum&" "&$ThisImage&".jpg", FileRead(@TempDir&"\Pic.jpg")) $Image = _GDIPlus_ImageLoadFromFile(@TempDir&"\Pic.jpg") $Width = _GDIPlus_ImageGetWidth($Image) $Height = _GDIPlus_ImageGetHeight($Image) If $Width > $Height Then $Height = 600*($Height/$Width) $Top = 300 - (0.5*$Height) $Width = 600 $Left = 0 ElseIf $Height > $Width Then $Width = 600*($Width/$Height) $Left = 300 - (0.5*$Width) $Height = 600 $Top = 0 Else $Left = 0 $Top = 0 $Height = 600 $Width = 600 EndIf _GDIPlus_ImageDispose($Image) $Pic = GUICtrlCreatePic(@TempDir&"\Pic.jpg", $Left, $Top, $Width, $Height) GUICtrlDelete($Label) EndFunc Func _PrevImage() GUICtrlSetState($ImagesGuiArray[3], 255) $ThisImage -= 1 GUICtrlSetData($ImagesGuiArray[4], "Image "&$ThisImage&" of "&UBound($PImagesArray)) If StringInStr($PImagesArray[$ThisImage], 'http') Then InetGet($PImagesArray[$ThisImage], @TempDir&"\Pic.jpg", 16, 0) Else FileDelete(@TempDir&"\Pic.jpg") FileWrite(@TempDir&"\Pic.jpg", FileRead($ImagesDirectory&"\"&$PNum&" "&$ThisImage&".jpg")) EndIf $Image = _GDIPlus_ImageLoadFromFile(@TempDir&"\Pic.jpg") $Width = _GDIPlus_ImageGetWidth($Image) $Height = _GDIPlus_ImageGetHeight($Image) If $Width > $Height Then $Height = 600*($Height/$Width) $Top = 300 - (0.5*$Height) $Width = 600 $Left = 0 ElseIf $Height > $Width Then $Width = 600*($Width/$Height) $Left = 300 - (0.5*$Width) $Height = 600 $Top = 0 Else $Left = 0 $Top = 0 $Height = 600 $Width = 600 EndIf _GDIPlus_ImageDispose($Image) GUICtrlDelete($Pic) $Pic = GUICtrlCreatePic(@TempDir&"\Pic.jpg", $Left, $Top, $Width, $Height) If $ThisImage = 0 Then GUICtrlSetState($ImagesGuiArray[1], 128) EndIf Return EndFunc Func _Price($FinalPrice) $FinalPrice = 1.3*$FinalPrice If $FinalPrice > 15 Then Local $FinalPriceArray = StringSplit($FinalPrice, ".", 3) If UBound($FinalPriceArray) = 1 Then _ArrayAdd($FinalPriceArray, 0) EndIf If StringRight($FinalPriceArray[0], 1) & "." & $FinalPriceArray[1] >= 2.45 And StringRight($FinalPriceArray[0], 1) & "." & $FinalPriceArray[1] < 7.45 Then $FinalPrice = StringLeft($FinalPriceArray[0], StringLen($FinalPriceArray[0])-1)&"4.95" Else If StringRight($FinalPriceArray[0], 1) > 5 Then $FinalPrice = StringLeft($FinalPriceArray[0], StringLen($FinalPriceArray[0])-1)&"9.95" Else $FinalPrice = (StringLeft($FinalPriceArray[0], StringLen($FinalPriceArray[0])-1)&"9.95")-10 EndIf EndIf EndIf ;~ MsgBox(0,"",$FinalPrice) Return $FinalPrice EndFunc Func _GetSearchTags($SearchTags) Local $DontAllow[4] = [" ", ",", "-", "&amp"] For $Repeat = 0 To UBound($DontAllow)-1 $SearchTags = StringReplace($SearchTags, $DontAllow[$Repeat], "|") Next While StringInStr($SearchTags, "||") $SearchTags = StringReplace($SearchTags, "||", "|") WEnd Return $SearchTags EndFunc Func _GetSEOKeywords($Keywords) Local $DontAllow[4] = [" ", ",", "-", "&amp"] For $Repeat = 0 To UBound($DontAllow)-1 $Keywords = StringReplace($Keywords, $DontAllow[$Repeat], ",") Next While StringInStr($Keywords, ",,") $Keywords = StringReplace($Keywords, ",,", ",") WEnd Return $Keywords EndFunc Func _Exit() Switch @GUI_WinHandle Case $GuiArray[0] Exit Case $ImagesGuiArray[0] GUIDelete($ImagesGuiArray[0]) _CreateGUI() Case $ProdNumGuiArray[0] $Exit = MsgBox(4,"Exit Now?", "Are you sure you want to exit?") If $Exit = 6 Then Exit Else Return EndIf Case Else GUIDelete(@GUI_WinHandle) ;DataGuiArray[0] EndSwitch EndFunc Func _OnExit() GUIDelete($GuiArray[0]) _GDIPlus_Shutdown() EndFunc Func _Delivery($Main) Local $Delivery ;$Delivery = StringTrimLeft($PMain, StringInStr($PMain, '<p class=delivery>', 0)+36) ;$Delivery = StringTrimRight(StringTrimLeft($Delivery, StringInStr($Delivery, "$")-1), StringLen($Delivery)-StringInStr($Delivery, ".")-2) Local $Delivery = StringRegExp($Main, '<P class=delivery>([\S\s]*?)<\/P>', 1) $Delivery = StringRegExp($Delivery[0], '<STRONG>([\S]+)<\/STRONG>', 1) $Delivery[0] = StringTrimLeft($Delivery[0], 1) ;~ MsgBox(0,"",$Delivery[0]) Return $Delivery[0] EndFunc Func _GetSEODescription($Desc2) $Desc2 = _HTML2PlainText($Desc2);StringRegExpReplace($Desc2, "(<[^>]+?>)", "") $Desc2 = _RemExtraLineBreaks($Desc2);StringReplace($Desc2, @CRLF&@CRLF, @CRLF, 0) Return $Desc2 EndFunc Func _HTML2PlainText($sHtml) $sHtml = StringRegExpReplace($sHtml, "<br[^>]*\/>", @CRLF) $sHtml = StringRegExpReplace($sHtml, "<\/?p[^>]*>", @CRLF & @CRLF) $sHtml = StringRegExpReplace($sHtml, '(<[^>]+>)', '') Return $sHtml EndFunc Func _RemExtraLineBreaks($sTxt) $sTxt = StringRegExpReplace($sTxt, "[\s][\s]+", @CRLF) Return $sTxt EndFunc Func _IsURL($URL) Select Case StringInStr($URL, ".com") Return True Case StringInStr($URL, ".net") Return True Case StringInStr($URL, ".org") Return True Case StringInStr($URL, ".gov") Return True Case StringInStr($URL, ".edu") Return True Case StringInStr($URL, ".biz") Return True Case Else Return False EndSelect EndFunc Func _Restart() GUIDelete($GuIArray[0]) _Start() EndFunc
      Does anybody have the same problem?
      Thanks.
×
×
  • Create New...