Jump to content

Problem with photo selection


chelo32
 Share

Go to solution Solved by Nine,

Recommended Posts

Help I go to those who know, I've been thinking about it for a long time, I have problems with this code that I can't get to change the image according to what I read in a registry chain, I already tried with swich and it didn't work, I don't know what to do
From already thank you very much

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $img1 = @ScriptDir & "\Gigabyte.jpg"
Local $img2 = @ScriptDir & "\Biostar.jpg"
Local $img3 = @ScriptDir & "\Intel_inside.jpg"
Local $img4 = @ScriptDir & "\Lenovo.jpg"
Local $img5 = @ScriptDir & "\MSI.jpg"
Local $img6 = @ScriptDir & "\AsRock.jpg"
Local $img7 = @ScriptDir & "\asus.jpg"
Local $img8 = @ScriptDir & "\Intel.jpg"
Local $img9 = @ScriptDir & "\amd.jpg"

$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
For $object in $colCPU
    $CPU1 = StringStripWS($object.Name,1)
Next
Local $Mother0 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 862, 437, 814, 393)
$Pic1 = GUICtrlCreatePic("", 664, 32, 153, 105)
$Pic2 = GUICtrlCreatePic("", 672, 168, 161, 105)
$Pic3 = GUICtrlCreatePic("", 672, 312, 145, 97)
$Label2 = GUICtrlCreateLabel($Mother0, 24, 96, 500, 17)
$Label3 = GUICtrlCreateLabel($CPU1, 24, 144, 500, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

if GUICtrlRead ($Mother0) = "Gigabyte"  Then
        GUICtrlSetImage($Pic2, $img1)
ElseIf GUICtrlRead ($Mother0) = "Biostar"  Then
        GUICtrlSetImage($Pic2, $img2)
Elseif GUICtrlRead ($Mother0) = "Intel"  Then
        GUICtrlSetImage($Pic2, $img3)
Elseif GUICtrlRead ($Mother0) = "Lenovo"  Then
        GUICtrlSetImage($Pic2, $img4)
Elseif GUICtrlRead ($Mother0) = "MSI"  Then
        GUICtrlSetImage($Pic2, $img5)
Elseif  GUICtrlRead ($Mother0) = "AsRock"  Then
        GUICtrlSetImage($Pic2, $img6)
Elseif  GUICtrlRead ($Mother0) = "asus"  Then
        GUICtrlSetImage($Pic2, $img7)
        EndIf

if  GUICtrlRead ($CPU1) = "AMD"  Then
        GUICtrlSetImage($Pic1, $img9)
ElseIf  GUICtrlRead ($CPU1) = "Intel"  Then
        GUICtrlSetImage($Pic1, $img8)
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Link to comment
Share on other sites

That is working well for me :

#include <GUIConstants.au3>

Example()

Func Example()
  GUICreate("Test")
  $Pic1 = GUICtrlCreatePic("", 10, 10, 100, 100)
  GUISetState(@SW_SHOW)

  GUICtrlSetImage($Pic1, "Check.bmp")
  Sleep(5000)
  GUICtrlSetImage($Pic1, "Torus.jpg")

  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
EndFunc   ;==>Example

Maybe the path of the file ( or file name ) is wrong.

edit @ad777 Nailed it ...

Edited by Nine
Link to comment
Share on other sites

20 hours ago, Nine said:

That is working well for me :

#include <GUIConstants.au3>

Example()

Func Example()
  GUICreate("Test")
  $Pic1 = GUICtrlCreatePic("", 10, 10, 100, 100)
  GUISetState(@SW_SHOW)

  GUICtrlSetImage($Pic1, "Check.bmp")
  Sleep(5000)
  GUICtrlSetImage($Pic1, "Torus.jpg")

  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
EndFunc   ;==>Example

Maybe the path of the file ( or file name ) is wrong.

edit @ad777 Nailed it ...

This code changes one after 5 seconds, thank you, it is not what I referred to

Link to comment
Share on other sites

3 minutes ago, Nine said:

Provide the script

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $img1 = @ScriptDir & "\Gigabyte.jpg"
Local $img2 = @ScriptDir & "\Biostar.jpg"
Local $img3 = @ScriptDir & "\Intel_inside.jpg"
Local $img4 = @ScriptDir & "\Lenovo.jpg"
Local $img5 = @ScriptDir & "\MSI.jpg"
Local $img6 = @ScriptDir & "\AsRock.jpg"
Local $img7 = @ScriptDir & "\asus.jpg"
Local $img8 = @ScriptDir & "\Intel.jpg"
Local $img9 = @ScriptDir & "\amd.jpg"

$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
For $object in $colCPU
    $CPU1 = StringStripWS($object.Name,1)
Next
Local $Mother0 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 862, 437, 814, 393)
$Pic1 = GUICtrlCreatePic("", 664, 32, 153, 105)
$Pic2 = GUICtrlCreatePic("", 672, 168, 161, 105)
$Pic3 = GUICtrlCreatePic("", 672, 312, 145, 97)
$Label2 = GUICtrlCreateLabel($Mother0, 24, 96, 500, 17)
$Label3 = GUICtrlCreateLabel($CPU1, 24, 144, 500, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

if GUICtrlRead ($Mother0) = "Gigabyte"  Then
        GUICtrlSetImage($Pic2, $img1)
ElseIf GUICtrlRead ($Mother0) = "Biostar"  Then
        GUICtrlSetImage($Pic2, $img2)
Elseif GUICtrlRead ($Mother0) = "Intel"  Then
        GUICtrlSetImage($Pic2, $img3)
Elseif GUICtrlRead ($Mother0) = "Lenovo"  Then
        GUICtrlSetImage($Pic2, $img4)
Elseif GUICtrlRead ($Mother0) = "MSI"  Then
        GUICtrlSetImage($Pic2, $img5)
Elseif  GUICtrlRead ($Mother0) = "AsRock"  Then
        GUICtrlSetImage($Pic2, $img6)
Elseif  GUICtrlRead ($Mother0) = "asus"  Then
        GUICtrlSetImage($Pic2, $img7)
        EndIf

if  GUICtrlRead ($CPU1) = "AMD"  Then
        GUICtrlSetImage($Pic1, $img9)
ElseIf  GUICtrlRead ($CPU1) = "Intel"  Then
        GUICtrlSetImage($Pic1, $img8)
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • Solution

Alright, I gonna provide the code :

If $Mother0 = "Gigabyte" Then
  GUICtrlSetImage($Pic2, $img1)
ElseIf $Mother0 = "Biostar" Then
  GUICtrlSetImage($Pic2, $img2)
ElseIf $Mother0 = "Intel" Then
  GUICtrlSetImage($Pic2, $img3)
ElseIf $Mother0 = "Lenovo" Then
  GUICtrlSetImage($Pic2, $img4)
ElseIf $Mother0 = "MSI" Then
  GUICtrlSetImage($Pic2, $img5)
ElseIf $Mother0 = "AsRock" Then
  GUICtrlSetImage($Pic2, $img6)
ElseIf $Mother0 = "asus" Then
  GUICtrlSetImage($Pic2, $img7)
EndIf

If $CPU1 = "AMD" Then
  GUICtrlSetImage($Pic1, $img9)
ElseIf $CPU1 = "Intel" Then
  GUICtrlSetImage($Pic1, $img8)
EndIf

 

Link to comment
Share on other sites

16 hours ago, Nine said:

Alright, I gonna provide the code :

If $Mother0 = "Gigabyte" Then
  GUICtrlSetImage($Pic2, $img1)
ElseIf $Mother0 = "Biostar" Then
  GUICtrlSetImage($Pic2, $img2)
ElseIf $Mother0 = "Intel" Then
  GUICtrlSetImage($Pic2, $img3)
ElseIf $Mother0 = "Lenovo" Then
  GUICtrlSetImage($Pic2, $img4)
ElseIf $Mother0 = "MSI" Then
  GUICtrlSetImage($Pic2, $img5)
ElseIf $Mother0 = "AsRock" Then
  GUICtrlSetImage($Pic2, $img6)
ElseIf $Mother0 = "asus" Then
  GUICtrlSetImage($Pic2, $img7)
EndIf

If $CPU1 = "AMD" Then
  GUICtrlSetImage($Pic1, $img9)
ElseIf $CPU1 = "Intel" Then
  GUICtrlSetImage($Pic1, $img8)
EndIf

 

NINE Thank you very much for your solution, as something so simple can drive someone crazy, I leave the modified code.
truly THANK YOU

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $img1 = @ScriptDir & "\Gigabyte.jpg"
Local $img2 = @ScriptDir & "\Biostar.jpg"
Local $img3 = @ScriptDir & "\Intel_inside.jpg"
Local $img4 = @ScriptDir & "\Lenovo.jpg"
Local $img5 = @ScriptDir & "\MSI.jpg"
Local $img6 = @ScriptDir & "\AsRock.jpg"
Local $img7 = @ScriptDir & "\asus.jpg"
Local $img8 = @ScriptDir & "\Intel.jpg"
Local $img9 = @ScriptDir & "\amd.jpg"

$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
For $object in $colCPU
    $CPU1 = StringStripWS($object.Name,1)
Next
Local $Mother0 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BaseBoardManufacturer")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 862, 437, 814, 393)
$Pic1 = GUICtrlCreatePic("", 664, 32, 153, 105)
$Pic2 = GUICtrlCreatePic("", 672, 168, 161, 105)
$Pic3 = GUICtrlCreatePic("", 672, 312, 145, 97)
$Label2 = GUICtrlCreateLabel($Mother0, 24, 96, 500, 17)
$Label3 = GUICtrlCreateLabel($CPU1, 24, 144, 500, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$sString_Mother0 = StringLeft($Mother0, 4)
If $sString_Mother0 = "Giga" Then
  GUICtrlSetImage($Pic2, $img1)
ElseIf $sString_Mother0 = "Bios" Then
  GUICtrlSetImage($Pic2, $img2)
ElseIf $sString_Mother0 = "Inte" Then
  GUICtrlSetImage($Pic2, $img3)
ElseIf $sString_Mother0 = "Leno" Then
  GUICtrlSetImage($Pic2, $img4)
ElseIf $sString_Mother0 = "MSI" Then
  GUICtrlSetImage($Pic2, $img5)
ElseIf $sString_Mother0 = "AsRo" Then
  GUICtrlSetImage($Pic2, $img6)
ElseIf $sString_Mother0 = "ASUS" Then
  GUICtrlSetImage($Pic2, $img7)
EndIf
$sString = StringLeft($CPU1, 3)
If $sString = "AMD" Then
  GUICtrlSetImage($Pic1, $img9)
ElseIf $sString = "Int" Then
  GUICtrlSetImage($Pic1, $img8)
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Link to comment
Share on other sites

One thing that would greatly compact your code is to name your images the same as the value of $Mother0, so you could simply use :

GUICtrlSetImage($Pic2, @ScriptDir & "\" & $Mother0 & ".jpg")

And the same goes for $CPU1...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...