Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/27/2011 in all areas

  1. This works but I would look into using guigetmsg() #include <Array.au3> #include <GUIConstants.au3> Global $currentprinter Global $defaultprinter Global $printer_list[1] Global $printer_list_ext[1] Global $printer_radio_array[1] Global $imprimante Global $printername Global $gh GetPrinter() Do Sleep(100) Until $printername MsgBox(0,'',$printername) Func GetPrinter() $regprinters = "HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionDevices" $currentprinter = RegRead("HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows", "Device") $defaultprinter = StringLeft($currentprinter, StringInStr($currentprinter, ",") - 1) Dim $i = 1 Dim $erreur_reg = False While Not $erreur_reg $imprimante = RegEnumVal($regprinters, $i) $erreur_reg = @error If Not $erreur_reg Then _ArrayAdd($printer_list, $imprimante) _ArrayAdd($printer_list_ext, $imprimante & "," & RegRead($regprinters, $imprimante)) EndIf $i = $i + 1 WEnd _ArrayDelete($printer_list, 0) _ArrayDelete($printer_list_ext, 0) If UBound($printer_list) >= 2 Then ;if 2 or more printers available, we show the dialog Dim $groupheight = (UBound($printer_list) + 1) * 30 Dim $guiheight = $groupheight + 50 Dim $buttontop = $groupheight + 20 Opt("GUIOnEventMode", 1) $gh = GUICreate("Select a printer for this PDF file:", 400, $guiheight) Dim $font = "Verdana" GUISetFont(10, 400, 0, $font) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetFont(10, 400, 0, $font) GUICtrlCreateGroup("Available printers:", 10, 10, 380, $groupheight) Dim $position_vertical = 0 For $i = 0 To UBound($printer_list) - 1 Step 1 GUISetFont(10, 400, 0, $font) $position_vertical = $position_vertical + 30 $radio = GUICtrlCreateRadio($printer_list[$i], 20, $position_vertical, 350, 20) _ArrayAdd($printer_radio_array, $radio) If $currentprinter = $printer_list_ext[$i] Then GUICtrlSetState($radio, $GUI_CHECKED) EndIf Next _ArrayDelete($printer_radio_array, 0) GUISetFont(10, 400, 0, $font) $okbutton = GUICtrlCreateButton("OK", 10, $buttontop, 50, 25) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetState() EndIf EndFunc ;==>GetPrinter Func OKButton() For $i = 0 To UBound($printer_radio_array) - 1 Step 1 If GUICtrlRead($printer_radio_array[$i]) = 1 Then $printername = StringLeft($printer_list_ext[$i], StringInStr($printer_list_ext[$i], ",") - 1) EndIf Next GUIDelete($gh) ; MsgBox(0, "", $printername) ConsoleWrite($printername & @LF) EndFunc ;==>OKButton Func CLOSEClicked() $printername = $defaultprinter GUIDelete($gh) ; MsgBox(0, "", $printername) Return $printername EndFunc ;==>CLOSEClicked
    1 point
  2. iRAWRRichard, If your just trying to center the app then just divide desktop widths and heights by 2 like JS said. If your going for a different location, I treat the cordinates as a percentage ratio. For example if the GUI sits at 100,100 on a 1024x768 resolution, a similar location on 1440x900 would be (100/1024) * 1440 -> 140.625 (100/768) * 900 -> 117.1875 So you end up with 141, 117
    1 point
  3. datefon, test this with the two pictures and see if it's ok when you move the slider: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> _Test() Func _Test() Local $hMain = GUICreate("Form1", 220, 310) Local $hTrans = GUICtrlCreateSlider(10, 280, 200, 25, 0) GUICtrlSetLimit(-1, 254, 0) Local $hWhite = _Child($hMain, 200, 260, 10, 10) Local $hPicWhite = GUICtrlCreatePic("", 0, 0, 200, 260) _SetPNGIntoPicControl($hPicWhite, @ScriptDir & "1.png") Local $hYellow = _Child($hMain, 200, 260, 10, 10) Local $hPicYellow = GUICtrlCreatePic("", 0, 0, 200, 260) _SetPNGIntoPicControl($hPicYellow, @ScriptDir & "2.png") WinSetTrans($hYellow, "", 0) GUISetState(@SW_SHOW, $hMain) GUISetState(@SW_SHOW, $hWhite) GUISetState(@SW_SHOW, $hYellow) While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hTrans WinSetTrans($hYellow, "", GUICtrlRead($hTrans)) EndSwitch WEnd EndFunc ;==>_Test Func _Child($hParent, $iW, $iH, $iX, $iY) Local $hChild = GUICreate("", $iW - $iX - 5, $iH - $iY - 10, $iX, $iY + 6, $WS_POPUP, $WS_EX_MDICHILD, $hParent) Return $hChild EndFunc ;==>_Child Func _SetPNGIntoPicControl($iPic, $sPNGFile) ;thanks to Monoscout _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x172, 0, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_SetPNGIntoPicControlImages: 1.png, 2.png
    1 point
  4. Valik

    GMAIL Automation!

    Point #1 violates our rules. Beyond that it escapes me why you need to do this. Set up a filter to delete the mail automatically. Thread locked.
    1 point
  5. Alright, I will try to get rainmeter to display the latest entries instead of the first ones then.
    1 point
  6. Jon

    AutoIt v3.3.8.0 Released

    AutoIt v3.3.8.0 Released Thanks to all involved in coding and testing. Merry xmas. Download History Script Breaking Changes
    1 point
  7. gMgmc, Welcome to the AutoIt forum. Answer to your first question - do something like this: #include <GUIConstantsEx.au3> $sLanguage = IniRead("language.ini", "Current", "Language", "English") $sOne = IniRead("language.ini", $sLanguage, "One", "One") $sTwo = IniRead("language.ini", $sLanguage, "Two", "Two") $sThree = IniRead("language.ini", $sLanguage, "Three", "Three") $hGUI = GUICreate("Test", 500, 500) $hLabel_1 = GUICtrlCreateLabel($sOne, 10, 10, 100, 20) $hLabel_2 = GUICtrlCreateLabel($sTwo, 10, 50, 100, 20) $hLabel_3 = GUICtrlCreateLabel($sThree, 10, 90, 100, 20) $hCombo = GUICtrlCreateCombo("", 10, 150, 200, 20) GUICtrlSetData(-1, "English|Deutch|Francais", "English") $hButton = GUICtrlCreateButton("Set", 10, 180, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $sLanguage = GUICtrlRead($hCombo) IniWrite("language.ini", "Current", "Language", $sLanguage) $sOne = IniRead("language.ini", $sLanguage, "One", "One") GUICtrlSetData($hLabel_1, $sOne) $sTwo = IniRead("language.ini", $sLanguage, "Two", "Two") GUICtrlSetData($hLabel_2, $sTwo) $sThree = IniRead("language.ini", $sLanguage, "Three", "Three") GUICtrlSetData($hLabel_3, $sThree) EndSwitch WEndand use something like this as the ini file: [Current] Language=English [English] One=One Two=Two Three=Three [Deutch] One=Ein Two=Zwei Three=Drei [Francais] One=Un Two=Deux Three=TroisAs to the second question - _About runs a MessageBox and everything else in the script will pause until you close it. So the short answer to you question is: "You cannot!" By the way, your code is pretty messed up. You are restarting the _Main function via _Start and _Pause before you end either. This is known as recursion and will lead into BIG trouble. You need to get back to _Main using Return or having the functions end naturally, not calling it again. Perhaps if yyou posted your whole code we coudl look and see how we might get over this. M23
    1 point
×
×
  • Create New...