Fade91

Country Location

15 posts in this topic

#1 ·  Posted (edited)

This was just a simple project for myself but may be someone else will find it interesting.

 

#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 by Fade91

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Works for me :D

f19ab0e12e0f807f0e18f0962e93a450.png

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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

 

 000182.jpg

1 person likes this

My Contributions

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)

 

Share this post


Link to post
Share on other sites

@kcvinu You live in US? I was in the impression that you live in Kerala :)

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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

 


My Contributions

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)

 

Share this post


Link to post
Share on other sites

@kcvinu It is not a prank, Did forgot to change your language to English (India) while installing windows?

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

May be.

 


My Contributions

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)

 

Share this post


Link to post
Share on other sites

@kcvinu Here is a reminder :D

58be69a4f843129e6fa494c9c6acd7be.png

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
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"

1 person likes this

Share this post


Link to post
Share on other sites

#12 ·  Posted (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 by kcvinu

My Contributions

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)

 

Share this post


Link to post
Share on other sites

@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

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
$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

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (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 by Fade91

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