redfire Posted September 22, 2013 Share Posted September 22, 2013 Hi everyone, How do i get the country 2 letter TLD and Flag in Auto IT? For instance , i am developing an application that would get the country as Brazil, it gets the 2 letter TLD as BR and then it shows the country flag. How is this possible in Auto IT? what must be done? Are there functions i should follow? pls let me know. Link to comment Share on other sites More sharing options...
water Posted September 22, 2013 Share Posted September 22, 2013 You need something to determine the country. You could start with macro @OSLang My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
michaelslamet Posted September 22, 2013 Share Posted September 22, 2013 To determine the country, you could first check it's public ip address, then find the geographics location using this: >GeoIP database parsing examples by guinness Dont forget we need IpToCountry.csv that can be downloaded here To determine the user's public ip address, you can use this snippet (also by guinness): ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #FUNCTION# ========================================================================================================= ; Name...........: _GetIP_Chicken ; Description ...: Retrieves the Public IP Address of a Network/Computer. ; Syntax.........: _GetIP_Chicken() ; Parameters ....: None ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns Public IP Address. ; Failure - Returns -1 & sets @error = 1 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _GetIP_Chicken() Local $aReturn, $bRead, $sRead $bRead = InetRead("http://www.ipchicken.com/") $sRead = BinaryToString($bRead) $aReturn = StringRegExp($sRead, '(?s)(?i)<b>(.*?)<br>', 3) If @error Then Return SetError(1, 0, -1) EndIf Return StringStripWS($aReturn[0], 8) EndFunc ;==>_GetIP_Chicken Link to comment Share on other sites More sharing options...
redfire Posted September 22, 2013 Author Share Posted September 22, 2013 To determine the country, you could first check it's public ip address, then find the geographics location using this: >GeoIP database parsing examples by guinness Dont forget we need IpToCountry.csv that can be downloaded here To determine the user's public ip address, you can use this snippet (also by guinness): ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #FUNCTION# ========================================================================================================= ; Name...........: _GetIP_Chicken ; Description ...: Retrieves the Public IP Address of a Network/Computer. ; Syntax.........: _GetIP_Chicken() ; Parameters ....: None ; Requirement(s).: v3.3.2.0 or higher ; Return values .: Success - Returns Public IP Address. ; Failure - Returns -1 & sets @error = 1 ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _GetIP_Chicken() Local $aReturn, $bRead, $sRead $bRead = InetRead("http://www.ipchicken.com/") $sRead = BinaryToString($bRead) $aReturn = StringRegExp($sRead, '(?s)(?i)<b>(.*?)<br>', 3) If @error Then Return SetError(1, 0, -1) EndIf Return StringStripWS($aReturn[0], 8) EndFunc ;==>_GetIP_Chicken What i mean is, My country is Brazil. the code returns something like BR. thats what i mean. for the ip. this _GetIP() doesnt it return the public ip of the computer? Link to comment Share on other sites More sharing options...
water Posted September 22, 2013 Share Posted September 22, 2013 How do you determine that your country is Brazil? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
guinness Posted September 22, 2013 Share Posted September 22, 2013 You can use _GetIP() in Inet.au3 as that IPChicken is badly coded. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
michaelslamet Posted September 22, 2013 Share Posted September 22, 2013 You can use _GetIP() in Inet.au3 as that IPChicken is badly coded. @Guinness: How is that IPChicken snippet badly coded? I'm using it on some of my scripts and it never failed me, and I dont plan to change it Link to comment Share on other sites More sharing options...
guinness Posted September 22, 2013 Share Posted September 22, 2013 #include <Constants.au3> Local $sPublicIP = _GetIP_IPChicken() MsgBox($MB_SYSTEMMODAL, "", "Your external IP address is: " & $sPublicIP) ; #FUNCTION# ==================================================================================================================== ; Author ........: guinness ; =============================================================================================================================== Func _GetIP_IPChicken() Local Const $IP_URL = "http://ipchicken.com/" Local $aReturn = StringRegExp(BinaryToString(InetRead($IP_URL)), "[\d\.]{7,15}", 3), $sReturn = "" If @error = 0 Then $sReturn = $aReturn[0] EndIf If $sReturn == "" Then Return SetError(1, 0, -1) Return $sReturn EndFunc ;==>_GetIP_IPChicken UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted September 22, 2013 Share Posted September 22, 2013 @Guinness: How is that IPChicken snippet badly coded? I'm using it on some of my scripts and it never failed me, and I dont plan to change it Use _GetIP() because IPChicken isn't intended for automation, whereas the sites in _GetIP() are. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
michaelslamet Posted September 22, 2013 Share Posted September 22, 2013 If I'm not wrong, the main different is at the RegEx pattern: previous one: (?s)(?i)<b>(.*?)<br> new one: [d.]{7,15} I can see why the new one will give better result Is that correct? Link to comment Share on other sites More sharing options...
michaelslamet Posted September 22, 2013 Share Posted September 22, 2013 Use _GetIP() because IPChicken isn't intended for automation, whereas the sites in _GetIP() are. Noted with thanks, guinness. I am not remember why I'm using IPChicken instead of _GetIP(), but if i'm not wrong, _GetIP() sometime return the local ip address ? Link to comment Share on other sites More sharing options...
guinness Posted September 22, 2013 Share Posted September 22, 2013 (edited) I guess the OP is wanting to use the ISO 3166 code? If so look at using images from http://icondrawer.com/free.php (notice the license please) and then look at _GetOSLanguage() in my signature. You will basically need to use some logical thinking and create your own user defined function. Edited September 22, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2013 Share Posted September 22, 2013 (edited) It doesn't have to be super complicated but it really isn't possible to determine what you really want based on your input. I will imagine you want something like this:expandcollapse popup#include "GIFAnimation.au3" #include <GUIConstantsEx.au3> Global $sCountry = "Portugal" Global Const $sFormat = "http://flagpedia.net/data/flags/normal/%s.png" Global $sTLD Global $hGui = GUICreate("National flags", 500, 350) Global $hInput = GUICtrlCreateInput($sCountry, 20, 30, 150, 30) GUICtrlSetFont($hInput, 0) Global $hButton = GUICtrlCreateButton("&Show national flag", 200, 30, 140, 30) GUICtrlSetFont($hButton, 0) Global $hLabel = GUICtrlCreateLabel("", 20, 180, 70, 30) GUICtrlSetFont($hLabel, 0, 600) GUICtrlSetColor($hLabel, 0x0000FF) GUICtrlSetTip($hLabel, "Top-level Domain") Global $hPic = GUICtrlCreatePic("", 112, 110, 275, 183) GUICtrlSetState($hButton, $GUI_FOCUS) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $sTLD = GetCountryTLD(GUICtrlRead($hInput)) If $sTLD Then SetNationalFlag($hPic, $sTLD) GUICtrlSetData($hLabel, "." & $sTLD) EndIf EndSwitch WEnd Func SetNationalFlag($hControl, $sMoniker) Local $vData = InetRead(StringFormat($sFormat, StringLower($sMoniker)), 16) If $vData Then _GUICtrlSetGIF($hControl, $vData) GUICtrlSetState($hControl, $GUI_SHOW) Else GUICtrlSetState($hControl, $GUI_HIDE) EndIf EndFunc Func GetCountryTLD($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 $sTLD, $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 $sTLD 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 $sTLD $sTLD = $aCall[3] ExitLoop EndIf Next Return $sTLD EndFunc Or this variation of the same thing:expandcollapse popup#include "GIFAnimation.au3" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> Global $sCountry = "Portugal" Global Const $sFormat = "http://flagpedia.net/data/flags/normal/%s.png" Global $sTLD Global $hGui = GUICreate("National flags", 500, 350) Global $hInput = GUICtrlCreateInput($sCountry, 20, 30, 160, 30) GUICtrlSetFont($hInput, 0) Global $hComboBox = GUICtrlCreateCombo($sCountry, 20, 61, 160, 30, BitOR($WS_VSCROLL, $CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData($hComboBox, ListCountries()) Global $hButton = GUICtrlCreateButton("&Show national flag", 200, 30, 140, 30) GUICtrlSetFont($hButton, 0) Global $hLabel = GUICtrlCreateLabel("", 20, 180, 70, 30) GUICtrlSetFont($hLabel, 0, 600) GUICtrlSetColor($hLabel, 0x0000FF) GUICtrlSetTip($hLabel, "Top-level Domain") Global $hLabelNotAvailable = GUICtrlCreateLabel(@CRLF & @CRLF & " NOT AVAILABLE!", 112, 110, 275, 183) GUICtrlSetFont($hLabelNotAvailable, 22, 600, -1, "Tahoma") GUICtrlSetColor($hLabelNotAvailable, 0xAAAAAA) GUICtrlSetBkColor($hLabelNotAvailable, 0xFFFFFF) GUICtrlSetState($hLabelNotAvailable, $GUI_HIDE) Global $hPic = GUICtrlCreatePic("", 112, 110, 275, 183) GUICtrlSetState($hButton, $GUI_FOCUS) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton GUISetCursor(15, 1) ; WAIT $sTLD = GetCountryTLD(GUICtrlRead($hInput)) SetNationalFlag($hPic, $sTLD, $hLabelNotAvailable) If $sTLD Then GUICtrlSetData($hLabel, "." & $sTLD) Else GUICtrlSetData($hLabel, "") EndIf GUISetCursor(-1, 0) ; restore default Case $hComboBox GUICtrlSetData($hInput, GUICtrlRead($hComboBox)) EndSwitch WEnd Func SetNationalFlag($hPicControl, $sMoniker, $hLabelControl) Local $vData = InetRead(StringFormat($sFormat, StringLower($sMoniker)), 16) If $vData Then _GUICtrlSetGIF($hPicControl, $vData) GUICtrlSetState($hLabelControl, $GUI_HIDE) GUICtrlSetState($hPicControl, $GUI_SHOW) Else GUICtrlSetState($hPicControl, $GUI_HIDE) GUICtrlSetState($hLabelControl, $GUI_SHOW) EndIf EndFunc Func GetCountryTLD($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 $sTLD, $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 $sTLD 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 $sTLD $sTLD = $aCall[3] ExitLoop EndIf Next Return $sTLD EndFunc Func ListCountries() Local Const $GEO_FRIENDLYNAME = 0x0008 Local $sOut, $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 ExitLoop If $aCall[3] Then $sOut &= $aCall[3] & "|" Next Return StringTrimRight($sOut, 1) EndFuncYou can find included GIFAnimation.au3 >here (it's link, follow it). Put that script in the same folder as the example before you run it, it's used to display the national flags without the need to download them to files.In the example script you will also find GetCountryTLD function. Is that close to what you meant? Edited September 22, 2013 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
michaelslamet Posted September 22, 2013 Share Posted September 22, 2013 Nice script, trancexx, like usual My boy like it a lot as his favorite book is a world altas with maps and country flag Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2013 Share Posted September 22, 2013 Nice script, trancexx, like usual My boy like it a lot as his favorite book is a world altas with maps and country flag Kisses to your young explorer from Dragana . ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
michaelslamet Posted September 23, 2013 Share Posted September 23, 2013 Kisses to your young explorer from Dragana . And to his father too? 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