Jump to content

How do i get Country TLD and Flag


redfire
 Share

Recommended Posts

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

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 - 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 (NEW 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

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

 

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

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 - 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 (NEW 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

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

@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 o:)

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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:

#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:

#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)
EndFunc
You 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 by trancexx

♡♡♡

.

eMyvnE

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...