Fade91 Posted February 13, 2016 Share Posted February 13, 2016 (edited) This was just a simple project for myself but may be someone else will find it interesting. expandcollapse popup#include <IE.au3> #include <Array.au3> #include <String.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Country = RegRead("HKEY_CURRENT_USER\Control Panel\International\", "sCountry") $oIE = _IECreateEmbedded() GUICreate("Country Test" , 300, 300, Default, Default, BitNOT($WS_MINIMIZEBOX) + $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN, $WS_EX_TOPMOST) GUISetBkColor(0xFFFFFF) $Txt = GUICtrlCreateLabel("Loading...Please Wait!", 0, 80, 300, 220, $SS_CENTER) $Obj = GUICtrlCreateObj($oIE, 100, 0, 100, 80) GUISetState(@SW_SHOW) $Flag = _Short_Country($Country) _IENavigate($oIE, "www.flagpedia.net/data/flags/mini/" & StringLower($Flag) & ".png") $oIE.Document.Body.Scroll = "No" $oIE.Document.Body.Style.Border = "0px" GUICtrlSetState($Obj, $GUI_DISABLE) $oIE_Read = _IECreate("www.flagpedia.net/" & StringLower($Country), 0, 0, 1, 0) $oIE_String = _StringBetween(_IEBodyReadHTML($oIE_Read), "<p>", "</p>") GUICtrlSetData($Txt, $oIE_String[0]) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _IEQuit($oIE) _IEQuit($oIE_Read) Exit EndSwitch WEnd Func _Short_Country($sCountry) Local Enum $GEO_NATION = 0x0001, $GEO_LATITUDE, $GEO_LONGITUDE, $GEO_ISO2, $GEO_ISO3, $GEO_RFC1766, $GEO_LCID, $GEO_FRIENDLYNAME, $GEO_OFFICIALNAME, $GEO_TIMEZONES, $GEO_OFFICIALLANGUAGES, $GEO_ISO_UN_NUMBER, $GEO_PARENT Local $SC_Name, $aCall For $iGEOId = 0 To 0xFFFF $aCall = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $iGEOId, "int", $GEO_FRIENDLYNAME, "wstr", "", "int", 65536, "word", 0) If @error Then Return $SC_Name If $aCall[3] = $sCountry Then $aCall = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $iGEOId, "int", $GEO_ISO2, "wstr", "", "int", 65536, "word", 0) If @error Then Return $SC_Name $SC_Name = $aCall[3] ExitLoop EndIf Next Return $SC_Name EndFunc Edited February 13, 2016 by Fade91 Link to comment Share on other sites More sharing options...
JohnOne Posted February 13, 2016 Share Posted February 13, 2016 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted February 13, 2016 Share Posted February 13, 2016 Get the same error here. The problem is caused by the fact that the country is stored in the registry in the local language (e.g. Deutschland) but flagpedia needs the country name in English (e.g. Germany). My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TheDcoder Posted February 13, 2016 Share Posted February 13, 2016 Works for me kcvinu 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
kcvinu Posted February 13, 2016 Share Posted February 13, 2016 Well, this is what i got. "XXXXXX\Desktop\Flag.au3" (30) : ==> Subscript used on non-accessible variable.: GUICtrlSetData($Txt, $oIE_String[0]) GUICtrlSetData($Txt, $oIE_String^ ERROR ->21:58:03 AutoIt3.exe ended.rc:1 argumentum 1 Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
TheDcoder Posted February 13, 2016 Share Posted February 13, 2016 @kcvinu You live in US? I was in the impression that you live in Kerala kcvinu 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
kcvinu Posted February 13, 2016 Share Posted February 13, 2016 @TheDcoder I am wondering that how the flag became us flag. Infact i am in kerala and where is our tricolor ?. May be this program is a prank Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
TheDcoder Posted February 13, 2016 Share Posted February 13, 2016 @kcvinu It is not a prank, Did forgot to change your language to English (India) while installing windows? kcvinu 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
kcvinu Posted February 13, 2016 Share Posted February 13, 2016 May be. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
TheDcoder Posted February 13, 2016 Share Posted February 13, 2016 @kcvinu Here is a reminder kcvinu 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
argumentum Posted February 13, 2016 Share Posted February 13, 2016 12 minutes ago, kcvinu said: Well, this is what i got. "XXXXXX\Desktop\Flag.au3" (30) : ==> Subscript used on non-accessible variable.: GUICtrlSetData($Txt, $oIE_String[0]) GUICtrlSetData($Txt, $oIE_String^ ERROR ->21:58:03 AutoIt3.exe ended.rc:1 should look for "http://flagpedia.net/the-united-states" but it looks for "http://www.flagpedia.net/united states" kcvinu 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
kcvinu Posted February 13, 2016 Share Posted February 13, 2016 (edited) Anyway, i have changed the code little bit like this $Flag = _Short_Country("India") $oIE_Read = _IECreate("http://flagpedia.net/india", 0, 0, 1, 0) Then i got my tricolor Edited February 13, 2016 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
TheDcoder Posted February 13, 2016 Share Posted February 13, 2016 @kcvinu The path is hard coded, You can change your system locale instead : http://windows.microsoft.com/en-us/windows/change-system-locale#1TC=windows-7 kcvinu 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
argumentum Posted February 13, 2016 Share Posted February 13, 2016 $Flag = _Short_Country($Country) Local $aTemp = "", $sLink = "" Local $sSource = _INetGetSource("http://flagpedia.net/index") Local $aSource = StringSplit($sSource,@CRLF) For $n = 1 To $aSource[0] If StringInStr($aSource[$n],'data/flags/mini/'& $Flag &'.png"') Then $aTemp = StringSplit($aSource[$n],'"') $sLink = "http://flagpedia.net"& $aTemp[4] ; use this for the link to get the text ExitLoop EndIf Next Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Fade91 Posted February 13, 2016 Author Share Posted February 13, 2016 (edited) Interesting, ill have to look into fixing it [Edited] I think if I switch the script to use this HKEY_CURRENT_USER\Control Panel\International\iCountry it would be a lot more accurate. Edited February 14, 2016 by Fade91 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