Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

AutoIt Snippets


  • Please log in to reply
156 replies to this topic

#141 guestscripter

guestscripter

    Wayfarer

  • Active Members
  • Pip
  • 73 posts

Posted 12 January 2014 - 09:32 PM

Use to convert data from "Name = XXXX YYYY" to "Surname = YYY, First Name = XXXXXX" 

AutoIt         
  1. Local $sFullName = " Harry J T.  Potter"
  2. Local $aFirstnamesLast = splitfirstlastname($sFullName)
  3. ConsoleWrite($aFirstnamesLast[0] & @CR)
  4. ConsoleWrite($aFirstnamesLast[1] & @CR)
  5.  
  6. Func splitfirstlastname($sFullName)
  7.     Local $aWords = StringSplit(StringStripWS($sFullName, 7), " ");Clean out leading/trailing/double+ spaces, and Split into words
  8.     Local $sFirstnames, $sLastname
  9.     $sLastname = $aWords[$aWords[0]];Assume the last (or only) word is the last name
  10.     Select
  11.         Case $aWords[0] = 1;Assume no first name if only one word
  12.             $sFirstnames = ""
  13.         Case $aWords[0] = 2;If two words, assume this is the first and last name in that order
  14.             $sFirstnames = $aWords[1]
  15.         Case $aWords[0] > 2;If more than two words, all except the last are first names
  16.             For $n = 1 To $aWords[0] - 2
  17.                 $sFirstnames &= $aWords[$n] & " "
  18.             Next
  19.             $sFirstnames &= $aWords[$aWords[0] - 1]
  20.     EndSelect
  21.     Dim $aFirstnamesLast[] = [$sFirstnames, $sLastname]
  22.     Return $aFirstnamesLast
  23. EndFunc   ;==>splitfirstlastname








#142 guestscripter

guestscripter

    Wayfarer

  • Active Members
  • Pip
  • 73 posts

Posted 12 January 2014 - 10:26 PM

 Use to convert data that has country names to their corresponding 2-digit codes.

AutoIt         
  1.  
  2. Local $sCountry = "Fiji"
  3. ConsoleWrite("ISO Country Code: " & _CountryNameToISO($sCountry) & @CR)
  4.  
  5. Func _CountryNameToISO($sCountry)
  6.     Local $sCountryCode
  7.     ;names and codes according to
  8.     ;http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm
  9.     ;updated in December 2013
  10.     If $sCountry = "AFGHANISTAN" Then $sCountryCode = "AF"
  11.     If $sCountry = "ÅLAND ISLANDS" Then $sCountryCode = "AX"
  12.     If $sCountry = "ALBANIA" Then $sCountryCode = "AL"
  13.     If $sCountry = "ALGERIA" Then $sCountryCode = "DZ"
  14.     If $sCountry = "AMERICAN SAMOA" Then $sCountryCode = "AS"
  15.     If $sCountry = "ANDORRA" Then $sCountryCode = "AD"
  16.     If $sCountry = "ANGOLA" Then $sCountryCode = "AO"
  17.     If $sCountry = "ANGUILLA" Then $sCountryCode = "AI"
  18.     If $sCountry = "ANTARCTICA" Then $sCountryCode = "AQ"
  19.     If $sCountry = "ANTIGUA AND BARBUDA" Then $sCountryCode = "AG"
  20.     If $sCountry = "ARGENTINA" Then $sCountryCode = "AR"
  21.     If $sCountry = "ARMENIA" Then $sCountryCode = "AM"
  22.     If $sCountry = "ARUBA" Then $sCountryCode = "AW"
  23.     If $sCountry = "AUSTRALIA" Then $sCountryCode = "AU"
  24.     If $sCountry = "AUSTRIA" Then $sCountryCode = "AT"
  25.     If $sCountry = "AZERBAIJAN" Then $sCountryCode = "AZ"
  26.     If $sCountry = "BAHAMAS" Then $sCountryCode = "BS"
  27.     If $sCountry = "BAHRAIN" Then $sCountryCode = "BH"
  28.     If $sCountry = "BANGLADESH" Then $sCountryCode = "BD"
  29.     If $sCountry = "BARBADOS" Then $sCountryCode = "BB"
  30.     If $sCountry = "BELARUS" Then $sCountryCode = "BY"
  31.     If $sCountry = "BELGIUM" Then $sCountryCode = "BE"
  32.     If $sCountry = "BELIZE" Then $sCountryCode = "BZ"
  33.     If $sCountry = "BENIN" Then $sCountryCode = "BJ"
  34.     If $sCountry = "BERMUDA" Then $sCountryCode = "BM"
  35.     If $sCountry = "BHUTAN" Then $sCountryCode = "BT"
  36.     If $sCountry = "BOLIVIA, PLURINATIONAL STATE OF" Then $sCountryCode = "BO"
  37.     If $sCountry = "BONAIRE, SINT EUSTATIUS AND SABA" Then $sCountryCode = "BQ"
  38.     If $sCountry = "BOSNIA AND HERZEGOVINA" Then $sCountryCode = "BA"
  39.     If $sCountry = "BOTSWANA" Then $sCountryCode = "BW"
  40.     If $sCountry = "BOUVET ISLAND" Then $sCountryCode = "BV"
  41.     If $sCountry = "BRAZIL" Then $sCountryCode = "BR"
  42.     If $sCountry = "BRITISH INDIAN OCEAN TERRITORY" Then $sCountryCode = "IO"
  43.     If $sCountry = "BRUNEI DARUSSALAM" Then $sCountryCode = "BN"
  44.     If $sCountry = "BULGARIA" Then $sCountryCode = "BG"
  45.     If $sCountry = "BURKINA FASO" Then $sCountryCode = "BF"
  46.     If $sCountry = "BURUNDI" Then $sCountryCode = "BI"
  47.     If $sCountry = "CAMBODIA" Then $sCountryCode = "KH"
  48.     If $sCountry = "CAMEROON" Then $sCountryCode = "CM"
  49.     If $sCountry = "CANADA" Then $sCountryCode = "CA"
  50.     If $sCountry = "CAPE VERDE" Then $sCountryCode = "CV"
  51.     If $sCountry = "CAYMAN ISLANDS" Then $sCountryCode = "KY"
  52.     If $sCountry = "CENTRAL AFRICAN REPUBLIC" Then $sCountryCode = "CF"
  53.     If $sCountry = "CHAD" Then $sCountryCode = "TD"
  54.     If $sCountry = "CHILE" Then $sCountryCode = "CL"
  55.     If $sCountry = "CHINA" Then $sCountryCode = "CN"
  56.     If $sCountry = "CHRISTMAS ISLAND" Then $sCountryCode = "CX"
  57.     If $sCountry = "COCOS (KEELING) ISLANDS" Then $sCountryCode = "CC"
  58.     If $sCountry = "COLOMBIA" Then $sCountryCode = "CO"
  59.     If $sCountry = "COMOROS" Then $sCountryCode = "KM"
  60.     If $sCountry = "CONGO" Then $sCountryCode = "CG"
  61.     If $sCountry = "CONGO, THE DEMOCRATIC REPUBLIC OF THE" Then $sCountryCode = "CD"
  62.     If $sCountry = "COOK ISLANDS" Then $sCountryCode = "CK"
  63.     If $sCountry = "COSTA RICA" Then $sCountryCode = "CR"
  64.     If $sCountry = "CÔTE D'IVOIRE" Then $sCountryCode = "CI"
  65.     If $sCountry = "CROATIA" Then $sCountryCode = "HR"
  66.     If $sCountry = "CUBA" Then $sCountryCode = "CU"
  67.     If $sCountry = "CURAÇAO" Then $sCountryCode = "CW"
  68.     If $sCountry = "CYPRUS" Then $sCountryCode = "CY"
  69.     If $sCountry = "CZECH REPUBLIC" Then $sCountryCode = "CZ"
  70.     If $sCountry = "DENMARK" Then $sCountryCode = "DK"
  71.     If $sCountry = "DJIBOUTI" Then $sCountryCode = "DJ"
  72.     If $sCountry = "DOMINICA" Then $sCountryCode = "DM"
  73.     If $sCountry = "DOMINICAN REPUBLIC" Then $sCountryCode = "DO"
  74.     If $sCountry = "ECUADOR" Then $sCountryCode = "EC"
  75.     If $sCountry = "EGYPT" Then $sCountryCode = "EG"
  76.     If $sCountry = "EL SALVADOR" Then $sCountryCode = "SV"
  77.     If $sCountry = "EQUATORIAL GUINEA" Then $sCountryCode = "GQ"
  78.     If $sCountry = "ERITREA" Then $sCountryCode = "ER"
  79.     If $sCountry = "ESTONIA" Then $sCountryCode = "EE"
  80.     If $sCountry = "ETHIOPIA" Then $sCountryCode = "ET"
  81.     If $sCountry = "FALKLAND ISLANDS (MALVINAS)" Then $sCountryCode = "FK"
  82.     If $sCountry = "FAROE ISLANDS" Then $sCountryCode = "FO"
  83.     If $sCountry = "FIJI" Then $sCountryCode = "FJ"
  84.     If $sCountry = "FINLAND" Then $sCountryCode = "FI"
  85.     If $sCountry = "FRANCE" Then $sCountryCode = "FR"
  86.     If $sCountry = "FRENCH GUIANA" Then $sCountryCode = "GF"
  87.     If $sCountry = "FRENCH POLYNESIA" Then $sCountryCode = "PF"
  88.     If $sCountry = "FRENCH SOUTHERN TERRITORIES" Then $sCountryCode = "TF"
  89.     If $sCountry = "GABON" Then $sCountryCode = "GA"
  90.     If $sCountry = "GAMBIA" Then $sCountryCode = "GM"
  91.     If $sCountry = "GEORGIA" Then $sCountryCode = "GE"
  92.     If $sCountry = "GERMANY" Then $sCountryCode = "DE"
  93.     If $sCountry = "GHANA" Then $sCountryCode = "GH"
  94.     If $sCountry = "GIBRALTAR" Then $sCountryCode = "GI"
  95.     If $sCountry = "GREECE" Then $sCountryCode = "GR"
  96.     If $sCountry = "GREENLAND" Then $sCountryCode = "GL"
  97.     If $sCountry = "GRENADA" Then $sCountryCode = "GD"
  98.     If $sCountry = "GUADELOUPE" Then $sCountryCode = "GP"
  99.     If $sCountry = "GUAM" Then $sCountryCode = "GU"
  100.     If $sCountry = "GUATEMALA" Then $sCountryCode = "GT"
  101.     If $sCountry = "GUERNSEY" Then $sCountryCode = "GG"
  102.     If $sCountry = "GUINEA" Then $sCountryCode = "GN"
  103.     If $sCountry = "GUINEA-BISSAU" Then $sCountryCode = "GW"
  104.     If $sCountry = "GUYANA" Then $sCountryCode = "GY"
  105.     If $sCountry = "HAITI" Then $sCountryCode = "HT"
  106.     If $sCountry = "HEARD ISLAND AND MCDONALD ISLANDS" Then $sCountryCode = "HM"
  107.     If $sCountry = "HOLY SEE (VATICAN CITY STATE)" Then $sCountryCode = "VA"
  108.     If $sCountry = "HONDURAS" Then $sCountryCode = "HN"
  109.     If $sCountry = "HONG KONG" Then $sCountryCode = "HK"
  110.     If $sCountry = "HUNGARY" Then $sCountryCode = "HU"
  111.     If $sCountry = "ICELAND" Then $sCountryCode = "IS"
  112.     If $sCountry = "INDIA" Then $sCountryCode = "IN"
  113.     If $sCountry = "INDONESIA" Then $sCountryCode = "ID"
  114.     If $sCountry = "IRAN, ISLAMIC REPUBLIC OF" Then $sCountryCode = "IR"
  115.     If $sCountry = "IRAQ" Then $sCountryCode = "IQ"
  116.     If $sCountry = "IRELAND" Then $sCountryCode = "IE"
  117.     If $sCountry = "ISLE OF MAN" Then $sCountryCode = "IM"
  118.     If $sCountry = "ISRAEL" Then $sCountryCode = "IL"
  119.     If $sCountry = "ITALY" Then $sCountryCode = "IT"
  120.     If $sCountry = "JAMAICA" Then $sCountryCode = "JM"
  121.     If $sCountry = "JAPAN" Then $sCountryCode = "JP"
  122.     If $sCountry = "JERSEY" Then $sCountryCode = "JE"
  123.     If $sCountry = "JORDAN" Then $sCountryCode = "JO"
  124.     If $sCountry = "KAZAKHSTAN" Then $sCountryCode = "KZ"
  125.     If $sCountry = "KENYA" Then $sCountryCode = "KE"
  126.     If $sCountry = "KIRIBATI" Then $sCountryCode = "KI"
  127.     If $sCountry = "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF" Then $sCountryCode = "KP"
  128.     If $sCountry = "KOREA, REPUBLIC OF" Then $sCountryCode = "KR"
  129.     If $sCountry = "KUWAIT" Then $sCountryCode = "KW"
  130.     If $sCountry = "KYRGYZSTAN" Then $sCountryCode = "KG"
  131.     If $sCountry = "LAO PEOPLE'S DEMOCRATIC REPUBLIC" Then $sCountryCode = "LA"
  132.     If $sCountry = "LATVIA" Then $sCountryCode = "LV"
  133.     If $sCountry = "LEBANON" Then $sCountryCode = "LB"
  134.     If $sCountry = "LESOTHO" Then $sCountryCode = "LS"
  135.     If $sCountry = "LIBERIA" Then $sCountryCode = "LR"
  136.     If $sCountry = "LIBYA" Then $sCountryCode = "LY"
  137.     If $sCountry = "LIECHTENSTEIN" Then $sCountryCode = "LI"
  138.     If $sCountry = "LITHUANIA" Then $sCountryCode = "LT"
  139.     If $sCountry = "LUXEMBOURG" Then $sCountryCode = "LU"
  140.     If $sCountry = "MACAO" Then $sCountryCode = "MO"
  141.     If $sCountry = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF" Then $sCountryCode = "MK"
  142.     If $sCountry = "MADAGASCAR" Then $sCountryCode = "MG"
  143.     If $sCountry = "MALAWI" Then $sCountryCode = "MW"
  144.     If $sCountry = "MALAYSIA" Then $sCountryCode = "MY"
  145.     If $sCountry = "MALDIVES" Then $sCountryCode = "MV"
  146.     If $sCountry = "MALI" Then $sCountryCode = "ML"
  147.     If $sCountry = "MALTA" Then $sCountryCode = "MT"
  148.     If $sCountry = "MARSHALL ISLANDS" Then $sCountryCode = "MH"
  149.     If $sCountry = "MARTINIQUE" Then $sCountryCode = "MQ"
  150.     If $sCountry = "MAURITANIA" Then $sCountryCode = "MR"
  151.     If $sCountry = "MAURITIUS" Then $sCountryCode = "MU"
  152.     If $sCountry = "MAYOTTE" Then $sCountryCode = "YT"
  153.     If $sCountry = "MEXICO" Then $sCountryCode = "MX"
  154.     If $sCountry = "MICRONESIA, FEDERATED STATES OF" Then $sCountryCode = "FM"
  155.     If $sCountry = "MOLDOVA, REPUBLIC OF" Then $sCountryCode = "MD"
  156.     If $sCountry = "MONACO" Then $sCountryCode = "MC"
  157.     If $sCountry = "MONGOLIA" Then $sCountryCode = "MN"
  158.     If $sCountry = "MONTENEGRO" Then $sCountryCode = "ME"
  159.     If $sCountry = "MONTSERRAT" Then $sCountryCode = "MS"
  160.     If $sCountry = "MOROCCO" Then $sCountryCode = "MA"
  161.     If $sCountry = "MOZAMBIQUE" Then $sCountryCode = "MZ"
  162.     If $sCountry = "MYANMAR" Then $sCountryCode = "MM"
  163.     If $sCountry = "NAMIBIA" Then $sCountryCode = "NA"
  164.     If $sCountry = "NAURU" Then $sCountryCode = "NR"
  165.     If $sCountry = "NEPAL" Then $sCountryCode = "NP"
  166.     If $sCountry = "NETHERLANDS" Then $sCountryCode = "NL"
  167.     If $sCountry = "NEW CALEDONIA" Then $sCountryCode = "NC"
  168.     If $sCountry = "NEW ZEALAND" Then $sCountryCode = "NZ"
  169.     If $sCountry = "NICARAGUA" Then $sCountryCode = "NI"
  170.     If $sCountry = "NIGER" Then $sCountryCode = "NE"
  171.     If $sCountry = "NIGERIA" Then $sCountryCode = "NG"
  172.     If $sCountry = "NIUE" Then $sCountryCode = "NU"
  173.     If $sCountry = "NORFOLK ISLAND" Then $sCountryCode = "NF"
  174.     If $sCountry = "NORTHERN MARIANA ISLANDS" Then $sCountryCode = "MP"
  175.     If $sCountry = "NORWAY" Then $sCountryCode = "NO"
  176.     If $sCountry = "OMAN" Then $sCountryCode = "OM"
  177.     If $sCountry = "PAKISTAN" Then $sCountryCode = "PK"
  178.     If $sCountry = "PALAU" Then $sCountryCode = "PW"
  179.     If $sCountry = "PALESTINE, STATE OF" Then $sCountryCode = "PS"
  180.     If $sCountry = "PANAMA" Then $sCountryCode = "PA"
  181.     If $sCountry = "PAPUA NEW GUINEA" Then $sCountryCode = "PG"
  182.     If $sCountry = "PARAGUAY" Then $sCountryCode = "PY"
  183.     If $sCountry = "PERU" Then $sCountryCode = "PE"
  184.     If $sCountry = "PHILIPPINES" Then $sCountryCode = "PH"
  185.     If $sCountry = "PITCAIRN" Then $sCountryCode = "PN"
  186.     If $sCountry = "POLAND" Then $sCountryCode = "PL"
  187.     If $sCountry = "PORTUGAL" Then $sCountryCode = "PT"
  188.     If $sCountry = "PUERTO RICO" Then $sCountryCode = "PR"
  189.     If $sCountry = "QATAR" Then $sCountryCode = "QA"
  190.     If $sCountry = "RÉUNION" Then $sCountryCode = "RE"
  191.     If $sCountry = "ROMANIA" Then $sCountryCode = "RO"
  192.     If $sCountry = "RUSSIAN FEDERATION" Then $sCountryCode = "RU"
  193.     If $sCountry = "RWANDA" Then $sCountryCode = "RW"
  194.     If $sCountry = "SAINT BARTHÉLEMY" Then $sCountryCode = "BL"
  195.     If $sCountry = "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA" Then $sCountryCode = "SH"
  196.     If $sCountry = "SAINT KITTS AND NEVIS" Then $sCountryCode = "KN"
  197.     If $sCountry = "SAINT LUCIA" Then $sCountryCode = "LC"
  198.     If $sCountry = "SAINT MARTIN (FRENCH PART)" Then $sCountryCode = "MF"
  199.     If $sCountry = "SAINT PIERRE AND MIQUELON" Then $sCountryCode = "PM"
  200.     If $sCountry = "SAINT VINCENT AND THE GRENADINES" Then $sCountryCode = "VC"
  201.     If $sCountry = "SAMOA" Then $sCountryCode = "WS"
  202.     If $sCountry = "SAN MARINO" Then $sCountryCode = "SM"
  203.     If $sCountry = "SAO TOME AND PRINCIPE" Then $sCountryCode = "ST"
  204.     If $sCountry = "SAUDI ARABIA" Then $sCountryCode = "SA"
  205.     If $sCountry = "SENEGAL" Then $sCountryCode = "SN"
  206.     If $sCountry = "SERBIA" Then $sCountryCode = "RS"
  207.     If $sCountry = "SEYCHELLES" Then $sCountryCode = "SC"
  208.     If $sCountry = "SIERRA LEONE" Then $sCountryCode = "SL"
  209.     If $sCountry = "SINGAPORE" Then $sCountryCode = "SG"
  210.     If $sCountry = "SINT MAARTEN (DUTCH PART)" Then $sCountryCode = "SX"
  211.     If $sCountry = "SLOVAKIA" Then $sCountryCode = "SK"
  212.     If $sCountry = "SLOVENIA" Then $sCountryCode = "SI"
  213.     If $sCountry = "SOLOMON ISLANDS" Then $sCountryCode = "SB"
  214.     If $sCountry = "SOMALIA" Then $sCountryCode = "SO"
  215.     If $sCountry = "SOUTH AFRICA" Then $sCountryCode = "ZA"
  216.     If $sCountry = "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS" Then $sCountryCode = "GS"
  217.     If $sCountry = "SOUTH SUDAN" Then $sCountryCode = "SS"
  218.     If $sCountry = "SPAIN" Then $sCountryCode = "ES"
  219.     If $sCountry = "SRI LANKA" Then $sCountryCode = "LK"
  220.     If $sCountry = "SUDAN" Then $sCountryCode = "SD"
  221.     If $sCountry = "SURINAME" Then $sCountryCode = "SR"
  222.     If $sCountry = "SVALBARD AND JAN MAYEN" Then $sCountryCode = "SJ"
  223.     If $sCountry = "SWAZILAND" Then $sCountryCode = "SZ"
  224.     If $sCountry = "SWEDEN" Then $sCountryCode = "SE"
  225.     If $sCountry = "SWITZERLAND" Then $sCountryCode = "CH"
  226.     If $sCountry = "SYRIAN ARAB REPUBLIC" Then $sCountryCode = "SY"
  227.     If $sCountry = "TAIWAN, PROVINCE OF CHINA" Then $sCountryCode = "TW"
  228.     If $sCountry = "TAJIKISTAN" Then $sCountryCode = "TJ"
  229.     If $sCountry = "TANZANIA, UNITED REPUBLIC OF" Then $sCountryCode = "TZ"
  230.     If $sCountry = "THAILAND" Then $sCountryCode = "TH"
  231.     If $sCountry = "TIMOR-LESTE" Then $sCountryCode = "TL"
  232.     If $sCountry = "TOGO" Then $sCountryCode = "TG"
  233.     If $sCountry = "TOKELAU" Then $sCountryCode = "TK"
  234.     If $sCountry = "TONGA" Then $sCountryCode = "TO"
  235.     If $sCountry = "TRINIDAD AND TOBAGO" Then $sCountryCode = "TT"
  236.     If $sCountry = "TUNISIA" Then $sCountryCode = "TN"
  237.     If $sCountry = "TURKEY" Then $sCountryCode = "TR"
  238.     If $sCountry = "TURKMENISTAN" Then $sCountryCode = "TM"
  239.     If $sCountry = "TURKS AND CAICOS ISLANDS" Then $sCountryCode = "TC"
  240.     If $sCountry = "TUVALU" Then $sCountryCode = "TV"
  241.     If $sCountry = "UGANDA" Then $sCountryCode = "UG"
  242.     If $sCountry = "UKRAINE" Then $sCountryCode = "UA"
  243.     If $sCountry = "UNITED ARAB EMIRATES" Then $sCountryCode = "AE"
  244.     If $sCountry = "UNITED KINGDOM" Then $sCountryCode = "GB"
  245.     If $sCountry = "UNITED STATES" Then $sCountryCode = "US"
  246.     If $sCountry = "UNITED STATES MINOR OUTLYING ISLANDS" Then $sCountryCode = "UM"
  247.     If $sCountry = "URUGUAY" Then $sCountryCode = "UY"
  248.     If $sCountry = "UZBEKISTAN" Then $sCountryCode = "UZ"
  249.     If $sCountry = "VANUATU" Then $sCountryCode = "VU"
  250.     If $sCountry = "VENEZUELA, BOLIVARIAN REPUBLIC OF" Then $sCountryCode = "VE"
  251.     If $sCountry = "VIET NAM" Then $sCountryCode = "VN"
  252.     If $sCountry = "VIRGIN ISLANDS, BRITISH" Then $sCountryCode = "VG"
  253.     If $sCountry = "VIRGIN ISLANDS, U.S." Then $sCountryCode = "VI"
  254.     If $sCountry = "WALLIS AND FUTUNA" Then $sCountryCode = "WF"
  255.     If $sCountry = "WESTERN SAHARA" Then $sCountryCode = "EH"
  256.     If $sCountry = "YEMEN" Then $sCountryCode = "YE"
  257.     If $sCountry = "ZAMBIA" Then $sCountryCode = "ZM"
  258.     If $sCountry = "ZIMBABWE" Then $sCountryCode = "ZW"
  259.     Return $sCountryCode
  260. EndFunc   ;==>_CountryNameToISO


#143 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 24 February 2014 - 03:32 AM

 

 Use to convert data that has country names to their corresponding 2-digit codes.

AutoIt         
  1.  
  2. Local $sCountry = "Fiji"
  3. ConsoleWrite("ISO Country Code: " & _CountryNameToISO($sCountry) & @CR)
  4.  
  5. Func _CountryNameToISO($sCountry)
  6.     Local $sCountryCode
  7.     ;names and codes according to
  8.     ;http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm
  9.     ;updated in December 2013
  10.     If $sCountry = "AFGHANISTAN" Then $sCountryCode = "AF"
  11.     If $sCountry = "ÅLAND ISLANDS" Then $sCountryCode = "AX"
  12.     If $sCountry = "ALBANIA" Then $sCountryCode = "AL"
  13.     If $sCountry = "ALGERIA" Then $sCountryCode = "DZ"
  14.     If $sCountry = "AMERICAN SAMOA" Then $sCountryCode = "AS"
  15.     If $sCountry = "ANDORRA" Then $sCountryCode = "AD"
  16.     If $sCountry = "ANGOLA" Then $sCountryCode = "AO"
  17.     If $sCountry = "ANGUILLA" Then $sCountryCode = "AI"
  18.     If $sCountry = "ANTARCTICA" Then $sCountryCode = "AQ"
  19.     If $sCountry = "ANTIGUA AND BARBUDA" Then $sCountryCode = "AG"
  20.     If $sCountry = "ARGENTINA" Then $sCountryCode = "AR"
  21.     If $sCountry = "ARMENIA" Then $sCountryCode = "AM"
  22.     If $sCountry = "ARUBA" Then $sCountryCode = "AW"
  23.     If $sCountry = "AUSTRALIA" Then $sCountryCode = "AU"
  24.     If $sCountry = "AUSTRIA" Then $sCountryCode = "AT"
  25.     If $sCountry = "AZERBAIJAN" Then $sCountryCode = "AZ"
  26.     If $sCountry = "BAHAMAS" Then $sCountryCode = "BS"
  27.     If $sCountry = "BAHRAIN" Then $sCountryCode = "BH"
  28.     If $sCountry = "BANGLADESH" Then $sCountryCode = "BD"
  29.     If $sCountry = "BARBADOS" Then $sCountryCode = "BB"
  30.     If $sCountry = "BELARUS" Then $sCountryCode = "BY"
  31.     If $sCountry = "BELGIUM" Then $sCountryCode = "BE"
  32.     If $sCountry = "BELIZE" Then $sCountryCode = "BZ"
  33.     If $sCountry = "BENIN" Then $sCountryCode = "BJ"
  34.     If $sCountry = "BERMUDA" Then $sCountryCode = "BM"
  35.     If $sCountry = "BHUTAN" Then $sCountryCode = "BT"
  36.     If $sCountry = "BOLIVIA, PLURINATIONAL STATE OF" Then $sCountryCode = "BO"
  37.     If $sCountry = "BONAIRE, SINT EUSTATIUS AND SABA" Then $sCountryCode = "BQ"
  38.     If $sCountry = "BOSNIA AND HERZEGOVINA" Then $sCountryCode = "BA"
  39.     If $sCountry = "BOTSWANA" Then $sCountryCode = "BW"
  40.     If $sCountry = "BOUVET ISLAND" Then $sCountryCode = "BV"
  41.     If $sCountry = "BRAZIL" Then $sCountryCode = "BR"
  42.     If $sCountry = "BRITISH INDIAN OCEAN TERRITORY" Then $sCountryCode = "IO"
  43.     If $sCountry = "BRUNEI DARUSSALAM" Then $sCountryCode = "BN"
  44.     If $sCountry = "BULGARIA" Then $sCountryCode = "BG"
  45.     If $sCountry = "BURKINA FASO" Then $sCountryCode = "BF"
  46.     If $sCountry = "BURUNDI" Then $sCountryCode = "BI"
  47.     If $sCountry = "CAMBODIA" Then $sCountryCode = "KH"
  48.     If $sCountry = "CAMEROON" Then $sCountryCode = "CM"
  49.     If $sCountry = "CANADA" Then $sCountryCode = "CA"
  50.     If $sCountry = "CAPE VERDE" Then $sCountryCode = "CV"
  51.     If $sCountry = "CAYMAN ISLANDS" Then $sCountryCode = "KY"
  52.     If $sCountry = "CENTRAL AFRICAN REPUBLIC" Then $sCountryCode = "CF"
  53.     If $sCountry = "CHAD" Then $sCountryCode = "TD"
  54.     If $sCountry = "CHILE" Then $sCountryCode = "CL"
  55.     If $sCountry = "CHINA" Then $sCountryCode = "CN"
  56.     If $sCountry = "CHRISTMAS ISLAND" Then $sCountryCode = "CX"
  57.     If $sCountry = "COCOS (KEELING) ISLANDS" Then $sCountryCode = "CC"
  58.     If $sCountry = "COLOMBIA" Then $sCountryCode = "CO"
  59.     If $sCountry = "COMOROS" Then $sCountryCode = "KM"
  60.     If $sCountry = "CONGO" Then $sCountryCode = "CG"
  61.     If $sCountry = "CONGO, THE DEMOCRATIC REPUBLIC OF THE" Then $sCountryCode = "CD"
  62.     If $sCountry = "COOK ISLANDS" Then $sCountryCode = "CK"
  63.     If $sCountry = "COSTA RICA" Then $sCountryCode = "CR"
  64.     If $sCountry = "CÔTE D'IVOIRE" Then $sCountryCode = "CI"
  65.     If $sCountry = "CROATIA" Then $sCountryCode = "HR"
  66.     If $sCountry = "CUBA" Then $sCountryCode = "CU"
  67.     If $sCountry = "CURAÇAO" Then $sCountryCode = "CW"
  68.     If $sCountry = "CYPRUS" Then $sCountryCode = "CY"
  69.     If $sCountry = "CZECH REPUBLIC" Then $sCountryCode = "CZ"
  70.     If $sCountry = "DENMARK" Then $sCountryCode = "DK"
  71.     If $sCountry = "DJIBOUTI" Then $sCountryCode = "DJ"
  72.     If $sCountry = "DOMINICA" Then $sCountryCode = "DM"
  73.     If $sCountry = "DOMINICAN REPUBLIC" Then $sCountryCode = "DO"
  74.     If $sCountry = "ECUADOR" Then $sCountryCode = "EC"
  75.     If $sCountry = "EGYPT" Then $sCountryCode = "EG"
  76.     If $sCountry = "EL SALVADOR" Then $sCountryCode = "SV"
  77.     If $sCountry = "EQUATORIAL GUINEA" Then $sCountryCode = "GQ"
  78.     If $sCountry = "ERITREA" Then $sCountryCode = "ER"
  79.     If $sCountry = "ESTONIA" Then $sCountryCode = "EE"
  80.     If $sCountry = "ETHIOPIA" Then $sCountryCode = "ET"
  81.     If $sCountry = "FALKLAND ISLANDS (MALVINAS)" Then $sCountryCode = "FK"
  82.     If $sCountry = "FAROE ISLANDS" Then $sCountryCode = "FO"
  83.     If $sCountry = "FIJI" Then $sCountryCode = "FJ"
  84.     If $sCountry = "FINLAND" Then $sCountryCode = "FI"
  85.     If $sCountry = "FRANCE" Then $sCountryCode = "FR"
  86.     If $sCountry = "FRENCH GUIANA" Then $sCountryCode = "GF"
  87.     If $sCountry = "FRENCH POLYNESIA" Then $sCountryCode = "PF"
  88.     If $sCountry = "FRENCH SOUTHERN TERRITORIES" Then $sCountryCode = "TF"
  89.     If $sCountry = "GABON" Then $sCountryCode = "GA"
  90.     If $sCountry = "GAMBIA" Then $sCountryCode = "GM"
  91.     If $sCountry = "GEORGIA" Then $sCountryCode = "GE"
  92.     If $sCountry = "GERMANY" Then $sCountryCode = "DE"
  93.     If $sCountry = "GHANA" Then $sCountryCode = "GH"
  94.     If $sCountry = "GIBRALTAR" Then $sCountryCode = "GI"
  95.     If $sCountry = "GREECE" Then $sCountryCode = "GR"
  96.     If $sCountry = "GREENLAND" Then $sCountryCode = "GL"
  97.     If $sCountry = "GRENADA" Then $sCountryCode = "GD"
  98.     If $sCountry = "GUADELOUPE" Then $sCountryCode = "GP"
  99.     If $sCountry = "GUAM" Then $sCountryCode = "GU"
  100.     If $sCountry = "GUATEMALA" Then $sCountryCode = "GT"
  101.     If $sCountry = "GUERNSEY" Then $sCountryCode = "GG"
  102.     If $sCountry = "GUINEA" Then $sCountryCode = "GN"
  103.     If $sCountry = "GUINEA-BISSAU" Then $sCountryCode = "GW"
  104.     If $sCountry = "GUYANA" Then $sCountryCode = "GY"
  105.     If $sCountry = "HAITI" Then $sCountryCode = "HT"
  106.     If $sCountry = "HEARD ISLAND AND MCDONALD ISLANDS" Then $sCountryCode = "HM"
  107.     If $sCountry = "HOLY SEE (VATICAN CITY STATE)" Then $sCountryCode = "VA"
  108.     If $sCountry = "HONDURAS" Then $sCountryCode = "HN"
  109.     If $sCountry = "HONG KONG" Then $sCountryCode = "HK"
  110.     If $sCountry = "HUNGARY" Then $sCountryCode = "HU"
  111.     If $sCountry = "ICELAND" Then $sCountryCode = "IS"
  112.     If $sCountry = "INDIA" Then $sCountryCode = "IN"
  113.     If $sCountry = "INDONESIA" Then $sCountryCode = "ID"
  114.     If $sCountry = "IRAN, ISLAMIC REPUBLIC OF" Then $sCountryCode = "IR"
  115.     If $sCountry = "IRAQ" Then $sCountryCode = "IQ"
  116.     If $sCountry = "IRELAND" Then $sCountryCode = "IE"
  117.     If $sCountry = "ISLE OF MAN" Then $sCountryCode = "IM"
  118.     If $sCountry = "ISRAEL" Then $sCountryCode = "IL"
  119.     If $sCountry = "ITALY" Then $sCountryCode = "IT"
  120.     If $sCountry = "JAMAICA" Then $sCountryCode = "JM"
  121.     If $sCountry = "JAPAN" Then $sCountryCode = "JP"
  122.     If $sCountry = "JERSEY" Then $sCountryCode = "JE"
  123.     If $sCountry = "JORDAN" Then $sCountryCode = "JO"
  124.     If $sCountry = "KAZAKHSTAN" Then $sCountryCode = "KZ"
  125.     If $sCountry = "KENYA" Then $sCountryCode = "KE"
  126.     If $sCountry = "KIRIBATI" Then $sCountryCode = "KI"
  127.     If $sCountry = "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF" Then $sCountryCode = "KP"
  128.     If $sCountry = "KOREA, REPUBLIC OF" Then $sCountryCode = "KR"
  129.     If $sCountry = "KUWAIT" Then $sCountryCode = "KW"
  130.     If $sCountry = "KYRGYZSTAN" Then $sCountryCode = "KG"
  131.     If $sCountry = "LAO PEOPLE'S DEMOCRATIC REPUBLIC" Then $sCountryCode = "LA"
  132.     If $sCountry = "LATVIA" Then $sCountryCode = "LV"
  133.     If $sCountry = "LEBANON" Then $sCountryCode = "LB"
  134.     If $sCountry = "LESOTHO" Then $sCountryCode = "LS"
  135.     If $sCountry = "LIBERIA" Then $sCountryCode = "LR"
  136.     If $sCountry = "LIBYA" Then $sCountryCode = "LY"
  137.     If $sCountry = "LIECHTENSTEIN" Then $sCountryCode = "LI"
  138.     If $sCountry = "LITHUANIA" Then $sCountryCode = "LT"
  139.     If $sCountry = "LUXEMBOURG" Then $sCountryCode = "LU"
  140.     If $sCountry = "MACAO" Then $sCountryCode = "MO"
  141.     If $sCountry = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF" Then $sCountryCode = "MK"
  142.     If $sCountry = "MADAGASCAR" Then $sCountryCode = "MG"
  143.     If $sCountry = "MALAWI" Then $sCountryCode = "MW"
  144.     If $sCountry = "MALAYSIA" Then $sCountryCode = "MY"
  145.     If $sCountry = "MALDIVES" Then $sCountryCode = "MV"
  146.     If $sCountry = "MALI" Then $sCountryCode = "ML"
  147.     If $sCountry = "MALTA" Then $sCountryCode = "MT"
  148.     If $sCountry = "MARSHALL ISLANDS" Then $sCountryCode = "MH"
  149.     If $sCountry = "MARTINIQUE" Then $sCountryCode = "MQ"
  150.     If $sCountry = "MAURITANIA" Then $sCountryCode = "MR"
  151.     If $sCountry = "MAURITIUS" Then $sCountryCode = "MU"
  152.     If $sCountry = "MAYOTTE" Then $sCountryCode = "YT"
  153.     If $sCountry = "MEXICO" Then $sCountryCode = "MX"
  154.     If $sCountry = "MICRONESIA, FEDERATED STATES OF" Then $sCountryCode = "FM"
  155.     If $sCountry = "MOLDOVA, REPUBLIC OF" Then $sCountryCode = "MD"
  156.     If $sCountry = "MONACO" Then $sCountryCode = "MC"
  157.     If $sCountry = "MONGOLIA" Then $sCountryCode = "MN"
  158.     If $sCountry = "MONTENEGRO" Then $sCountryCode = "ME"
  159.     If $sCountry = "MONTSERRAT" Then $sCountryCode = "MS"
  160.     If $sCountry = "MOROCCO" Then $sCountryCode = "MA"
  161.     If $sCountry = "MOZAMBIQUE" Then $sCountryCode = "MZ"
  162.     If $sCountry = "MYANMAR" Then $sCountryCode = "MM"
  163.     If $sCountry = "NAMIBIA" Then $sCountryCode = "NA"
  164.     If $sCountry = "NAURU" Then $sCountryCode = "NR"
  165.     If $sCountry = "NEPAL" Then $sCountryCode = "NP"
  166.     If $sCountry = "NETHERLANDS" Then $sCountryCode = "NL"
  167.     If $sCountry = "NEW CALEDONIA" Then $sCountryCode = "NC"
  168.     If $sCountry = "NEW ZEALAND" Then $sCountryCode = "NZ"
  169.     If $sCountry = "NICARAGUA" Then $sCountryCode = "NI"
  170.     If $sCountry = "NIGER" Then $sCountryCode = "NE"
  171.     If $sCountry = "NIGERIA" Then $sCountryCode = "NG"
  172.     If $sCountry = "NIUE" Then $sCountryCode = "NU"
  173.     If $sCountry = "NORFOLK ISLAND" Then $sCountryCode = "NF"
  174.     If $sCountry = "NORTHERN MARIANA ISLANDS" Then $sCountryCode = "MP"
  175.     If $sCountry = "NORWAY" Then $sCountryCode = "NO"
  176.     If $sCountry = "OMAN" Then $sCountryCode = "OM"
  177.     If $sCountry = "PAKISTAN" Then $sCountryCode = "PK"
  178.     If $sCountry = "PALAU" Then $sCountryCode = "PW"
  179.     If $sCountry = "PALESTINE, STATE OF" Then $sCountryCode = "PS"
  180.     If $sCountry = "PANAMA" Then $sCountryCode = "PA"
  181.     If $sCountry = "PAPUA NEW GUINEA" Then $sCountryCode = "PG"
  182.     If $sCountry = "PARAGUAY" Then $sCountryCode = "PY"
  183.     If $sCountry = "PERU" Then $sCountryCode = "PE"
  184.     If $sCountry = "PHILIPPINES" Then $sCountryCode = "PH"
  185.     If $sCountry = "PITCAIRN" Then $sCountryCode = "PN"
  186.     If $sCountry = "POLAND" Then $sCountryCode = "PL"
  187.     If $sCountry = "PORTUGAL" Then $sCountryCode = "PT"
  188.     If $sCountry = "PUERTO RICO" Then $sCountryCode = "PR"
  189.     If $sCountry = "QATAR" Then $sCountryCode = "QA"
  190.     If $sCountry = "RÉUNION" Then $sCountryCode = "RE"
  191.     If $sCountry = "ROMANIA" Then $sCountryCode = "RO"
  192.     If $sCountry = "RUSSIAN FEDERATION" Then $sCountryCode = "RU"
  193.     If $sCountry = "RWANDA" Then $sCountryCode = "RW"
  194.     If $sCountry = "SAINT BARTHÉLEMY" Then $sCountryCode = "BL"
  195.     If $sCountry = "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA" Then $sCountryCode = "SH"
  196.     If $sCountry = "SAINT KITTS AND NEVIS" Then $sCountryCode = "KN"
  197.     If $sCountry = "SAINT LUCIA" Then $sCountryCode = "LC"
  198.     If $sCountry = "SAINT MARTIN (FRENCH PART)" Then $sCountryCode = "MF"
  199.     If $sCountry = "SAINT PIERRE AND MIQUELON" Then $sCountryCode = "PM"
  200.     If $sCountry = "SAINT VINCENT AND THE GRENADINES" Then $sCountryCode = "VC"
  201.     If $sCountry = "SAMOA" Then $sCountryCode = "WS"
  202.     If $sCountry = "SAN MARINO" Then $sCountryCode = "SM"
  203.     If $sCountry = "SAO TOME AND PRINCIPE" Then $sCountryCode = "ST"
  204.     If $sCountry = "SAUDI ARABIA" Then $sCountryCode = "SA"
  205.     If $sCountry = "SENEGAL" Then $sCountryCode = "SN"
  206.     If $sCountry = "SERBIA" Then $sCountryCode = "RS"
  207.     If $sCountry = "SEYCHELLES" Then $sCountryCode = "SC"
  208.     If $sCountry = "SIERRA LEONE" Then $sCountryCode = "SL"
  209.     If $sCountry = "SINGAPORE" Then $sCountryCode = "SG"
  210.     If $sCountry = "SINT MAARTEN (DUTCH PART)" Then $sCountryCode = "SX"
  211.     If $sCountry = "SLOVAKIA" Then $sCountryCode = "SK"
  212.     If $sCountry = "SLOVENIA" Then $sCountryCode = "SI"
  213.     If $sCountry = "SOLOMON ISLANDS" Then $sCountryCode = "SB"
  214.     If $sCountry = "SOMALIA" Then $sCountryCode = "SO"
  215.     If $sCountry = "SOUTH AFRICA" Then $sCountryCode = "ZA"
  216.     If $sCountry = "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS" Then $sCountryCode = "GS"
  217.     If $sCountry = "SOUTH SUDAN" Then $sCountryCode = "SS"
  218.     If $sCountry = "SPAIN" Then $sCountryCode = "ES"
  219.     If $sCountry = "SRI LANKA" Then $sCountryCode = "LK"
  220.     If $sCountry = "SUDAN" Then $sCountryCode = "SD"
  221.     If $sCountry = "SURINAME" Then $sCountryCode = "SR"
  222.     If $sCountry = "SVALBARD AND JAN MAYEN" Then $sCountryCode = "SJ"
  223.     If $sCountry = "SWAZILAND" Then $sCountryCode = "SZ"
  224.     If $sCountry = "SWEDEN" Then $sCountryCode = "SE"
  225.     If $sCountry = "SWITZERLAND" Then $sCountryCode = "CH"
  226.     If $sCountry = "SYRIAN ARAB REPUBLIC" Then $sCountryCode = "SY"
  227.     If $sCountry = "TAIWAN, PROVINCE OF CHINA" Then $sCountryCode = "TW"
  228.     If $sCountry = "TAJIKISTAN" Then $sCountryCode = "TJ"
  229.     If $sCountry = "TANZANIA, UNITED REPUBLIC OF" Then $sCountryCode = "TZ"
  230.     If $sCountry = "THAILAND" Then $sCountryCode = "TH"
  231.     If $sCountry = "TIMOR-LESTE" Then $sCountryCode = "TL"
  232.     If $sCountry = "TOGO" Then $sCountryCode = "TG"
  233.     If $sCountry = "TOKELAU" Then $sCountryCode = "TK"
  234.     If $sCountry = "TONGA" Then $sCountryCode = "TO"
  235.     If $sCountry = "TRINIDAD AND TOBAGO" Then $sCountryCode = "TT"
  236.     If $sCountry = "TUNISIA" Then $sCountryCode = "TN"
  237.     If $sCountry = "TURKEY" Then $sCountryCode = "TR"
  238.     If $sCountry = "TURKMENISTAN" Then $sCountryCode = "TM"
  239.     If $sCountry = "TURKS AND CAICOS ISLANDS" Then $sCountryCode = "TC"
  240.     If $sCountry = "TUVALU" Then $sCountryCode = "TV"
  241.     If $sCountry = "UGANDA" Then $sCountryCode = "UG"
  242.     If $sCountry = "UKRAINE" Then $sCountryCode = "UA"
  243.     If $sCountry = "UNITED ARAB EMIRATES" Then $sCountryCode = "AE"
  244.     If $sCountry = "UNITED KINGDOM" Then $sCountryCode = "GB"
  245.     If $sCountry = "UNITED STATES" Then $sCountryCode = "US"
  246.     If $sCountry = "UNITED STATES MINOR OUTLYING ISLANDS" Then $sCountryCode = "UM"
  247.     If $sCountry = "URUGUAY" Then $sCountryCode = "UY"
  248.     If $sCountry = "UZBEKISTAN" Then $sCountryCode = "UZ"
  249.     If $sCountry = "VANUATU" Then $sCountryCode = "VU"
  250.     If $sCountry = "VENEZUELA, BOLIVARIAN REPUBLIC OF" Then $sCountryCode = "VE"
  251.     If $sCountry = "VIET NAM" Then $sCountryCode = "VN"
  252.     If $sCountry = "VIRGIN ISLANDS, BRITISH" Then $sCountryCode = "VG"
  253.     If $sCountry = "VIRGIN ISLANDS, U.S." Then $sCountryCode = "VI"
  254.     If $sCountry = "WALLIS AND FUTUNA" Then $sCountryCode = "WF"
  255.     If $sCountry = "WESTERN SAHARA" Then $sCountryCode = "EH"
  256.     If $sCountry = "YEMEN" Then $sCountryCode = "YE"
  257.     If $sCountry = "ZAMBIA" Then $sCountryCode = "ZM"
  258.     If $sCountry = "ZIMBABWE" Then $sCountryCode = "ZW"
  259.     Return $sCountryCode
  260. EndFunc   ;==>_CountryNameToISO

 

Wouldn't Switch $sCountry work better than all those If statements?


  • DatMCEyeBall likes this

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

SafeExecute, for picking and choosing what commands you want Execute to be able to run.


#144 gil900

gil900

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 732 posts

Posted 16 March 2014 - 02:02 PM

This code snippet is expansion to _ResourcePlaySound() from Resources UDF.

Thanks to Melba23 for helped me here:

http://www.autoitscript.com/forum/topic/159723-need-help-with-playsound-api/

Without his example, I could not develop this code snippet.

 

 

The purpose of the code is:

To play group of sounds in order without stopping the loop.

 

for example, if you have these sounds: sound1.wav , sound2.wav , sound3.wav

you can play them in order in simple way with my code in this way:

PlaySoundGroup("sound1|sound2|sound3") While 1     $PlaySoundGroup = PlaySoundGroup()     If $PlaySoundGroup = 1 Then         ToolTip("Sounds Playing")     ElseIf $PlaySoundGroup = 0 Then         MsgBox(0,"","Sounds Stopped")         Exit     EndIf     Sleep(50) WEnd

Full examle attached to this post.

 

EDIT:

I updated the code and example.

Attached Files


Edited by gil900, 16 March 2014 - 03:29 PM.

Please correct my English in this post. I want to learn how to write correctly in English


#145 j981

j981

    Seeker

  • Normal Members
  • 2 posts

Posted 17 March 2014 - 10:18 AM

I had a need to change the z-order of windows and their position in the "alt-tab" list. I spent quite a long time trying to figure out how to make it happen, so I thought I'd post this snippet back since I finally came up with a workable solution.

 

USE CASE: I bring music applications to the foreground while I'm working/etc via a hotkey. I then press the hotkey again in order to minimize the program. When I did that, however, my alt-tab order was then modified so that I couldn't continue to "alt-tab" between active windows I was working on, which is a distraction that hurt my workflow. I wanted a way to set a window to the back of the alt-tab list and also to change the z-order of a window (two different problems, as it turned out). I've used this with Windows 8.1.

 

I'm not sure if "WinWaitDelay" is applicable to WinSetState operations. I just have it there for good measure. The _WinAPI_FlashWindowEx bit is needed sometimes to prevent windows from automatically flashing the newly un-hidden window. Also, two ancillary functions are used in order to ensure that a different window is active than the one that is to be sent to the back, since this doesn't seem to work right unless that is the case.

AutoIt         
#include <WinAPI.au3> $handle = WinGetHandle("A window which you would like to send to the back of all other windows") _SendToBottom($handle) Func _LastWindowTitle($z = 1)     If $z < 1 Then Return SetError(1, 0, 0) ; Bad parameter     Local $avList = WinList()     For $n = 1 to $avList[0][0]         If $avList[$n][0] <> "" And BitAND(WinGetState($avList[$n][1]), 2) Then             If $z Then                 $z -= 1             Else                 Local $arr = [$avList[$n][0],$avList[$n][1]]                 Return $arr             EndIf         EndIf     Next     Return SetError(2, 0, 0) ; z-depth exceeded EndFunc Func _FastActivate($hWnd)     Opt("WinWaitDelay", 20)     WinActivate($hWnd)     WinWaitActive($hWnd,"",4)     _WinAPI_FlashWindowEx($hWnd,0,0,0)     Opt("WinWaitDelay", 250) EndFunc Func _SendToBottom($hWnd)     Local Const $HWND_BOTTOM = 1;     Opt("WinWaitDelay", 20)     Local $active = WinGetHandle("[ACTIVE]")     Local $lastWindow = _LastWindowTitle()     Local $lastHandle = $lastWindow[1]     If Not ($hWnd <> $active) Then         If (WinExists($lastHandle)) Then             _FastActivate($lastHandle)         EndIf     EndIf     DllCall("user32.dll", "long", "SetWindowPos", "uint", $hWnd, "uint", $HWND_BOTTOM , "int", 0, "int", 0, "int", 0, "int", 0 , "uint", 0x13)     WinSetState($hWnd,"",@SW_MINIMIZE)     WinSetState($hWnd,"",@SW_HIDE)     WinSetState($hWnd,"",@SW_SHOW)     ;disable the taskbar flashing that sometimes occurs when hiding and showing windows...     _WinAPI_FlashWindowEx($hWnd,0,0,0)     Opt("WinWaitDelay", 250) EndFunc

Edited by j981, 22 March 2014 - 03:37 PM.


#146 j981

j981

    Seeker

  • Normal Members
  • 2 posts

Posted 17 March 2014 - 10:26 AM

This is another simple function I've found to be quite handy.

 

USE CASE: Since chrome v32 and later no longer exposes any standard windows API controls, a huge number of "controlsend" based automation functions I was using against webapps broke. I changed things to bring those windows to the foreground instead to send keys and then minimize them again (with the _SendToBottom function I just posted as well), but with the standard 'winactivate' it took too long. This function basically just reduces the winwaitdelay temporarily, but it also disables the automatic flashing of windows in the taskbar which occurs if you activate windows too rapidly, which was extremely annoying. It's not particularly useful if you just want to bring something to the foreground to actively work with, but if the goal is to activate something solely to send a key and then minimize again, it speeds things up quite a bit since it happens almost instantly. Hopefully someone else also finds this useful.

#include <WinAPI.au3> $handle = WinGetHandle("Some window you would like to activate") _FastActivate($handle) Func _FastActivate($hWnd)     Opt("WinWaitDelay", 20)     WinActivate($hWnd)     WinWaitActive($hWnd,"",4)     _WinAPI_FlashWindowEx($hWnd,0,0,0)     Opt("WinWaitDelay", 250) EndFunc

Edited by j981, 17 March 2014 - 10:40 AM.


#147 DigitalFacade82

DigitalFacade82

    Wayfarer

  • Active Members
  • Pip
  • 53 posts

Posted 05 May 2014 - 10:26 PM

Here is my solution to the sh!tty Windows Desklink  aka Right click 'Send To' menu. It's probably been done before and or better than how I have done it?
I wrote it this way because it's the easiest for me to understand how so I could fix a problem not because it is the best way. Feel free to critique/rewrite label as abortion code what ever it does what I need it to do on Windows 7 64 bit.

Credit nearly all goes to the two users mentioned in the credits. I merely grabbed their two ideas and joined them together to make a solution. None of the code is mine really

AutoIt         
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Desktop (create shortcut).ico #AutoIt3Wrapper_Outfile=Desktop (create shortcut).exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------  AutoIt Version: 3.3.10.2  Author:   Jarmezrocks  Script Version: 1.0  Script Function:   The purpose of creating this was due to an annoyance with Windows 7 where                     I was constantly editing the shortcuts created from the right click 'Send To'                     create 'Desktop (create shortcut)' where I would need to remove the junk that                     Microsoft attached as a postfix i.e. - (short cut) and remove the file                     extension as well. E.g. Notepad.exe -> creates a shortcut 'Notepad.exe - (shortcut)'                     when what I really wanted created was a shortcut called 'Notepad'                     This AutoIT script was created to solve this issue/annoyance.  Usage:             Place the compiled exe where ever you like right click the compiled exe and create a shortcut                     rename it 'Desktop (create shortcut)' the same as the Desktop (create shortcut).Desklink                     item in the Send To menu.                     Locate your Send To menu: Start -> Run -> type this: shell:sendto -> press enter                     This opens the directory for your Send To items, likely located somewhere like                     C:\Users\<User Name>\AppData\Roaming\Microsoft\Windows\SendTo                     Paste the shortcut to the exe here                     Note: You will now have a duplicate in the Send To menu, so I advise that you hide the old .Desklink item                     Right click -> File Properties -> Hidden                     Done!                     Test by Right clicking any file and choosing Send To -> Desktop (create shortcut)  Acknowledgements:  AutoIT Forums;                     User Harlequin for this post/thread -> http://www.autoitscript.com/forum/topic/86839-how-get-file-extension/#entry623386                     User Voodooman for this post/thread -> http://www.autoitscript.com/forum/topic/122807-remove-extension-from-the-filenameexample/?p=1110846  Improvements:      Place a link to it's self in the Send to Menu and hide the old desklink - Easily done #ce ---------------------------------------------------------------------------- Global $Input = $CmdLineRaw Global $LinkFileName = RemoveExt(GetFileName($Input)) ; Borrowed from Voodooman Func RemoveExt($Input)     Local $ExtArray = StringSplit($Input, ".")     Return StringReplace($Input, "." & $ExtArray[$ExtArray[0]], "", -1) EndFunc   ;==>RemoveExt Func RemoveExtRegExp($Input)     Return StringRegExpReplace($Input, "\.[^.]*$", "") EndFunc   ;==>RemoveExtRegExp Func GetFileName($Input)     Local $PathArray = StringSplit($Input, "\/")     Return $PathArray[$PathArray[0]] EndFunc   ;==>GetFileName ; Importance of the following. As pointed out by Harlequin using any StringRightTrim methods of obtaining the extension doesn't account for several ; things "." can located in the path of a folder name and  "." can appear more than once within files or folders i.e What would one do when trying ; to return the extension of a html file or any other long extension file type? Func CreateLink()     Local $Ext     If $CmdLineRaw Then         For $YLoop = StringLen($CmdLineRaw) To 1 Step -1             If StringMid($CmdLineRaw, $YLoop, 1) == "." Then                 $Ext = StringMid($CmdLineRaw, $YLoop)                 $YLoop = 1             EndIf         Next         Local $Type = RegRead("HKEY_CLASSES_ROOT\." & $Ext, "")         Local $FileName = $CmdLineRaw         Local $LnkFileLocate = (@DesktopDir & "\" & $LinkFileName & ".lnk"); Here is the working part - Generate the Desktop shortcut from the derived file name         Local $WorkingDirectory = ""         Local $Icon = RegRead("HKEY_CLASSES_ROOT\" & $Type & "\DefaultIcon", ""); Derive the file type icon from the registered application         Local $IconNumber = 1         Local $Description = "" ; I decided to leave this blank         Local $State = @SW_SHOWNORMAL ;Can also be @SW_MAXIMUM or @SW_SHOWMINNOACTIVE or even @SW_HIDE         If Not FileExists($LinkFileName) Then ;Check there isn't already as shortcut             FileCreateShortcut($FileName, $LnkFileLocate, $WorkingDirectory, "", $Description, $Icon, "", $IconNumber, $State); Generate the shortcut         EndIf     EndIf EndFunc   ;==>CreateLink CreateLink() ; Execute the Function

Edited by DigitalFacade82, 05 May 2014 - 10:35 PM.


#148 GerrOrneq

GerrOrneq

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 06 May 2014 - 09:25 AM

 

Here is my solution to the sh!tty Windows Desklink  aka Right click 'Send To' menu. It's probably been done before and or better than how I have done it?
I wrote it this way because it's the easiest for me to understand how so I could fix a problem not because it is the best way. Feel free to critique/rewrite label as abortion code what ever it does what I need it to do on Windows 7 64 bit. ...

 

 

Just as a matter of interest, there is a registry hack that will turn off the "Shortcut to" on desktop shortcuts.

 

You can read about it here http://www.howtogeek.com/howto/windows-vista/remove-shortcut-text-from-new-shortcuts-in-vista/

 

Good Luck. DeMo.


Quote of the week:"BASIC programmers never die, they GOSUB and don't RETURN." -- UnknownWisdom of the ages:

  • I started life with nothing. I still have most of it left.
  • A boiled egg in the morning is hard to beat.
  • I finally got my head together, now my body is falling apart.
  • Local Area Network in Australia: the LAN down under.

Newspaper Headline of The Week  NEW STUDY OF OBESITY LOOKS FOR LARGER TEST GROUP

 

Statistics; 101:

The larger the sample size (n) the more confident you can be that your sample mean is a good representation of the population mean.

In other words, the "n" justifies the means.
 


#149 DigitalFacade82

DigitalFacade82

    Wayfarer

  • Active Members
  • Pip
  • 53 posts

Posted 07 May 2014 - 03:44 PM

Just as a matter of interest, there is a registry hack that will turn off the "Shortcut to" on desktop shortcuts.

 

You can read about it here http://www.howtogeek.com/howto/windows-vista/remove-shortcut-text-from-new-shortcuts-in-vista/

 

Good Luck. DeMo.

Dammit!

Hmm hang on? Wait that will only remove - Shortcut right?

What about the file extension?

notpad.exe normally goes to -> notepad.exe - Shortcut

 

Registry edit

notepad.exe goes to -> notepad.exe

I still then need to double long click or right click shortcut properties and remove .exe from the end.

 

What I want then is this
notepad.exe goes to -> notepad

Or maybe I could improve it to reproduce the link in propercase Or propercase with string replace to substitute dashes and underscores
 

notepad.exe goes to -> Notepad

 

and

 

this-is-the-name-of-a-long-executable_1.exe goes to -> This is the name of a long executable 1

My snippet still applies I guess? But thanks for the reg hack. I have no idea why I never come across that earlier? 



#150 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,012 posts

Posted 07 May 2014 - 03:49 PM

Have you tried FileCreateShortcut? You can call it whatever you want with it.


  • DigitalFacade82 likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#151 DigitalFacade82

DigitalFacade82

    Wayfarer

  • Active Members
  • Pip
  • 53 posts

Posted 08 May 2014 - 07:42 PM

Have you tried FileCreateShortcut? You can call it whatever you want with it.

5th line up from the bottom. I guess I should now go and seek who it was that created the initial FileCreateShortcut and add them to the credits....is that expected? I read it from the helpfile and yes that was very useful. If you read through the code in my snippet you will see why it alone cannot be used as the solution by its self and how I propose solutions to the issues that are created. I think you will like it ;-) As mentioned I am sure there are better ways that have been created to solve the same problem, this is just a different way of doing it and some of the parts or combination of parts may be useful to other forum members? 



#152 UEZ

UEZ

    Never say never

  • MVPs
  • 4,799 posts

Posted 22 May 2014 - 10:14 PM

Here a snipped how to colorize each character of a label text:

GUICtrlCreateLabelColorized:
AutoIt         
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> _GDIPlus_Startup() Global $hGUI = GUICreate("Test", 500, 100), $i GUISetBkColor(0) Global $sText1 = "These chars were colorized separately" Global $aColors1[StringLen($sText1)] For $i = 0 To UBound($aColors1) - 1     $aColors1[$i] = Random(0xA00000, 0xFFFFFF, 1) Next Global $aLabel1 = GUICtrlCreateLabelColorized($sText1, $aColors1, 10, 10, 18, "Comic Sans MS") Global $sText2 = "using label controls. ;-)" Global $aColors2[StringLen($sText2)] Global $aLabel2 = GUICtrlCreateLabelColorized($sText2, $aColors2, 18, 50, 26, "Times New Roman", 700) GUISetState() Do     For $i = 0 To UBound($aColors2) - 1         GUICtrlSetColor($aLabel2[$i][0], Random(0x000000, 0xD00000, 1))     Next     Sleep(40) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlCreateLabelColorized ; Description ...: Creates a label with possibility to set different color to each character ; Syntax ........: GUICtrlCreateLabelColorized($sText, $aColors, $iX, $iY, $fFontSize, $sFont[, $iWeight = 400[, $iAttribute = 0[, ;                  $iFQuality = 0[, $fCorrection = 0.95]]]]) ; Parameters ....: $sText               - A string value. ;                  $aColors             - An array of color values in format RGB. ;                  $iX                  - An integer value - x position of the label. ;                  $iY                  - An integer value - y position of the label. ;                  $fFontSize           - A floating point value - size of the font. ;                  $sFont               - A string value - font name. ;                  $iWeight             - [optional] An integer value. Default is 400. ;                  $iAttribute          - [optional] An integer value. Default is 0. ;                  $iFQuality           - [optional] An integer value. Default is 0 (checkout GUICtrlSetFont for more details about quality settings) ;                  $fCorrection         - [optional] A floating point value. Default is 0.925. ; Return values .: An array with following values: ;                  [$i][0] = control id of the label ;                  [$i][1] = color value of the character in RGB format ;                  [$i][2] = x position of the character ;                  [$i][3] = y position of the character ;                  [$i][4] = width of the character ;                  [$i][5] = height of the character ; Version .......: 0.90 build 2014-07-05 beta ; Author ........: UEZ ; Modified ......: ; Remarks .......: AutoIt version 3.3.10.2 or higher is required, __MeasureString is an internal function to measure each character. ;                  Don't forget to start GDI+ before you call the function! ; Related .......: GUICtrlCreateLabel, _GDIPlus_StringFormatSetMeasurableCharacterRanges ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlCreateLabelColorized($sText, $aColors, $iX, $iY, $fFontSize = 9.5, $sFont = "Arial", $iWeight = 400, $iAttribute = 0, $iFQuality = 0, $fCorrection = 0.925)     If Not StringLen($sText) Then Return SetError(1, 0, 0)     Local $aChars = StringSplit($sText, "", 2), $i, $aLabels[UBound($aChars)][6], $aCoord, $sChar     For $i = 0 To UBound($aChars) - 1         $sChar = $aChars[$i]         If $sChar = " " Then $sChar = "." ;if char is space fill it up with . to calculate space between words         $aCoord = __MeasureString($sChar, $sFont, $fFontSize, $iAttribute + ($iWeight > 699) * 1)         $aLabels[$i][1] = $aColors[$i] ;color         $aLabels[$i][2] = ($iX - $aCoord[0]) * $fCorrection ;x pos         $aLabels[$i][3] = $iY ;y pos         $aLabels[$i][4] = $aCoord[2] ;width         $aLabels[$i][5] = $aCoord[3] ;height         $aLabels[$i][0] = GUICtrlCreateLabel($aChars[$i], $aLabels[$i][2], $aLabels[$i][3], $aLabels[$i][4], $aLabels[$i][5]) ;create label (char) control         GUICtrlSetColor($aLabels[$i][0], $aLabels[$i][1]) ;set char color         GUICtrlSetFont($aLabels[$i][0], $fFontSize, $iWeight, $iAttribute, $sFont, $iFQuality) ;set font for char         $iX += $aCoord[1] ;calculate next x position     Next     Return $aLabels EndFunc   ;==>GUICtrlCreateLabelColorized ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __MeasureString ; Description ...: Measures a string ; Syntax ........: __MeasureString($sString, $sFont, $fFontSize[, $iAttribute = 0]) ; Parameters ....: $sString             - A string value. ;                  $sFont               - A string value. ;                  $fFontSize           - A floating point value. ;                  $iAttribute          - [optional] An integer value. Default is 0. ; Return values .: An array with x, y, width and height values of the string ; Author ........: UEZ ; Modified ......: ; Remarks .......: AutoIt version 3.3.10.2 or higher is required ; Related .......: GDIPlus ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func __MeasureString($sString, $sFont, $fFontSize, $iAttribute = 0)     Local Const $hDC = _WinAPI_GetDC(0), $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC), $tLayout = _GDIPlus_RectFCreate()     Local Const $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($sFont), $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize, $iAttribute)     Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)     Local $aRanges[2][2] = [[1]]     $aRanges[1][1] = StringLen($sString)     _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)     Local Const $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)     Local Const $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)     _GDIPlus_RegionDispose($aRegion[1])     _GDIPlus_FontDispose($hFont)     _GDIPlus_FontFamilyDispose($hFamily)     _GDIPlus_StringFormatDispose($hFormat)     _WinAPI_ReleaseDC(0, $hDC)     Local $aDim[4]     $aDim[0] = $aBounds[0] ; X coordinate of the upper-left corner of the rectangle     $aDim[1] = $aBounds[2] ; Width of the rectangle     $aDim[2] = $aInfo[0].Width     $aDim[3] = $aInfo[0].Height     Return $aDim EndFunc   ;==>__MeasureString


Requires AutoIt version 3.3.10.2 or higher!

Br,
UEZ

Edited by UEZ, 05 July 2014 - 03:15 PM.

  • mLipok and mesale0077 like this

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#153 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 3,833 posts

Posted 23 May 2014 - 12:27 PM

Awesome, UEZ. Made my eyes bleed with the bright colors, but great work nevertheless :)


Programming is like sex...one mistake and you have to support it for a lifetime.

My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#154 UEZ

UEZ

    Never say never

  • MVPs
  • 4,799 posts

Posted 23 May 2014 - 12:59 PM

Thanks JLogan3o13. Changed bg to black to be less dazzling for your eyes. ;)
 
Br,
UEZ

Edited by UEZ, 23 May 2014 - 01:12 PM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#155 mLipok

mLipok

    thinking does not hurt, ........ .......... but it takes time

  • Active Members
  • PipPipPipPipPipPip
  • 2,244 posts

Posted 02 June 2014 - 08:04 PM

Slided ON / OFF by @taietel

http://www.autoitscript.com/forum/topic/141361-gui-rocker-switch-onoff-udf/#entry995083

AutoIt         
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> $bOn = True $hGUI = GUICreate("On/Off", 120, 45) GUICtrlCreateLabel("ON", 10, 10, 50, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 8, 800, 0, "Arial",5) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetBkColor(-1, 0x101010) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("OFF", 60, 10, 50, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 8, 800, 0, "Arial",5) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetBkColor(-1, 0x101010) GUICtrlSetState(-1, $GUI_DISABLE) $hSwitch = GUICtrlCreateLabel("", 60, 10, 50, 25) GUICtrlSetFont(-1, 8, 800, 0, "Arial") GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg()   Case -3    Exit   Case $hSwitch    $aPos = ControlGetPos($hGUI, "", $hSwitch)    If $bOn Then     For $i = 0 To 50      ControlMove($hGUI, "", $hSwitch, $aPos[0] - $i, $aPos[1])     Next     $bOn = False    Else     For $i = 0 To 50      ControlMove($hGUI, "", $hSwitch, $aPos[0] + $i, $aPos[1])     Next     $bOn = True    EndIf EndSwitch WEnd

Edited by mLipok, 02 June 2014 - 08:05 PM.

My contribution:
DumpDebugingBestCodingPractice Analyzer * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta()NEW 2014/07/02: Debenu Quick PDF Library - UDFRTF Printer - UDF * NEW 2014/07/01: XZip - UDFNEW 2014/06/20: Acrobat Reader - ActiveX ViewerAppCompatFlags UDF

 

Other useful stuff - click the following Show button:

Spoiler

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute"  Donald Knuth

#156 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,779 posts

Posted 02 June 2014 - 08:27 PM

Thanks mLipok. Though the code needs a bit of updating in my opinion.


Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 20/07/2014


#157 mLipok

mLipok

    thinking does not hurt, ........ .......... but it takes time

  • Active Members
  • PipPipPipPipPipPip
  • 2,244 posts

Posted 03 June 2014 - 01:23 PM

based on:

http://blogs.technet.com/b/heyscriptingguy/archive/2005/02/16/how-can-i-list-open-sessions-and-open-files-on-a-computer.aspx

 

List of active sesion and opened files :

Local $objConnection = ObjGet("WinNT://localhost/LanmanServer") Local $colSessions = $objConnection.Sessions For $objSession In $colSessions     ConsoleWrite("Computer: " & $objSession.Computer & @CRLF )     ConsoleWrite("Connected Time: " & $objSession.ConnectTime & @CRLF )     ConsoleWrite("Idle Time: " & $objSession.IdleTime & @CRLF )     ConsoleWrite("Name: " & $objSession.Name & @CRLF )     ConsoleWrite("User: " & $objSession.User & @CRLF )     ConsoleWrite(@CRLF ) Next Local $colResources = $objConnection.Resources For $objResource in $colResources     ConsoleWrite("Name: " & $objResource.Name& @CRLF )     ConsoleWrite("Path: " & $objResource.Path& @CRLF )     ConsoleWrite("User: " & $objResource.User& @CRLF )     ConsoleWrite("LockCount: " & $objResource.LockCount& @CRLF )     ConsoleWrite(@CRLF ) Next

My contribution:
DumpDebugingBestCodingPractice Analyzer * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta()NEW 2014/07/02: Debenu Quick PDF Library - UDFRTF Printer - UDF * NEW 2014/07/01: XZip - UDFNEW 2014/06/20: Acrobat Reader - ActiveX ViewerAppCompatFlags UDF

 

Other useful stuff - click the following Show button:

Spoiler

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute"  Donald Knuth




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users