Jump to content

Printer Plugini Hakkında


fba44
 Share

Recommended Posts

Arkadaşlar printer pluginini biliyorsunuz yazdırmaya yarıyor. Ben bilgisayarda bulunan yazıcıları bir combobox yada listbox vs eklemek istiyorum bunu nasıl yapabilirim bu yada başka bir pluginde? Bu plugini baya kurcaladım ama bulamadım.

 Yardımcı olursanız sevinirim. Teşekkürler.

Link to comment
Share on other sites

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

  • Editor
function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
	ComboBox.AddItem("ComboBox1", Escape(oItem:Caption()), "");
    oItem = oEnum:Next();
    end
else
    Dialog.Message("","Win32_Printer Kitaplığı bulunamadı");
end

Link to comment
Share on other sites

function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
	ComboBox.AddItem("ComboBox1", Escape(oItem:Caption()), "");
    oItem = oEnum:Next();
    end
else
    Dialog.Message("","Win32_Printer Kitaplığı bulunamadı");
end

 

way hocam on numarasınız ya bukadar çabuk yanıt geleceğini hiç beklemiyordum doğrusu. Bu konu ile alakalı ufak bi projem var takıldığım yerleri tekrar sorarım inş fazla sıkmam sizi.

 

Ayrıca bir sorum olacak. Ben dün internette çok aradım ama böyle birşey bulamadım. Benim merak ettiğim şey siz nasıl buldunuz yada aklınızdan mı yazdınız bu sorumada cevap verirseniz bende bulma yönteminizi ve eksiğimi bi nebze olsun anlamış olacağım. Teşekkürler

Link to comment
Share on other sites

  • Editor

Bir ara banada lazım olmuştu o yüzden  ,tabi zamanında ben regeditten çekmiştim. Lazım olan çoğu bilgiyi windows kütüphanlerinden çekebilirsiniz.

Link to comment
Share on other sites

Bir ara banada lazım olmuştu o yüzden  ,tabi zamanında ben regeditten çekmiştim. Lazım olan çoğu bilgiyi windows kütüphanlerinden çekebilirsiniz.

 

Evet hocam regeditte olabilirdi doğru bu aklıma gelmedi hiç. Peki hocam şimdi regettende baktım da bulamadım. Hani yazıcıların durum göstergesi var hazır, çevrimdışı,beklemede,duraklatıldı gibi. Bu yazıcıların durumlarınıda çekmek istiyorum onu nasıl yapabiliriz. Ayrıca yazıcıları verdiğiniz kodla çekerken default printer comboboxta seçili olarak gelmesini istiyorum. Bunun içinde printer plugini ile denedim ama malesef olmadı o sadece gösterdiğimizi default yapıyo hangisi default yani get diye bir komutu yok. Sizin kodlarla nasıl yapabilirim bununla da alakalı bilgi verirseniz yeterli hocam heralde daha da başınızı ağrıtmam :D

default printer ile şöyle birşey buldum ama beceremedim

 

 

 

_GetDefaultPrinter; Check to see which printer is the default.
 
ConsoleWrite(_GetDefaultPrinter() & @CRLF)
 
; Get the default printer.
Func _GetDefaultPrinter()
Local $sResult = 'None', $oWMIService = ObjGet('winmgmts:\\' & '.' & '\root\cimv2')
Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_Printer Where Default = True')
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sResult = $oObjectItem.DeviceID
Next
EndIf
Return $sResult
EndFunc ;==>_GetDefaultPrinter
Link to comment
Share on other sites

Verdiğin kodlar autoit ye ait autoit bilmiyorum.Autoit bölümüne sorarsan yardımcı olacaklardır.

 

Kodu zaten internette öyle ararken buldum ne dilde olduğunu bilmiyordum. Peki bu sorduğum soruları nasıl yapabiliriz bununla ilgili bir fikrin varmı hocam

Link to comment
Share on other sites

  • Editor
function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
        ComboBox.AddItem("ComboBox1",Escape(oItem:Caption()) .. " | Status : "..Escape(oItem:WorkOffline()), "");
		if Escape(oItem:Default()) == "Yes" then
		ComboBox.SetSelected("ComboBox1",ComboBox.GetCount("ComboBox1"));
		end
        sOutput = "";
        oItem = oEnum:Next();
    end    
else
    Dialog.Message("", "Win32_Printer Kütüphanesi bulunamadı.");
end

Yazıcıları listeler Durumlarını Yanında Yazar Default olanıda seçer.

Edited by pairs
Link to comment
Share on other sites

function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
        ComboBox.AddItem("ComboBox1",Escape(oItem:Caption()) .. " | Status : "..Escape(oItem:WorkOffline()), "");
		if Escape(oItem:Default()) == "Yes" then
		ComboBox.SetSelected("ComboBox1",ComboBox.GetCount("ComboBox1"));
		end
        sOutput = "";
        oItem = oEnum:Next();
    end    
else
    Dialog.Message("", "Win32_Printer Kütüphanesi bulunamadı.");
end

Yazıcıları listeler Durumlarını Yanında Yazar Default olanıda seçer.

 

 

hocam teşekkür ederim eve gidince hemen deneyeceğim. Bunu TreeList yada Listbox şeklinede dönüştürebilirim yine sorularım olacak hocam tekrar teşekkür ederim.

 

Bu arada nasıl yaptınız bu kodları nasıl öğrenebilirim 

Link to comment
Share on other sites

hocam AMS kodlamasını biraz biliyorum zaten ufak tefek projelerde yaptım benim burda anlamadığım yerler

 

  1. unction Escape(v)
  2. if (v == nil) then return ""; end
  3. if (type(v) == "table") then return Table.Concat(v, ", "); end
  4. if (type(v) == "boolean") then
  5. if (v == true) then return "Yes"; else return "No"; end
  6. end
  7. return v;
  8. end
  9.  
  10. local sOutput = "";
  11. local oWMIService = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
  12. local oColItems = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);

 

burası yani ne bileyim baya farklı duruyor. 

Link to comment
Share on other sites

  • Editor

Orası ams nin içinde yok tabi üstteki kısım bi fonksiyon fonksiyonunu içindede if kullanılmış gelensonuca göre return ile geriye değer gönderiliyor.

 

Alttaki kısımda ise luacom pluginini bilmen laızm onun içinde lua.org du bildiğim kadarı ile oradan dökümanlarını okuyarak ögrene bilirsiniz.

Link to comment
Share on other sites

Hocam neyse kafayı şimdilik oraya takmayayım zamanla çözeriz inş. Madem durum ve default olayınıda çözdük ozaman ben combobox değil tree kullanıcam. Eve gittiğimde böyle yapıp sonucu bildiririm hocam ben gece uğraşıcam o yüzden artık yarın görüşmek üzere. Herşey için tşkler.

Link to comment
Share on other sites

pairs hocam denedim çok güzel çalışıyor ellerine sağlık. Çok az kaldı bi soru daha ondan sonra sadece bi kısımda daha yadım isticem yani şimdilik öyle görünüyor hocam.

 

Neyse daha fazla kafa şişirmeden soruma geleyim

 

ComboBox.AddItem("ComboBox1",Escape(oItem:Caption()) .. " | Status : "..Escape(oItem:WorkOffline()), "");

 

Burdaki kod yazıcının offline olup olmadığını sorguluyor ya ben peki listedeki yazıcının butona tıkladığımda offline yapacak başka bir butona bastığımda offline ı kaldıracak. Siz sadece kodları söyleyin hocam yazıcı seçtirme vs kısmını ben ayarlıcam zaten. 

 

Hocam sayenizde proje düşündüğümden daha işlevsel olacak nekadar tşk etsem azdır. Bunu da bi halledelim sonra bir kısım daha var onu hallederiz. Teşekkürler ...

Link to comment
Share on other sites

  • Editor

pairs hocam bu sorumla alakalı bir kod bulamadıysanız eğer diğer sorumu sorayım mı ??

 

O sorun la alakalı ams üzerinden herhangi bir müdahale olacagını sanmıyorum en azndan ben bilmiyorum. Ama regedit kayıtları ile yapılabilir diye düşünüyorum.

Link to comment
Share on other sites

 

O sorun la alakalı ams üzerinden herhangi bir müdahale olacagını sanmıyorum en azndan ben bilmiyorum. Ama regedit kayıtları ile yapılabilir diye düşünüyorum.

 

Evet Regedit olabilir Peki ozaman hocam aynı şekilde çevrim dışını bulduğunuz gibi yazdırma duraklatıldı yeri varya onuda get yapabilirmiyiz ??

 

Edit: 

 

ComboBox.AddItem("ComboBox1",Escape(oItem:Caption()) .. " | Status : "..Escape(oItem:WorkOffline()), "");

 

Burdaki kod gibi

Edited by fba44
Link to comment
Share on other sites

  • Editor
function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

function WMIDateStringToDate(dtmDate)
    if dtmDate then
        dtmDate = tostring(dtmDate);
        return (String.Mid (dtmDate, 7, 2)  .. "/" ..
                String.Mid (dtmDate, 5, 2)  .. "/" ..
                String.Left(dtmDate, 4)     .. " " ..
                String.Mid (dtmDate, 9, 2)  .. ":" .. 
                String.Mid (dtmDate, 11, 2) .. ":" .. 
                String.Mid (dtmDate, 13, 2)
               );
    else
        return "";
    end
end


local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
        ComboBox.AddItem("ComboBox1",Escape(oItem:Caption()) .. " | Status : "..Escape(oItem:WorkOffline()), "");
		if Escape(oItem:Default()) == "Yes" then
		ComboBox.SetSelected("ComboBox1",ComboBox.GetCount("ComboBox1"));
		end
        sOutput = "";
        oItem = oEnum:Next();
    end    
else
    Dialog.Message("", "Win32_Printer Kütüphanesi bulunamadı.");
end

local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_PrintJob", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
    Name = String.TrimRight(Escape(oItem:Caption()), "  ,6");
	sayi = ComboBox.GetCount("ComboBox1");
	for i = 0,sayi do
	  if (Name == String.Mid(ComboBox.GetItemText("ComboBox1", i), 1, String.Length(Name))) then
	     ComboBox.SetItemText("ComboBox1", i,ComboBox.GetItemText("ComboBox1", i) .." | ".. Escape(oItem:JobStatus()));
	  end
	end
        oItem = oEnum:Next();
    end
else
    Dialog.Message("", "Win32_PrintJob Kütüphanesi bulunamadı.");
end


Edited by pairs
Link to comment
Share on other sites

function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

function WMIDateStringToDate(dtmDate)
    if dtmDate then
        dtmDate = tostring(dtmDate);
        return (String.Mid (dtmDate, 7, 2)  .. "/" ..
                String.Mid (dtmDate, 5, 2)  .. "/" ..
                String.Left(dtmDate, 4)     .. " " ..
                String.Mid (dtmDate, 9, 2)  .. ":" .. 
                String.Mid (dtmDate, 11, 2) .. ":" .. 
                String.Mid (dtmDate, 13, 2)
               );
    else
        return "";
    end
end


local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_Printer", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
        ComboBox.AddItem("ComboBox1",Escape(oItem:Caption()) .. " | Status : "..Escape(oItem:WorkOffline()), "");
		if Escape(oItem:Default()) == "Yes" then
		ComboBox.SetSelected("ComboBox1",ComboBox.GetCount("ComboBox1"));
		end
        sOutput = "";
        oItem = oEnum:Next();
    end    
else
    Dialog.Message("", "Win32_Printer Kütüphanesi bulunamadı.");
end

local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_PrintJob", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
    Name = String.TrimRight(Escape(oItem:Caption()), "  ,6");
	sayi = ComboBox.GetCount("ComboBox1");
	for i = 0,sayi do
	  if (Name == String.Mid(ComboBox.GetItemText("ComboBox1", i), 1, String.Length(Name))) then
	     ComboBox.SetItemText("ComboBox1", i,ComboBox.GetItemText("ComboBox1", i) .." | ".. Escape(oItem:JobStatus()));
	  end
	end
        oItem = oEnum:Next();
    end
else
    Dialog.Message("", "Win32_PrintJob Kütüphanesi bulunamadı.");
end


 

Hocam tşk ederim. Şuan iş yerindeyim AMS olmadığı için deneyemiyorum. Bu eklenen kodlar sanırım duraklatıldı ibaresi için değilmi hocam. Ben duraklatmayı aktif ve pasif etmeyi regetitten buldum ama regedit kaydını değiştirince bilgisayarı yeniden başlatmadan değişiklikler aktif olmuyor bu yüzden bu şekilde kodlarla olması daha iyi olacak. 

Link to comment
Share on other sites

  • Editor

Verdiğim kodlar sadece bir yazı gönderipte sonra gönderdiğiniz yazıyı duraklatırsınız ya.Onu gösterir yani hangi yazıcıda duraklatılmış çıktı var.

 

Yazıcıyı çevrim dışı felan etmek değil yani.

Edited by pairs
Link to comment
Share on other sites

  1. function WMIDateStringToDate(dtmDate)
  2. if dtmDate then
  3. dtmDate = tostring(dtmDate);
  4. return (String.Mid (dtmDate, 7, 2) .. "/" ..
  5. String.Mid (dtmDate, 5, 2) .. "/" ..
  6. String.Left(dtmDate, 4) .. " " ..
  7. String.Mid (dtmDate, 9, 2) .. ":" ..
  8. String.Mid (dtmDate, 11, 2) .. ":" ..
  9. String.Mid (dtmDate, 13, 2)
  10. );
  11. else
  12. return "";
  13. end
  14. end

 

bu tarih ile alakalı kod ne işe yarıyor hocam ve ayrıca

 

 

local oColItems = oWMIService:ExecQuery("SELECT * FROM Win32_PrintJob", "WQL", 48);

 

bu tür kodları nasıl bulabilirim?
 
 
Edit: Hocam şuan AMS kurup kodları denedim siz denediniz mi son eklediğiniz kodlar çalışmıyor yani benim yukarıya yazıp sorduğum kod çalışmıyor sanırım. çünkü if ten sonrası devamı gelmiyor dialog açtım oda gelmiyor

ocal oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_PrintJob", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
    Name = String.TrimRight(Escape(oItem:Caption()), "  ,6");
sayi = ComboBox.GetCount("ComboBox1");
for i = 0,sayi do
 if (Name == String.Mid(ComboBox.GetItemText("ComboBox1", i), 1, String.Length(Name))) then
    ComboBox.SetItemText("ComboBox1", i,ComboBox.GetItemText("ComboBox1", i) .." | ".. Escape(oItem:JobStatus()));
    Dialog.Message("", "", MB_OK)
 end
end
        oItem = oEnum:Next();
    end
else
    Dialog.Message("", "Win32_PrintJob Kütüphanesi bulunamadı.");
end

 

 

 
 
böyle yaptım dialog bile açılmadı. Not: yazı duraklatma yaptım
Edited by fba44
Link to comment
Share on other sites

hocam anladım yazı duraklatıldı olunca oluyor aslında yazıcının duraklatıldığı zaman olsa daha iyi olurdu. Yani JobStatus Değilde printerstatus gibi bişi yani. Daha açılça bende prntscrn koyuyorum

 

 

http://prntscr.com/1ow2ur

 

Yazıcı menusunun içinde check ticklenmiş olanlar varya ben onlarla ilgileniyorum. Varsyılan kısmı oldu. Hem get yapabiliyorum hemde set

 

ÇevrimDışı kısmını Sadece sizin kodlarda Get Yapabiliyoruz SET halen yapamadım ,

 

Duraklatıldı kısmı ise GET yapamıyorum ama SET yapıyorum regeditten oda yeniden başlatmak gerekiyor o yüzden olmuyor. 

 

Bu konulara biraz çözüm bulabilirsek iyi olur hocam.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...