guestscripter Posted January 12, 2014 Share Posted January 12, 2014 Use to convert data from "Name = XXXX YYYY" to "Surname = YYY, First Name = XXXXXX" #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 Local $sFullName = " Harry J T. Potter" Local $aFirstnamesLast = splitfirstlastname($sFullName) ConsoleWrite($aFirstnamesLast[0] & @CR) ConsoleWrite($aFirstnamesLast[1] & @CR) Func splitfirstlastname($sFullName) Local $aWords = StringSplit(StringStripWS($sFullName, 7), " ");Clean out leading/trailing/double+ spaces, and Split into words Local $sFirstnames, $sLastname $sLastname = $aWords[$aWords[0]];Assume the last (or only) word is the last name Select Case $aWords[0] = 1;Assume no first name if only one word $sFirstnames = "" Case $aWords[0] = 2;If two words, assume this is the first and last name in that order $sFirstnames = $aWords[1] Case $aWords[0] > 2;If more than two words, all except the last are first names For $n = 1 To $aWords[0] - 2 $sFirstnames &= $aWords[$n] & " " Next $sFirstnames &= $aWords[$aWords[0] - 1] EndSelect Dim $aFirstnamesLast[] = [$sFirstnames, $sLastname] Return $aFirstnamesLast EndFunc ;==>splitfirstlastname ImageSearch15.au3 featuring _ImageSearchStartup() and _ImageSearchShutdown() Link to comment Share on other sites More sharing options...
guestscripter Posted January 12, 2014 Share Posted January 12, 2014 Use to convert data that has country names to their corresponding 2-digit codes. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 Local $sCountry = "Fiji" ConsoleWrite("ISO Country Code: " & _CountryNameToISO($sCountry) & @CR) Func _CountryNameToISO($sCountry) Local $sCountryCode ;names and codes according to ;http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm ;updated in December 2013 If $sCountry = "AFGHANISTAN" Then $sCountryCode = "AF" If $sCountry = "ÅLAND ISLANDS" Then $sCountryCode = "AX" If $sCountry = "ALBANIA" Then $sCountryCode = "AL" If $sCountry = "ALGERIA" Then $sCountryCode = "DZ" If $sCountry = "AMERICAN SAMOA" Then $sCountryCode = "AS" If $sCountry = "ANDORRA" Then $sCountryCode = "AD" If $sCountry = "ANGOLA" Then $sCountryCode = "AO" If $sCountry = "ANGUILLA" Then $sCountryCode = "AI" If $sCountry = "ANTARCTICA" Then $sCountryCode = "AQ" If $sCountry = "ANTIGUA AND BARBUDA" Then $sCountryCode = "AG" If $sCountry = "ARGENTINA" Then $sCountryCode = "AR" If $sCountry = "ARMENIA" Then $sCountryCode = "AM" If $sCountry = "ARUBA" Then $sCountryCode = "AW" If $sCountry = "AUSTRALIA" Then $sCountryCode = "AU" If $sCountry = "AUSTRIA" Then $sCountryCode = "AT" If $sCountry = "AZERBAIJAN" Then $sCountryCode = "AZ" If $sCountry = "BAHAMAS" Then $sCountryCode = "BS" If $sCountry = "BAHRAIN" Then $sCountryCode = "BH" If $sCountry = "BANGLADESH" Then $sCountryCode = "BD" If $sCountry = "BARBADOS" Then $sCountryCode = "BB" If $sCountry = "BELARUS" Then $sCountryCode = "BY" If $sCountry = "BELGIUM" Then $sCountryCode = "BE" If $sCountry = "BELIZE" Then $sCountryCode = "BZ" If $sCountry = "BENIN" Then $sCountryCode = "BJ" If $sCountry = "BERMUDA" Then $sCountryCode = "BM" If $sCountry = "BHUTAN" Then $sCountryCode = "BT" If $sCountry = "BOLIVIA, PLURINATIONAL STATE OF" Then $sCountryCode = "BO" If $sCountry = "BONAIRE, SINT EUSTATIUS AND SABA" Then $sCountryCode = "BQ" If $sCountry = "BOSNIA AND HERZEGOVINA" Then $sCountryCode = "BA" If $sCountry = "BOTSWANA" Then $sCountryCode = "BW" If $sCountry = "BOUVET ISLAND" Then $sCountryCode = "BV" If $sCountry = "BRAZIL" Then $sCountryCode = "BR" If $sCountry = "BRITISH INDIAN OCEAN TERRITORY" Then $sCountryCode = "IO" If $sCountry = "BRUNEI DARUSSALAM" Then $sCountryCode = "BN" If $sCountry = "BULGARIA" Then $sCountryCode = "BG" If $sCountry = "BURKINA FASO" Then $sCountryCode = "BF" If $sCountry = "BURUNDI" Then $sCountryCode = "BI" If $sCountry = "CAMBODIA" Then $sCountryCode = "KH" If $sCountry = "CAMEROON" Then $sCountryCode = "CM" If $sCountry = "CANADA" Then $sCountryCode = "CA" If $sCountry = "CAPE VERDE" Then $sCountryCode = "CV" If $sCountry = "CAYMAN ISLANDS" Then $sCountryCode = "KY" If $sCountry = "CENTRAL AFRICAN REPUBLIC" Then $sCountryCode = "CF" If $sCountry = "CHAD" Then $sCountryCode = "TD" If $sCountry = "CHILE" Then $sCountryCode = "CL" If $sCountry = "CHINA" Then $sCountryCode = "CN" If $sCountry = "CHRISTMAS ISLAND" Then $sCountryCode = "CX" If $sCountry = "COCOS (KEELING) ISLANDS" Then $sCountryCode = "CC" If $sCountry = "COLOMBIA" Then $sCountryCode = "CO" If $sCountry = "COMOROS" Then $sCountryCode = "KM" If $sCountry = "CONGO" Then $sCountryCode = "CG" If $sCountry = "CONGO, THE DEMOCRATIC REPUBLIC OF THE" Then $sCountryCode = "CD" If $sCountry = "COOK ISLANDS" Then $sCountryCode = "CK" If $sCountry = "COSTA RICA" Then $sCountryCode = "CR" If $sCountry = "CÔTE D'IVOIRE" Then $sCountryCode = "CI" If $sCountry = "CROATIA" Then $sCountryCode = "HR" If $sCountry = "CUBA" Then $sCountryCode = "CU" If $sCountry = "CURAÇAO" Then $sCountryCode = "CW" If $sCountry = "CYPRUS" Then $sCountryCode = "CY" If $sCountry = "CZECH REPUBLIC" Then $sCountryCode = "CZ" If $sCountry = "DENMARK" Then $sCountryCode = "DK" If $sCountry = "DJIBOUTI" Then $sCountryCode = "DJ" If $sCountry = "DOMINICA" Then $sCountryCode = "DM" If $sCountry = "DOMINICAN REPUBLIC" Then $sCountryCode = "DO" If $sCountry = "ECUADOR" Then $sCountryCode = "EC" If $sCountry = "EGYPT" Then $sCountryCode = "EG" If $sCountry = "EL SALVADOR" Then $sCountryCode = "SV" If $sCountry = "EQUATORIAL GUINEA" Then $sCountryCode = "GQ" If $sCountry = "ERITREA" Then $sCountryCode = "ER" If $sCountry = "ESTONIA" Then $sCountryCode = "EE" If $sCountry = "ETHIOPIA" Then $sCountryCode = "ET" If $sCountry = "FALKLAND ISLANDS (MALVINAS)" Then $sCountryCode = "FK" If $sCountry = "FAROE ISLANDS" Then $sCountryCode = "FO" If $sCountry = "FIJI" Then $sCountryCode = "FJ" If $sCountry = "FINLAND" Then $sCountryCode = "FI" If $sCountry = "FRANCE" Then $sCountryCode = "FR" If $sCountry = "FRENCH GUIANA" Then $sCountryCode = "GF" If $sCountry = "FRENCH POLYNESIA" Then $sCountryCode = "PF" If $sCountry = "FRENCH SOUTHERN TERRITORIES" Then $sCountryCode = "TF" If $sCountry = "GABON" Then $sCountryCode = "GA" If $sCountry = "GAMBIA" Then $sCountryCode = "GM" If $sCountry = "GEORGIA" Then $sCountryCode = "GE" If $sCountry = "GERMANY" Then $sCountryCode = "DE" If $sCountry = "GHANA" Then $sCountryCode = "GH" If $sCountry = "GIBRALTAR" Then $sCountryCode = "GI" If $sCountry = "GREECE" Then $sCountryCode = "GR" If $sCountry = "GREENLAND" Then $sCountryCode = "GL" If $sCountry = "GRENADA" Then $sCountryCode = "GD" If $sCountry = "GUADELOUPE" Then $sCountryCode = "GP" If $sCountry = "GUAM" Then $sCountryCode = "GU" If $sCountry = "GUATEMALA" Then $sCountryCode = "GT" If $sCountry = "GUERNSEY" Then $sCountryCode = "GG" If $sCountry = "GUINEA" Then $sCountryCode = "GN" If $sCountry = "GUINEA-BISSAU" Then $sCountryCode = "GW" If $sCountry = "GUYANA" Then $sCountryCode = "GY" If $sCountry = "HAITI" Then $sCountryCode = "HT" If $sCountry = "HEARD ISLAND AND MCDONALD ISLANDS" Then $sCountryCode = "HM" If $sCountry = "HOLY SEE (VATICAN CITY STATE)" Then $sCountryCode = "VA" If $sCountry = "HONDURAS" Then $sCountryCode = "HN" If $sCountry = "HONG KONG" Then $sCountryCode = "HK" If $sCountry = "HUNGARY" Then $sCountryCode = "HU" If $sCountry = "ICELAND" Then $sCountryCode = "IS" If $sCountry = "INDIA" Then $sCountryCode = "IN" If $sCountry = "INDONESIA" Then $sCountryCode = "ID" If $sCountry = "IRAN, ISLAMIC REPUBLIC OF" Then $sCountryCode = "IR" If $sCountry = "IRAQ" Then $sCountryCode = "IQ" If $sCountry = "IRELAND" Then $sCountryCode = "IE" If $sCountry = "ISLE OF MAN" Then $sCountryCode = "IM" If $sCountry = "ISRAEL" Then $sCountryCode = "IL" If $sCountry = "ITALY" Then $sCountryCode = "IT" If $sCountry = "JAMAICA" Then $sCountryCode = "JM" If $sCountry = "JAPAN" Then $sCountryCode = "JP" If $sCountry = "JERSEY" Then $sCountryCode = "JE" If $sCountry = "JORDAN" Then $sCountryCode = "JO" If $sCountry = "KAZAKHSTAN" Then $sCountryCode = "KZ" If $sCountry = "KENYA" Then $sCountryCode = "KE" If $sCountry = "KIRIBATI" Then $sCountryCode = "KI" If $sCountry = "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF" Then $sCountryCode = "KP" If $sCountry = "KOREA, REPUBLIC OF" Then $sCountryCode = "KR" If $sCountry = "KUWAIT" Then $sCountryCode = "KW" If $sCountry = "KYRGYZSTAN" Then $sCountryCode = "KG" If $sCountry = "LAO PEOPLE'S DEMOCRATIC REPUBLIC" Then $sCountryCode = "LA" If $sCountry = "LATVIA" Then $sCountryCode = "LV" If $sCountry = "LEBANON" Then $sCountryCode = "LB" If $sCountry = "LESOTHO" Then $sCountryCode = "LS" If $sCountry = "LIBERIA" Then $sCountryCode = "LR" If $sCountry = "LIBYA" Then $sCountryCode = "LY" If $sCountry = "LIECHTENSTEIN" Then $sCountryCode = "LI" If $sCountry = "LITHUANIA" Then $sCountryCode = "LT" If $sCountry = "LUXEMBOURG" Then $sCountryCode = "LU" If $sCountry = "MACAO" Then $sCountryCode = "MO" If $sCountry = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF" Then $sCountryCode = "MK" If $sCountry = "MADAGASCAR" Then $sCountryCode = "MG" If $sCountry = "MALAWI" Then $sCountryCode = "MW" If $sCountry = "MALAYSIA" Then $sCountryCode = "MY" If $sCountry = "MALDIVES" Then $sCountryCode = "MV" If $sCountry = "MALI" Then $sCountryCode = "ML" If $sCountry = "MALTA" Then $sCountryCode = "MT" If $sCountry = "MARSHALL ISLANDS" Then $sCountryCode = "MH" If $sCountry = "MARTINIQUE" Then $sCountryCode = "MQ" If $sCountry = "MAURITANIA" Then $sCountryCode = "MR" If $sCountry = "MAURITIUS" Then $sCountryCode = "MU" If $sCountry = "MAYOTTE" Then $sCountryCode = "YT" If $sCountry = "MEXICO" Then $sCountryCode = "MX" If $sCountry = "MICRONESIA, FEDERATED STATES OF" Then $sCountryCode = "FM" If $sCountry = "MOLDOVA, REPUBLIC OF" Then $sCountryCode = "MD" If $sCountry = "MONACO" Then $sCountryCode = "MC" If $sCountry = "MONGOLIA" Then $sCountryCode = "MN" If $sCountry = "MONTENEGRO" Then $sCountryCode = "ME" If $sCountry = "MONTSERRAT" Then $sCountryCode = "MS" If $sCountry = "MOROCCO" Then $sCountryCode = "MA" If $sCountry = "MOZAMBIQUE" Then $sCountryCode = "MZ" If $sCountry = "MYANMAR" Then $sCountryCode = "MM" If $sCountry = "NAMIBIA" Then $sCountryCode = "NA" If $sCountry = "NAURU" Then $sCountryCode = "NR" If $sCountry = "NEPAL" Then $sCountryCode = "NP" If $sCountry = "NETHERLANDS" Then $sCountryCode = "NL" If $sCountry = "NEW CALEDONIA" Then $sCountryCode = "NC" If $sCountry = "NEW ZEALAND" Then $sCountryCode = "NZ" If $sCountry = "NICARAGUA" Then $sCountryCode = "NI" If $sCountry = "NIGER" Then $sCountryCode = "NE" If $sCountry = "NIGERIA" Then $sCountryCode = "NG" If $sCountry = "NIUE" Then $sCountryCode = "NU" If $sCountry = "NORFOLK ISLAND" Then $sCountryCode = "NF" If $sCountry = "NORTHERN MARIANA ISLANDS" Then $sCountryCode = "MP" If $sCountry = "NORWAY" Then $sCountryCode = "NO" If $sCountry = "OMAN" Then $sCountryCode = "OM" If $sCountry = "PAKISTAN" Then $sCountryCode = "PK" If $sCountry = "PALAU" Then $sCountryCode = "PW" If $sCountry = "PALESTINE, STATE OF" Then $sCountryCode = "PS" If $sCountry = "PANAMA" Then $sCountryCode = "PA" If $sCountry = "PAPUA NEW GUINEA" Then $sCountryCode = "PG" If $sCountry = "PARAGUAY" Then $sCountryCode = "PY" If $sCountry = "PERU" Then $sCountryCode = "PE" If $sCountry = "PHILIPPINES" Then $sCountryCode = "PH" If $sCountry = "PITCAIRN" Then $sCountryCode = "PN" If $sCountry = "POLAND" Then $sCountryCode = "PL" If $sCountry = "PORTUGAL" Then $sCountryCode = "PT" If $sCountry = "PUERTO RICO" Then $sCountryCode = "PR" If $sCountry = "QATAR" Then $sCountryCode = "QA" If $sCountry = "RÉUNION" Then $sCountryCode = "RE" If $sCountry = "ROMANIA" Then $sCountryCode = "RO" If $sCountry = "RUSSIAN FEDERATION" Then $sCountryCode = "RU" If $sCountry = "RWANDA" Then $sCountryCode = "RW" If $sCountry = "SAINT BARTHÉLEMY" Then $sCountryCode = "BL" If $sCountry = "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA" Then $sCountryCode = "SH" If $sCountry = "SAINT KITTS AND NEVIS" Then $sCountryCode = "KN" If $sCountry = "SAINT LUCIA" Then $sCountryCode = "LC" If $sCountry = "SAINT MARTIN (FRENCH PART)" Then $sCountryCode = "MF" If $sCountry = "SAINT PIERRE AND MIQUELON" Then $sCountryCode = "PM" If $sCountry = "SAINT VINCENT AND THE GRENADINES" Then $sCountryCode = "VC" If $sCountry = "SAMOA" Then $sCountryCode = "WS" If $sCountry = "SAN MARINO" Then $sCountryCode = "SM" If $sCountry = "SAO TOME AND PRINCIPE" Then $sCountryCode = "ST" If $sCountry = "SAUDI ARABIA" Then $sCountryCode = "SA" If $sCountry = "SENEGAL" Then $sCountryCode = "SN" If $sCountry = "SERBIA" Then $sCountryCode = "RS" If $sCountry = "SEYCHELLES" Then $sCountryCode = "SC" If $sCountry = "SIERRA LEONE" Then $sCountryCode = "SL" If $sCountry = "SINGAPORE" Then $sCountryCode = "SG" If $sCountry = "SINT MAARTEN (DUTCH PART)" Then $sCountryCode = "SX" If $sCountry = "SLOVAKIA" Then $sCountryCode = "SK" If $sCountry = "SLOVENIA" Then $sCountryCode = "SI" If $sCountry = "SOLOMON ISLANDS" Then $sCountryCode = "SB" If $sCountry = "SOMALIA" Then $sCountryCode = "SO" If $sCountry = "SOUTH AFRICA" Then $sCountryCode = "ZA" If $sCountry = "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS" Then $sCountryCode = "GS" If $sCountry = "SOUTH SUDAN" Then $sCountryCode = "SS" If $sCountry = "SPAIN" Then $sCountryCode = "ES" If $sCountry = "SRI LANKA" Then $sCountryCode = "LK" If $sCountry = "SUDAN" Then $sCountryCode = "SD" If $sCountry = "SURINAME" Then $sCountryCode = "SR" If $sCountry = "SVALBARD AND JAN MAYEN" Then $sCountryCode = "SJ" If $sCountry = "SWAZILAND" Then $sCountryCode = "SZ" If $sCountry = "SWEDEN" Then $sCountryCode = "SE" If $sCountry = "SWITZERLAND" Then $sCountryCode = "CH" If $sCountry = "SYRIAN ARAB REPUBLIC" Then $sCountryCode = "SY" If $sCountry = "TAIWAN, PROVINCE OF CHINA" Then $sCountryCode = "TW" If $sCountry = "TAJIKISTAN" Then $sCountryCode = "TJ" If $sCountry = "TANZANIA, UNITED REPUBLIC OF" Then $sCountryCode = "TZ" If $sCountry = "THAILAND" Then $sCountryCode = "TH" If $sCountry = "TIMOR-LESTE" Then $sCountryCode = "TL" If $sCountry = "TOGO" Then $sCountryCode = "TG" If $sCountry = "TOKELAU" Then $sCountryCode = "TK" If $sCountry = "TONGA" Then $sCountryCode = "TO" If $sCountry = "TRINIDAD AND TOBAGO" Then $sCountryCode = "TT" If $sCountry = "TUNISIA" Then $sCountryCode = "TN" If $sCountry = "TURKEY" Then $sCountryCode = "TR" If $sCountry = "TURKMENISTAN" Then $sCountryCode = "TM" If $sCountry = "TURKS AND CAICOS ISLANDS" Then $sCountryCode = "TC" If $sCountry = "TUVALU" Then $sCountryCode = "TV" If $sCountry = "UGANDA" Then $sCountryCode = "UG" If $sCountry = "UKRAINE" Then $sCountryCode = "UA" If $sCountry = "UNITED ARAB EMIRATES" Then $sCountryCode = "AE" If $sCountry = "UNITED KINGDOM" Then $sCountryCode = "GB" If $sCountry = "UNITED STATES" Then $sCountryCode = "US" If $sCountry = "UNITED STATES MINOR OUTLYING ISLANDS" Then $sCountryCode = "UM" If $sCountry = "URUGUAY" Then $sCountryCode = "UY" If $sCountry = "UZBEKISTAN" Then $sCountryCode = "UZ" If $sCountry = "VANUATU" Then $sCountryCode = "VU" If $sCountry = "VENEZUELA, BOLIVARIAN REPUBLIC OF" Then $sCountryCode = "VE" If $sCountry = "VIET NAM" Then $sCountryCode = "VN" If $sCountry = "VIRGIN ISLANDS, BRITISH" Then $sCountryCode = "VG" If $sCountry = "VIRGIN ISLANDS, U.S." Then $sCountryCode = "VI" If $sCountry = "WALLIS AND FUTUNA" Then $sCountryCode = "WF" If $sCountry = "WESTERN SAHARA" Then $sCountryCode = "EH" If $sCountry = "YEMEN" Then $sCountryCode = "YE" If $sCountry = "ZAMBIA" Then $sCountryCode = "ZM" If $sCountry = "ZIMBABWE" Then $sCountryCode = "ZW" Return $sCountryCode EndFunc ;==>_CountryNameToISO ImageSearch15.au3 featuring _ImageSearchStartup() and _ImageSearchShutdown() Link to comment Share on other sites More sharing options...
rcmaehl Posted February 24, 2014 Share Posted February 24, 2014 Use to convert data that has country names to their corresponding 2-digit codes. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 Local $sCountry = "Fiji" ConsoleWrite("ISO Country Code: " & _CountryNameToISO($sCountry) & @CR) Func _CountryNameToISO($sCountry) Local $sCountryCode ;names and codes according to ;http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm ;updated in December 2013 If $sCountry = "AFGHANISTAN" Then $sCountryCode = "AF" If $sCountry = "ÅLAND ISLANDS" Then $sCountryCode = "AX" If $sCountry = "ALBANIA" Then $sCountryCode = "AL" If $sCountry = "ALGERIA" Then $sCountryCode = "DZ" If $sCountry = "AMERICAN SAMOA" Then $sCountryCode = "AS" If $sCountry = "ANDORRA" Then $sCountryCode = "AD" If $sCountry = "ANGOLA" Then $sCountryCode = "AO" If $sCountry = "ANGUILLA" Then $sCountryCode = "AI" If $sCountry = "ANTARCTICA" Then $sCountryCode = "AQ" If $sCountry = "ANTIGUA AND BARBUDA" Then $sCountryCode = "AG" If $sCountry = "ARGENTINA" Then $sCountryCode = "AR" If $sCountry = "ARMENIA" Then $sCountryCode = "AM" If $sCountry = "ARUBA" Then $sCountryCode = "AW" If $sCountry = "AUSTRALIA" Then $sCountryCode = "AU" If $sCountry = "AUSTRIA" Then $sCountryCode = "AT" If $sCountry = "AZERBAIJAN" Then $sCountryCode = "AZ" If $sCountry = "BAHAMAS" Then $sCountryCode = "BS" If $sCountry = "BAHRAIN" Then $sCountryCode = "BH" If $sCountry = "BANGLADESH" Then $sCountryCode = "BD" If $sCountry = "BARBADOS" Then $sCountryCode = "BB" If $sCountry = "BELARUS" Then $sCountryCode = "BY" If $sCountry = "BELGIUM" Then $sCountryCode = "BE" If $sCountry = "BELIZE" Then $sCountryCode = "BZ" If $sCountry = "BENIN" Then $sCountryCode = "BJ" If $sCountry = "BERMUDA" Then $sCountryCode = "BM" If $sCountry = "BHUTAN" Then $sCountryCode = "BT" If $sCountry = "BOLIVIA, PLURINATIONAL STATE OF" Then $sCountryCode = "BO" If $sCountry = "BONAIRE, SINT EUSTATIUS AND SABA" Then $sCountryCode = "BQ" If $sCountry = "BOSNIA AND HERZEGOVINA" Then $sCountryCode = "BA" If $sCountry = "BOTSWANA" Then $sCountryCode = "BW" If $sCountry = "BOUVET ISLAND" Then $sCountryCode = "BV" If $sCountry = "BRAZIL" Then $sCountryCode = "BR" If $sCountry = "BRITISH INDIAN OCEAN TERRITORY" Then $sCountryCode = "IO" If $sCountry = "BRUNEI DARUSSALAM" Then $sCountryCode = "BN" If $sCountry = "BULGARIA" Then $sCountryCode = "BG" If $sCountry = "BURKINA FASO" Then $sCountryCode = "BF" If $sCountry = "BURUNDI" Then $sCountryCode = "BI" If $sCountry = "CAMBODIA" Then $sCountryCode = "KH" If $sCountry = "CAMEROON" Then $sCountryCode = "CM" If $sCountry = "CANADA" Then $sCountryCode = "CA" If $sCountry = "CAPE VERDE" Then $sCountryCode = "CV" If $sCountry = "CAYMAN ISLANDS" Then $sCountryCode = "KY" If $sCountry = "CENTRAL AFRICAN REPUBLIC" Then $sCountryCode = "CF" If $sCountry = "CHAD" Then $sCountryCode = "TD" If $sCountry = "CHILE" Then $sCountryCode = "CL" If $sCountry = "CHINA" Then $sCountryCode = "CN" If $sCountry = "CHRISTMAS ISLAND" Then $sCountryCode = "CX" If $sCountry = "COCOS (KEELING) ISLANDS" Then $sCountryCode = "CC" If $sCountry = "COLOMBIA" Then $sCountryCode = "CO" If $sCountry = "COMOROS" Then $sCountryCode = "KM" If $sCountry = "CONGO" Then $sCountryCode = "CG" If $sCountry = "CONGO, THE DEMOCRATIC REPUBLIC OF THE" Then $sCountryCode = "CD" If $sCountry = "COOK ISLANDS" Then $sCountryCode = "CK" If $sCountry = "COSTA RICA" Then $sCountryCode = "CR" If $sCountry = "CÔTE D'IVOIRE" Then $sCountryCode = "CI" If $sCountry = "CROATIA" Then $sCountryCode = "HR" If $sCountry = "CUBA" Then $sCountryCode = "CU" If $sCountry = "CURAÇAO" Then $sCountryCode = "CW" If $sCountry = "CYPRUS" Then $sCountryCode = "CY" If $sCountry = "CZECH REPUBLIC" Then $sCountryCode = "CZ" If $sCountry = "DENMARK" Then $sCountryCode = "DK" If $sCountry = "DJIBOUTI" Then $sCountryCode = "DJ" If $sCountry = "DOMINICA" Then $sCountryCode = "DM" If $sCountry = "DOMINICAN REPUBLIC" Then $sCountryCode = "DO" If $sCountry = "ECUADOR" Then $sCountryCode = "EC" If $sCountry = "EGYPT" Then $sCountryCode = "EG" If $sCountry = "EL SALVADOR" Then $sCountryCode = "SV" If $sCountry = "EQUATORIAL GUINEA" Then $sCountryCode = "GQ" If $sCountry = "ERITREA" Then $sCountryCode = "ER" If $sCountry = "ESTONIA" Then $sCountryCode = "EE" If $sCountry = "ETHIOPIA" Then $sCountryCode = "ET" If $sCountry = "FALKLAND ISLANDS (MALVINAS)" Then $sCountryCode = "FK" If $sCountry = "FAROE ISLANDS" Then $sCountryCode = "FO" If $sCountry = "FIJI" Then $sCountryCode = "FJ" If $sCountry = "FINLAND" Then $sCountryCode = "FI" If $sCountry = "FRANCE" Then $sCountryCode = "FR" If $sCountry = "FRENCH GUIANA" Then $sCountryCode = "GF" If $sCountry = "FRENCH POLYNESIA" Then $sCountryCode = "PF" If $sCountry = "FRENCH SOUTHERN TERRITORIES" Then $sCountryCode = "TF" If $sCountry = "GABON" Then $sCountryCode = "GA" If $sCountry = "GAMBIA" Then $sCountryCode = "GM" If $sCountry = "GEORGIA" Then $sCountryCode = "GE" If $sCountry = "GERMANY" Then $sCountryCode = "DE" If $sCountry = "GHANA" Then $sCountryCode = "GH" If $sCountry = "GIBRALTAR" Then $sCountryCode = "GI" If $sCountry = "GREECE" Then $sCountryCode = "GR" If $sCountry = "GREENLAND" Then $sCountryCode = "GL" If $sCountry = "GRENADA" Then $sCountryCode = "GD" If $sCountry = "GUADELOUPE" Then $sCountryCode = "GP" If $sCountry = "GUAM" Then $sCountryCode = "GU" If $sCountry = "GUATEMALA" Then $sCountryCode = "GT" If $sCountry = "GUERNSEY" Then $sCountryCode = "GG" If $sCountry = "GUINEA" Then $sCountryCode = "GN" If $sCountry = "GUINEA-BISSAU" Then $sCountryCode = "GW" If $sCountry = "GUYANA" Then $sCountryCode = "GY" If $sCountry = "HAITI" Then $sCountryCode = "HT" If $sCountry = "HEARD ISLAND AND MCDONALD ISLANDS" Then $sCountryCode = "HM" If $sCountry = "HOLY SEE (VATICAN CITY STATE)" Then $sCountryCode = "VA" If $sCountry = "HONDURAS" Then $sCountryCode = "HN" If $sCountry = "HONG KONG" Then $sCountryCode = "HK" If $sCountry = "HUNGARY" Then $sCountryCode = "HU" If $sCountry = "ICELAND" Then $sCountryCode = "IS" If $sCountry = "INDIA" Then $sCountryCode = "IN" If $sCountry = "INDONESIA" Then $sCountryCode = "ID" If $sCountry = "IRAN, ISLAMIC REPUBLIC OF" Then $sCountryCode = "IR" If $sCountry = "IRAQ" Then $sCountryCode = "IQ" If $sCountry = "IRELAND" Then $sCountryCode = "IE" If $sCountry = "ISLE OF MAN" Then $sCountryCode = "IM" If $sCountry = "ISRAEL" Then $sCountryCode = "IL" If $sCountry = "ITALY" Then $sCountryCode = "IT" If $sCountry = "JAMAICA" Then $sCountryCode = "JM" If $sCountry = "JAPAN" Then $sCountryCode = "JP" If $sCountry = "JERSEY" Then $sCountryCode = "JE" If $sCountry = "JORDAN" Then $sCountryCode = "JO" If $sCountry = "KAZAKHSTAN" Then $sCountryCode = "KZ" If $sCountry = "KENYA" Then $sCountryCode = "KE" If $sCountry = "KIRIBATI" Then $sCountryCode = "KI" If $sCountry = "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF" Then $sCountryCode = "KP" If $sCountry = "KOREA, REPUBLIC OF" Then $sCountryCode = "KR" If $sCountry = "KUWAIT" Then $sCountryCode = "KW" If $sCountry = "KYRGYZSTAN" Then $sCountryCode = "KG" If $sCountry = "LAO PEOPLE'S DEMOCRATIC REPUBLIC" Then $sCountryCode = "LA" If $sCountry = "LATVIA" Then $sCountryCode = "LV" If $sCountry = "LEBANON" Then $sCountryCode = "LB" If $sCountry = "LESOTHO" Then $sCountryCode = "LS" If $sCountry = "LIBERIA" Then $sCountryCode = "LR" If $sCountry = "LIBYA" Then $sCountryCode = "LY" If $sCountry = "LIECHTENSTEIN" Then $sCountryCode = "LI" If $sCountry = "LITHUANIA" Then $sCountryCode = "LT" If $sCountry = "LUXEMBOURG" Then $sCountryCode = "LU" If $sCountry = "MACAO" Then $sCountryCode = "MO" If $sCountry = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF" Then $sCountryCode = "MK" If $sCountry = "MADAGASCAR" Then $sCountryCode = "MG" If $sCountry = "MALAWI" Then $sCountryCode = "MW" If $sCountry = "MALAYSIA" Then $sCountryCode = "MY" If $sCountry = "MALDIVES" Then $sCountryCode = "MV" If $sCountry = "MALI" Then $sCountryCode = "ML" If $sCountry = "MALTA" Then $sCountryCode = "MT" If $sCountry = "MARSHALL ISLANDS" Then $sCountryCode = "MH" If $sCountry = "MARTINIQUE" Then $sCountryCode = "MQ" If $sCountry = "MAURITANIA" Then $sCountryCode = "MR" If $sCountry = "MAURITIUS" Then $sCountryCode = "MU" If $sCountry = "MAYOTTE" Then $sCountryCode = "YT" If $sCountry = "MEXICO" Then $sCountryCode = "MX" If $sCountry = "MICRONESIA, FEDERATED STATES OF" Then $sCountryCode = "FM" If $sCountry = "MOLDOVA, REPUBLIC OF" Then $sCountryCode = "MD" If $sCountry = "MONACO" Then $sCountryCode = "MC" If $sCountry = "MONGOLIA" Then $sCountryCode = "MN" If $sCountry = "MONTENEGRO" Then $sCountryCode = "ME" If $sCountry = "MONTSERRAT" Then $sCountryCode = "MS" If $sCountry = "MOROCCO" Then $sCountryCode = "MA" If $sCountry = "MOZAMBIQUE" Then $sCountryCode = "MZ" If $sCountry = "MYANMAR" Then $sCountryCode = "MM" If $sCountry = "NAMIBIA" Then $sCountryCode = "NA" If $sCountry = "NAURU" Then $sCountryCode = "NR" If $sCountry = "NEPAL" Then $sCountryCode = "NP" If $sCountry = "NETHERLANDS" Then $sCountryCode = "NL" If $sCountry = "NEW CALEDONIA" Then $sCountryCode = "NC" If $sCountry = "NEW ZEALAND" Then $sCountryCode = "NZ" If $sCountry = "NICARAGUA" Then $sCountryCode = "NI" If $sCountry = "NIGER" Then $sCountryCode = "NE" If $sCountry = "NIGERIA" Then $sCountryCode = "NG" If $sCountry = "NIUE" Then $sCountryCode = "NU" If $sCountry = "NORFOLK ISLAND" Then $sCountryCode = "NF" If $sCountry = "NORTHERN MARIANA ISLANDS" Then $sCountryCode = "MP" If $sCountry = "NORWAY" Then $sCountryCode = "NO" If $sCountry = "OMAN" Then $sCountryCode = "OM" If $sCountry = "PAKISTAN" Then $sCountryCode = "PK" If $sCountry = "PALAU" Then $sCountryCode = "PW" If $sCountry = "PALESTINE, STATE OF" Then $sCountryCode = "PS" If $sCountry = "PANAMA" Then $sCountryCode = "PA" If $sCountry = "PAPUA NEW GUINEA" Then $sCountryCode = "PG" If $sCountry = "PARAGUAY" Then $sCountryCode = "PY" If $sCountry = "PERU" Then $sCountryCode = "PE" If $sCountry = "PHILIPPINES" Then $sCountryCode = "PH" If $sCountry = "PITCAIRN" Then $sCountryCode = "PN" If $sCountry = "POLAND" Then $sCountryCode = "PL" If $sCountry = "PORTUGAL" Then $sCountryCode = "PT" If $sCountry = "PUERTO RICO" Then $sCountryCode = "PR" If $sCountry = "QATAR" Then $sCountryCode = "QA" If $sCountry = "RÉUNION" Then $sCountryCode = "RE" If $sCountry = "ROMANIA" Then $sCountryCode = "RO" If $sCountry = "RUSSIAN FEDERATION" Then $sCountryCode = "RU" If $sCountry = "RWANDA" Then $sCountryCode = "RW" If $sCountry = "SAINT BARTHÉLEMY" Then $sCountryCode = "BL" If $sCountry = "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA" Then $sCountryCode = "SH" If $sCountry = "SAINT KITTS AND NEVIS" Then $sCountryCode = "KN" If $sCountry = "SAINT LUCIA" Then $sCountryCode = "LC" If $sCountry = "SAINT MARTIN (FRENCH PART)" Then $sCountryCode = "MF" If $sCountry = "SAINT PIERRE AND MIQUELON" Then $sCountryCode = "PM" If $sCountry = "SAINT VINCENT AND THE GRENADINES" Then $sCountryCode = "VC" If $sCountry = "SAMOA" Then $sCountryCode = "WS" If $sCountry = "SAN MARINO" Then $sCountryCode = "SM" If $sCountry = "SAO TOME AND PRINCIPE" Then $sCountryCode = "ST" If $sCountry = "SAUDI ARABIA" Then $sCountryCode = "SA" If $sCountry = "SENEGAL" Then $sCountryCode = "SN" If $sCountry = "SERBIA" Then $sCountryCode = "RS" If $sCountry = "SEYCHELLES" Then $sCountryCode = "SC" If $sCountry = "SIERRA LEONE" Then $sCountryCode = "SL" If $sCountry = "SINGAPORE" Then $sCountryCode = "SG" If $sCountry = "SINT MAARTEN (DUTCH PART)" Then $sCountryCode = "SX" If $sCountry = "SLOVAKIA" Then $sCountryCode = "SK" If $sCountry = "SLOVENIA" Then $sCountryCode = "SI" If $sCountry = "SOLOMON ISLANDS" Then $sCountryCode = "SB" If $sCountry = "SOMALIA" Then $sCountryCode = "SO" If $sCountry = "SOUTH AFRICA" Then $sCountryCode = "ZA" If $sCountry = "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS" Then $sCountryCode = "GS" If $sCountry = "SOUTH SUDAN" Then $sCountryCode = "SS" If $sCountry = "SPAIN" Then $sCountryCode = "ES" If $sCountry = "SRI LANKA" Then $sCountryCode = "LK" If $sCountry = "SUDAN" Then $sCountryCode = "SD" If $sCountry = "SURINAME" Then $sCountryCode = "SR" If $sCountry = "SVALBARD AND JAN MAYEN" Then $sCountryCode = "SJ" If $sCountry = "SWAZILAND" Then $sCountryCode = "SZ" If $sCountry = "SWEDEN" Then $sCountryCode = "SE" If $sCountry = "SWITZERLAND" Then $sCountryCode = "CH" If $sCountry = "SYRIAN ARAB REPUBLIC" Then $sCountryCode = "SY" If $sCountry = "TAIWAN, PROVINCE OF CHINA" Then $sCountryCode = "TW" If $sCountry = "TAJIKISTAN" Then $sCountryCode = "TJ" If $sCountry = "TANZANIA, UNITED REPUBLIC OF" Then $sCountryCode = "TZ" If $sCountry = "THAILAND" Then $sCountryCode = "TH" If $sCountry = "TIMOR-LESTE" Then $sCountryCode = "TL" If $sCountry = "TOGO" Then $sCountryCode = "TG" If $sCountry = "TOKELAU" Then $sCountryCode = "TK" If $sCountry = "TONGA" Then $sCountryCode = "TO" If $sCountry = "TRINIDAD AND TOBAGO" Then $sCountryCode = "TT" If $sCountry = "TUNISIA" Then $sCountryCode = "TN" If $sCountry = "TURKEY" Then $sCountryCode = "TR" If $sCountry = "TURKMENISTAN" Then $sCountryCode = "TM" If $sCountry = "TURKS AND CAICOS ISLANDS" Then $sCountryCode = "TC" If $sCountry = "TUVALU" Then $sCountryCode = "TV" If $sCountry = "UGANDA" Then $sCountryCode = "UG" If $sCountry = "UKRAINE" Then $sCountryCode = "UA" If $sCountry = "UNITED ARAB EMIRATES" Then $sCountryCode = "AE" If $sCountry = "UNITED KINGDOM" Then $sCountryCode = "GB" If $sCountry = "UNITED STATES" Then $sCountryCode = "US" If $sCountry = "UNITED STATES MINOR OUTLYING ISLANDS" Then $sCountryCode = "UM" If $sCountry = "URUGUAY" Then $sCountryCode = "UY" If $sCountry = "UZBEKISTAN" Then $sCountryCode = "UZ" If $sCountry = "VANUATU" Then $sCountryCode = "VU" If $sCountry = "VENEZUELA, BOLIVARIAN REPUBLIC OF" Then $sCountryCode = "VE" If $sCountry = "VIET NAM" Then $sCountryCode = "VN" If $sCountry = "VIRGIN ISLANDS, BRITISH" Then $sCountryCode = "VG" If $sCountry = "VIRGIN ISLANDS, U.S." Then $sCountryCode = "VI" If $sCountry = "WALLIS AND FUTUNA" Then $sCountryCode = "WF" If $sCountry = "WESTERN SAHARA" Then $sCountryCode = "EH" If $sCountry = "YEMEN" Then $sCountryCode = "YE" If $sCountry = "ZAMBIA" Then $sCountryCode = "ZM" If $sCountry = "ZIMBABWE" Then $sCountryCode = "ZW" Return $sCountryCode EndFunc ;==>_CountryNameToISO Wouldn't Switch $sCountry work better than all those If statements? DatMCEyeBall 1 My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
Guest Posted March 16, 2014 Share Posted March 16, 2014 (edited) This code snippet is expansion to _ResourcePlaySound() from Resources UDF. Thanks to Melba23 for helped me here: '?do=embed' frameborder='0' data-embedContent>> 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.PlaySoundGroup.rarPlaySoundGroup - v2.rar Edited March 16, 2014 by Guest Link to comment Share on other sites More sharing options...
j981 Posted March 17, 2014 Share Posted March 17, 2014 (edited) 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. expandcollapse popup#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 March 22, 2014 by j981 Link to comment Share on other sites More sharing options...
j981 Posted March 17, 2014 Share Posted March 17, 2014 (edited) 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 March 17, 2014 by j981 Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted May 5, 2014 Share Posted May 5, 2014 (edited) 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 expandcollapse popup#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 May 5, 2014 by DigitalFacade82 Link to comment Share on other sites More sharing options...
GerrOrneq Posted May 6, 2014 Share Posted May 6, 2014 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'd be unstoppable... if not for law enforcement and physics. Marriage, the number 1 cause of divorce. Don't steal... the government hates competition. Irish Government Motto: We’ve got what it takes to take what you’ve got. Birthdays are good for you. Statistics show that the people who have the most live the longest. Failure is not an option. It comes bundled with your Microsoft product.-- Ferenc Mantfeld If you learn from your mistakes, then why ain't I a genius?! -- Anonymous Remember, live every day as if it was your last day! one day you will be right. How is it one careless match can start a forest fire, but it takes a whole box to start a campfire? Sure my system is secure, it just locked up again. I haven't lost my mind; I have a tape back-up somewhere. ~Author Unknown Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted May 7, 2014 Share Posted May 7, 2014 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? Link to comment Share on other sites More sharing options...
BrewManNH Posted May 7, 2014 Share Posted May 7, 2014 Have you tried FileCreateShortcut? You can call it whatever you want with it. DigitalFacade82 1 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 XP, 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 GudeHow to ask questions the smart way! 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. 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 editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
DigitalFacade82 Posted May 8, 2014 Share Posted May 8, 2014 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? Link to comment Share on other sites More sharing options...
UEZ Posted May 22, 2014 Share Posted May 22, 2014 (edited) Here a snipped how to colorize each character of a label text: GUICtrlCreateLabelColorized: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> _GDIPlus_Startup() Global $hGUI = GUICreate("Test", 570, 100), $i GUISetBkColor(0xFFFFFF) Global $sText1 = "These chars were colorized separately" Global $aColors1[StringLen($sText1)] For $i = 0 To UBound($aColors1) - 1 $aColors1[$i] = Random(0x000000, 0x400000, 1) Next Global $aLabel1 = GUICtrlCreateLabelColorized($sText1, $aColors1, 10, 10, 18, "Comic Sans MS") Global $sText2 = "using " & Chr(203) & "label controls" & Chr(202) & " with " & Chr(201) & "bold" & Chr(200) & " words. ;-)" Global $aColors2[StringLen($sText2)] Global $aLabel2 = GUICtrlCreateLabelColorized($sText2, $aColors2, 18, 50, 26, "Times New Roman") 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. Chr(200) = disable bold char, Chr(201) = enable bold char, ; Chr(202) = disable italic char, Chr(203) = enable italic char, ; $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 4 (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.95 build 2017-09-11 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 = 4, $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, _ $bBold = 0, $bItalic = 0, $iBold = 700, $iItalic = 2, $iWeightPrev = $iWeight, $iItalicPrev = $iAttribute 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 Switch $sChar Case Chr(200) $bBold = 0 ContinueLoop Case Chr(201) $bBold = 1 ContinueLoop Case Chr(202) $bItalic = 0 ContinueLoop Case Chr(203) $bItalic = 1 ContinueLoop EndSwitch $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 If $bBold Then $iWeight = $iBold Else $iWeight = $iWeightPrev EndIf If $bItalic Then $iAttribute = $iItalic Else $iAttribute = $iItalicPrev EndIf 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 ; Version ..........: 2020-03-08 beta ; 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) _GDIPlus_GraphicsDispose($hGraphics) _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 for next char $aDim[2] = $aInfo[0].Width ;Width of the rectangle $aDim[3] = $aInfo[0].Height ;Height of the rectangle Return $aDim EndFunc ;==>__MeasureString Requires AutoIt version 3.3.10.2 or higher! Br, UEZ Edited March 8, 2020 by UEZ Little update web2win, mesale0077, Professor_Bernd and 1 other 3 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 23, 2014 Moderators Share Posted May 23, 2014 Awesome, UEZ. Made my eyes bleed with the bright colors, but great work nevertheless "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
UEZ Posted May 23, 2014 Share Posted May 23, 2014 (edited) Thanks JLogan3o13. Changed bg to black to be less dazzling for your eyes. Br,UEZ Edited May 23, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
mLipok Posted June 2, 2014 Share Posted June 2, 2014 (edited) Slided ON / OFF by @taietel expandcollapse popup#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 June 2, 2014 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "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, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
guinness Posted June 2, 2014 Share Posted June 2, 2014 Thanks mLipok. Though the code needs a bit of updating in my opinion. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
mLipok Posted June 3, 2014 Share Posted June 3, 2014 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 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "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, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
MikahS Posted August 1, 2014 Share Posted August 1, 2014 (edited) Get all environmental variables from the local computer: #include <Constants.au3> Local $PID, $line, $PIDerror ;;This simple program will pop a msgbox up showing all enviroment variables in the local machine $PID = Run(@ComSpec & ' /c set', @SystemDir, @SW_HIDE, $STDOUT_CHILD) $PIDerror = @error If $PIDerror <> 0 Then MsgBox(0, "error", "error running the $PID command; error: " & $PIDerror) EndIf SetError(0) ;;main line While 1 $line &= StdoutRead($PID) If @error Then ExitLoop EndIf WEnd MsgBox(0, "ENVIROMENT VARIABLES", $line) Edited August 4, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
MikahS Posted August 6, 2014 Share Posted August 6, 2014 (edited) Simple CPU temp monitor using >GraphGDIPlus.au3. Updates ticks allowing it to run indefinitely. expandcollapse popup#RequireAdmin #include <GraphGDIPlus.au3> #include <GUIConstants.au3> AdlibRegister("findTemp", 9000) AdlibRegister("_Draw_Graph", 10000) Local $hGUI, $hGraph, $temp, $Counter = 1, $iCheck, $msg, $xVal = 1 $hGUI = GUICreate("", 600, 350) ; create the GUI window $iCheck = GUICtrlCreateCheckbox("Reset on next interval", 462, 1) GUISetState() ; show the window CreateGraph() ; create the graph findTemp() ; find the temp _Draw_Graph() ; draw the graph While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Quit() EndSwitch WEnd Func CreateGraph() If IsArray($hGraph) = 0 Then ; if an array hasn't been made; then make it $hGraph = _GraphGDIPlus_Create($hGUI, 37, 24, 545, 300, 0xFF000000, 0xFF88B3DD) ; create the graph EndIf If $Counter > 24 Then ; if the counter is greater then 24; lets start making this move over one on the x range _GraphGDIPlus_Set_RangeX($hGraph, $xVal, $Counter, 24) ; this will move us one full tick over to the right from the start and finish of the x range $xVal += 1 ; add one to our start x range Else _GraphGDIPlus_Set_RangeX($hGraph, 0, 24, 24) ; set the x range from 0 - 24 putting all 24 ticks on screen _GraphGDIPlus_Set_RangeY($hGraph, 0, 125, 5) ; set the y range from 0 - 125 only putting 5 ticks on screen _GraphGDIPlus_Set_GridX($hGraph, 1, 0xFF6993BE) ; set the x grid _GraphGDIPlus_Set_GridY($hGraph, 1, 0xFF6993BE) ; set the y grid EndIf EndFunc ;==>CreateGraph Func _Draw_Graph() Local $rCheckbox $rCheckbox = GUICtrlRead($iCheck) ; read the checkbox value; 1 if clicked If $rCheckbox = 1 Then ; if clicked then... ControlClick($hGUI, "Reset on next interval", $iCheck) ; unclick the checkbox _GraphGDIPlus_Delete($hGUI, $hGraph) ; delete the graph $Counter = 1 ; reset the counter $xVal = 1 ; reset the x range counter CreateGraph() ; and create the graph again EndIf If $Counter > 24 Then ; if we've reached the end CreateGraph() ; and create the graph again EndIf _GraphGDIPlus_Set_PenColor($hGraph, 0xFF325D87) ; set the color of the line _GraphGDIPlus_Set_PenSize($hGraph, 2) ; set the size of the line _GraphGDIPlus_Plot_Start($hGraph, $Counter, 0) ; set the start on the graph plot _GraphGDIPlus_Plot_Line($hGraph, $Counter, $temp) ; set the line ending _GraphGDIPlus_Refresh($hGraph) ; draw it to the screen $Counter += 1 ; add one to our counter EndFunc ;==>_Draw_Graph Func findTemp() Local $aClasses, $nCounter = 0 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi") $Instances = $objWMIService.InstancesOf("MSAcpi_ThermalZoneTemperature") $aClasses = $objWMIService.subClassesOf() For $class in $aClasses If StringInStr($class.Path_.Path, "MSAcpi_ThermalZoneTemperature") <> 0 Then $nCounter += 1 EndIf Next If $nCounter = 0 Then MsgBox(0, "Not Supported", "I'm sorry, but getting of the CPU temp is not supported on your machine. Exiting...") Quit() Endif For $Item In $Instances $temp = ($Item.CurrentTemperature - 2732) / 10 ; set the temp Next EndFunc ;==>findTemp Func Quit() _GraphGDIPlus_Delete($hGUI, $hGraph) ; delete the graph Exit ; get us out EndFunc ;==>Quit EDIT: Added a check to see if the WMI temperature hive was present; if it is not, then it will tell you and exit. Edited August 8, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2014 Moderators Share Posted August 6, 2014 MikahS, you may want to add a check in there for whether that WMI hive is present, or they'll be staring at a blank graph. Remember that not all machines support reading of the cpu temperature. If you Google "msacpi_thermalzonetemperature not supported" you'll find a number of threads on MSDN and SO where people run into just this kind of issue. Otherwise, a great use of GDI+ graphing, very nice addition "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now