Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all 12506 articles
Browse latest View live

IniRead works in editor, not after running compiled on target PC?

$
0
0

I've got an odd one here. I've updated some old code that ran file previously. The update primarily just added the window title identification string to the INI file instead of being hardcoded in the script. I'm compiling the code on Windows 8.1 x64 and running it on Windows 8.1 x32 (previously ran fine on WinXP x32). There are restrictions on this PC. Through group policy, the C drive is hidden/inaccessible. This program is being run via the registry upon boot and is found in C:\sspl_stuff\kiosk\. The INI file is located in the same directory as the executable.

AutoIt         
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  3.  
  4. #include <WindowsConstants.au3>
  5. #include <StaticConstants.au3>
  6. #include <ButtonConstants.au3>
  7. #include <GUIConstantsEx.au3>
  8. #include <BlockInputEx.au3>         ; Attempts to block ALT+TAB from working (works in XP, sort of mimics it in >= Vista
  9. #include <GDIPlus.au3>              ; Fixes issue with odd transparent pixels w/normal AutoIt image/background methods
  10.  
  11. Opt('TrayIconDebug', 0);    Set to 1 to view current line in tray icon via tooltip
  12. Opt('TrayIconHide', 1);     Set to 1 to hide the tray icon
  13. Opt("GUIOnEventMode", 1);   Can call an event on action (like button click)
  14.  
  15.  
  16. ; --- FORCED DISPLAY SIGNAGE CODE --- ;
  17. $minutes_until_display = IniRead("settings.ini", "TimerScreenSettings", "minutes_until_display", 10);
  18. $seconds_to_display    = IniRead("settings.ini", "TimerScreenSettings", "time_delay_secs", 20);
  19. $background_color      = IniRead("settings.ini", "TimerScreenSettings", "background_color", "000000");
  20. $splash_image          = IniRead("settings.ini", "TimerScreenSettings", "splash_image", "splash.jpg")
  21. $text_color            = IniRead("settings.ini", "TimerScreenSettings", "text_color", "CCCCCC");
  22. $font_size             = IniRead("settings.ini", "TimerScreenSettings", "font_size", 24);
  23. $font_weight           = IniRead("settings.ini", "TimerScreenSettings", "font_weight", 600);
  24. $close_msg             = IniRead("settings.ini", "TimerScreenSettings", "close_msg", "I Understand");
  25. $font_family           = IniRead("settings.ini", "TimerScreenSettings", "font_family", "Verdana");
  26. $message_text          = IniRead("settings.ini", "TimerScreenSettings", "message_text", "You have a little over 10 minutes remaining." & @CRLF & "Please save your work.");
  27. $button_width          = IniRead("settings.ini", "TimerScreenSettings", "button_width", 100);
  28. $button_height         = IniRead("settings.ini", "TimerScreenSettings", "button_height", 30);
  29. $button_left           = IniRead("settings.ini", "TimerScreenSettings", "button_left", 1024 - $button_width);
  30. $button_top            = IniRead("settings.ini", "TimerScreenSettings", "button_top", 768 - $button_height);
  31. $window_width          = IniRead("settings.ini", "TimerScreenSettings", "window_width", @DesktopWidth);
  32. $window_height         = IniRead("settings.ini", "TimerScreenSettings", "window_height", @DesktopHeight);
  33. $image_width           = IniRead("settings.ini", "TimerScreenSettings", "image_width", @DesktopHeight);
  34. $image_height          = IniRead("settings.ini", "TimerScreenSettings", "image_height", @DesktopHeight);
  35. $window_class          = IniRead("settings.ini", "TimerScreenSettings", "window_class", "[REGEXPTITLE:(.* minutes)]");
  36. $left = (@DesktopWidth - $image_width) / 2;         Image centering placement
  37. $top  = (@DesktopHeight - $image_height) / 2;       Image centering placement
  38. ;$left = (1024 - $image_width) / 2;     Image centering placement
  39. ;$top  = (768 - $image_height) / 2;     Image centering placement
  40.  
  41.  
  42. ; Create newlines from the settings.ini file information
  43. $message_text = StringReplace($message_text,'\n',@CRLF);
  44.  
  45.  
  46. ; --- TIME/WINDOW DETECTION CODE --- ;
  47. $window = WinWait($window_class, "", 1);            Pauses script execution until the Cassie timer/application toolbar window is created and active
  48.     $time_remaining = WinGetTitle($window_class);   Cassie displays time remaining in title of window
  49.     $time_remaining = StringReplace($time_remaining, " minutes", "");   Replace "X minutes" with "X"
  50.     Sleep(5000)
  51.     If $time_remaining = $minutes_until_display Then
  52.         ExitLoop
  53.     EndIf
  54.  
  55.  
  56. ; --- Set the Form Controls --- ;
  57. ; Window
  58. $kiosk = GUICreate("", $window_width, $window_height, 0, 0, $WS_POPUP);
  59. WinSetOnTop($kiosk, "", 1);                     Set the window to show up above all other windows
  60. GuiSetBkColor("0x" & $background_color);
  61. ; Background image
  62. $hBitmap  = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\" & $splash_image);    load bitmap as GDI+ bitmap
  63. $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap);                   convert it to a GDI bitmap
  64. $iPic = GUICtrlCreatePic("", $left, $top, 640, 480);
  65. $hB   = GUICtrlSendMsg($iPic, 0x0172, 0, $hHBITMAP);                            copy GDI bitmap to picture control
  66. GuiCtrlSetState(-1,$GUI_DISABLE);
  67. ; Close button
  68. $close = GUICtrlCreateButton($close_msg, $button_left, $button_top, $button_width, $button_height);
  69. GUICtrlSetDefColor("0x" & $text_color);
  70. GUISetFont($font_size, $font_weight, '', $font_family);
  71. GUICtrlSetFont($close, $font_size, $font_weight, 0, $font_family);
  72. GUICtrlSetOnEvent($close,"Remove");             Close the window early
  73. ; Dummy button for use with blocking key commands
  74. $dummyCtrl1 = GUICtrlCreateDummy();
  75. $dummyCtrl2 = GUICtrlCreateDummy();
  76. ; Label text
  77. GUICtrlCreateLabel($message_text, 15, 15);      Place the text in the GUI
  78. GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);
  79.  
  80.  
  81. ;--- Block certain keys/combos for XP machines ---;
  82. ; Enter, Space, SHIFT+TAB, WIN+TAB, ALT+SHIFT+TAB, WIN+SHIFT+TAB
  83. Local  $AccelKeys[3][2] = [["{ENTER}", $dummyCtrl1], ["{SPACE}", $dummyCtrl1], ["!{TAB}|#{TAB}|!+{TAB}|#+{TAB}", $dummyCtrl2]];
  84. GUISetAccelerators($AccelKeys);
  85.  
  86.  
  87. ; --- Display the Coded Form --- ;
  88. WinActivate($kiosk);
  89.  
  90.  
  91. ; Watch for key accelerators and perform an action while window open, or close window after set time expires
  92. $timer = TimerInit();
  93.     $msg = GUIGetMsg();
  94.     Select
  95.         Case $msg = $dummyCtrl1
  96.             ; DO NOTHING
  97.         Case $msg = $dummyCtrl2
  98.             ; DO NOTHING
  99.         Case $msg = $close
  100.             Remove();
  101.     EndSelect
  102. Until $msg = $close or TimerDiff($timer) > $seconds_to_display * 1000
  103.  
  104.  
  105. ; --- CLOSE THE KIOSK GUI EARLY --- ;
  106. Func Remove ()
  107.     GUIDelete();
  108.     Exit;
  109. Func blocked ()

Lines 49-57 can be commented out to see the program run and what it's doing (it waits for a window title to update to an appropriate value, then runs - it's for a public library computer reservation system).

 

Settings file:

Plain Text         
  1. [SplashScreenSettings]
  2. time_delay_secs=5
  3. background_color=000000
  4. splash_image=splash.jpg
  5.  
  6. [TimerScreenSettings]
  7. minutes_until_display=10
  8. time_delay_secs=37
  9. background_color="000000"
  10. splash_image="alert_1024x768.jpg"
  11. text_color="AAD4FF"
  12. font_size=20
  13. font_weight=600
  14. close_msg="I Understand"
  15. font_family="Cambria Bold"
  16. message_text="\nYou have under 10 minutes remaining.\nContents saved *ON THE COMPUTER* will be *ERASED* at the end of your session.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n                                                       To prevent loss of work, please save externally now.\n                                                                    Please see the clerk for any assistance."
  17. button_width=300
  18. button_height=60
  19. button_left=493 ;1024 -> 1280 = 256 / 2 = 128 + 365 = 493 | old 365
  20. button_top=836  ;768  -> 1024 = 256 / 2 = 128 + 708 = 836 | old 768
  21. image_width=1024
  22. image_height=768
  23. window_class="[REGEXPTITLE:(.* minutes)]"
  24. ;window_width=1024
  25. ;window_height=768

Unfortunately my customized settings are not being read, only the alternate default settings (hardcoded in the application) are being used. The application and settings.ini file are both in the same folder. A different application is using the settings file as expected (compiled from an older build of AutoIt, I'm currently running v3.3.10.2 - which doesn't seem to use the AutoIt icon for compiled executables?)

 

Any ideas on why the INI might not be getting read on the target PC? It runs as expected when in the editor on my local dev PC.

 

EDIT: Just in case you're being curious and are examining every single line, note that the variable $window_class is a misnomer. I simply didn't update the variable name when I switched from class to REGEXTITLE (the class kept dynamically changing on each run).


IDM AutoIt problem

$
0
0

im trying to make IDM silent install with autoit , the problem is :

IDM when starts sometimes start with a chose language screen which is something like this :

Case 1 :

01.jpg

 

and other times it starts with the normal setup screen which is :

Case 2 :

02.png

 

my problem is :

How to make autoit when the first screen appear Case 1 so the script go on with chose language process and if IDM just start with Case 2 the script then escape Case 1 and work with Case 2 .

 

I hope that im clear .

autoit script here Attached File  installxp.au3   3.14KB   2 downloads

AutoIt         
#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  --- #region --- Internal functions Au3Recorder Start --- Func _Au3RecordSetup() Opt('WinWaitDelay',100) Opt('WinDetectHiddenText',1) Opt('MouseCoordMode',0) Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '') If $aResult[1] <> '00000409' Then   MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')') EndIf EndFunc Func _WinWaitActivate($title,$text,$timeout=0)     WinWait($title,$text,$timeout)     If Not WinActive($title,$text) Then WinActivate($title,$text)     WinWaitActive($title,$text,$timeout) EndFunc _AU3RecordSetup() #endregion --- Internal functions Au3Recorder End --- Run('idman.exe') WinWait("IDM Setup","الرجاء تحديد اللغة ل") If Not WinActive("IDM Setup","الرجاء تحديد اللغة ل") Then WinActivate("Internet Download Manager Installation Wizard","") _WinWaitActivate("IDM Setup","الرجاء تحديد اللغة ل") Send("{TAB}{DOWN}{DOWN}{DOWN}{DOWN}{TAB}{ENTER}") _WinWaitActivate("Internet Download Manager Installation Wizard","") Send("{ENTER}") _WinWaitActivate("Please read IDM license","") Send("{ENTER}") _WinWaitActivate("Choose Destination Location","") Send("{ENTER}") _WinWaitActivate("Start Installation of Internet Download Manager","") Send("{ENTER}") _WinWaitActivate("Installation Complete","") Send("{ENTER}") Sleep(3000) ProcessClose("IDMan.exe") ProcessClose("IEMonitor.exe") ProcessClose("IEXPLORE.exe") #endregion --- Au3Recorder generated code End ---

thank you

StringSplit - strange behavior ? or bug ?

$
0
0

Repro script:

AutoIt         
#include <MsgBoxConstants.au3> #include <array.au3> Local $sData1 = "NR KONTA: 47 1020" & @CRLF & _         "NR KONTA: 62 2030" & @CRLF & _         "NR KONTA: 64 1910" & @CRLF & _         "NR KONTA: 30 2030" & @CRLF & _         "NR KONTA: 03 1020" & @CRLF & _         "NR KONTA: 77 1020" & @CRLF & _         "NR KONTA: 35 1090" & @CRLF & _         "NR KONTA: 28 1240" & @CRLF & _         "NR KONTA: 07 1020" & @CRLF & _         "NR KONTA: 29 1240" & @CRLF & _         "" Local $sData2 = StringReplace($sData1, "NR KONTA: 62 2030", "Nr KONTA: 62 2030") Local $aTest1 = StringSplit($sData1, 'NR KONTA:', 1) _ArrayDisplay($aTest1, '$aTest1') Local $aTest2 = StringSplit($sData2, 'NR KONTA:', 1) _ArrayDisplay($aTest2, '$aTest2') If $aTest1[$aTest1[0]] <> $aTest2[$aTest2[0]] Then     MsgBox($MB_SYSTEMMODAL, "Question", " Why ? " & @CRLF & " $aTest1[$aTest1[0]] <> $aTest2[$aTest2[0]] " & @CRLF & $aTest1[$aTest1[0]] & " <> " & $aTest2[$aTest2[0]], 10) EndIf If $aTest1[2] == $aTest2[2] and $aTest1[3] == $aTest2[3] Then     MsgBox($MB_SYSTEMMODAL, "Question", "Why second and third element in $aTest1 and $aTest2 are still the same ?", 10) EndIf

.

Question are in MsgBox.

 

 

Regards

mLipok

IEPropertyGet / IEBodyReadText from a txt file opened in IE

$
0
0

Guys,

 

      I have quick question. I'm getting the source of a URL with inetgetsource and saving it to a txt file. I'm opening the txt file with IE and trying to read the inner text with IEPropertyGet or IEBodyReadText and both are returning the full source of the page. Is it possible to only get the inner text from the saved source  txt file opened in IE??

 

I would simply use iecreate > iedocreadhtml and go that way but it doesn't get the correct source that I need. Inetgetsource gets it perfectly. When I use iecreate, it gets the source from a different webpage. JS is preventing iecreate to go directly to the webpage I need whereas inetgetsource goes, gets and returns exactly what I need.

 

 

 

Looking to hire a bot developer i'am on a budget!

$
0
0

Targeted mmo Aion Online Retail NA Servers

 

paying a developer to create a bot that includes the following features and will do the following

 

super easy to use interface that can include my logo and also user friendly

 

away to log in and log out from a user account registered from my website kinda like a auth server

 

waypoint path recorder and way to, load a path / and away to unload paths stored in a database on a website 

 

away to import into database and away to export old paths out of the database

 

the bot needs to show the characters health level and mp level inside the bot in the gui

 

the bot will need to only do to things while ruining it's course! 

 

1st kill mobs according to the characters level range

2nd the ability to gather and level the characters skill level and gathering skill 

and also the ability to loot every thing

 

and have away to set a path to an npc to sale uncommon junk/items and away to heal the characters soul after death away for the bot to know when the character has died to go back to or near its path mark and continue where it left off at

 

and i would like for it to automatically detect the spill book its a requirement i need done

 

 

if anyone is interested in my little project here hit me up on skype: name zero.pass its the guy giving a big finger if someone has a hard time finding it

 

P.S please be awhere that i'am a fixed budget and the price that i can pay can not go up thanks for understanding

 

willing to pay throw paypal 125.00 us dollars this is a quick job for who ever can complete following requirements for me and the jobs will continually be offered to the person who does the job meaning any problems due to being out date or offsets changing

 

thinks for understanding 

If $var check

$
0
0

Hello,

 

What does this simple code actually checks.

 

If $var Then

    ....

 

$var is set to False in a global scope and it changes depending on some other stuff to True or False.

So does the "If $var Then" checks if the variable is True?

Prevent new window from taking focus

$
0
0

TL;DR: I'm looking for a way to prevent specific newly created (not created via autoit) windows from stealing focus (or from showing at all if possible) for the split second it takes for the script to automate them.

 

About once a week I have to print a bunch of pages, 1 at a time, to a PDF printer. I already have the process scripted and it takes about 30 minutes so normally I just turn it on and go to lunch. I'm trying to modify the script so the whole process runs in the background and I can keep using my computer without interruption. The script already uses all Control...() functions so none of the windows need to have focus to work. But, every minute or so, a couple windows pop up (print dialog, pdf program, save as dialog, etc) stealing the focus for a split second which can interrupt my typing/mouse clicking in other windows. That's what I'm trying to fix.

 

I figure I need to hook the window creation event somehow as I need to interrupt the process before the window gets displayed. I've tried the hooking example from http://www.autoitscript.com/forum/topic/56536-easy-shell-hooking-example/ and using WinSetState(..., @SW_HIDE) but the window still appears and steals focus for a brief moment.

 

Basically, the code looks like this:

 

while true

press print

wait for print dialog

press ok

wait for pdf dialog

press save

wait for save as dialog

fill in file name

press ok

go to next page

wend

 

I'd like to do something like:

 

register that the print dialog is about to open

press print

event handler fires from registered print dialog opening and doesn't allow it to take focus

unregister print dialog

press ok

etc...

 

Any help would be appreciated.

Why are my buttons blinking?

$
0
0

I was messing around and thought I try out some stuff with colors and managed to make a thing where the background in the gui is kind of glowing.

My problem though is if it goes too fast the buttons start to blink, is this the result of the script trying to run really fast or is there an error some where else?

Code:

AutoIt         
$gui = GUICreate("",200,200) $hex = 0x000000 $go = GUICtrlCreateButton("Go Button",100,0,70,30) $go2 = GUICtrlCreateButton("Go GUI",0,0,70,30) $label = GUICtrlCreateLabel("",0,50,500,500) $button1 = GUICtrlCreateButton("Button",0,150,100,30) GUICtrlSetFont($label,15,700) GUICtrlSetFont($button1,15,700) GUICtrlSetColor($button1,0xAAAAAA) GUISetState() while 1    $msg = GUIGetMsg(1)    Switch $msg[1]    Case $gui       Switch $msg[0]       Case -3          Exit       Case $go          first()       Case $go2          first2()       EndSwitch    EndSwitch WEnd Func first() while 1             If GUICtrlRead($label) < 200 Then          $hex = $hex + Dec(0x000005)          GUICtrlSetData($label,$hex)          GUICtrlSetBkColor($button1,$hex)          Sleep(200)          Switch GUIGetMsg()       Case -3          Exit          EndSwitch       Else          second()          ExitLoop       EndIf       WEnd       EndFunc Func second()    while 1             $hex = $hex - Dec(0x000005)             GUICtrlSetData($label,$hex)          GUICtrlSetBkColor($button1,$hex)          Sleep(200)          If GUICtrlRead($label) = 0 Then             first()             ExitLoop          EndIf          Switch GUIGetMsg()       Case -3          Exit          EndSwitch       WEnd    EndFunc    Func first2() while 1             If GUICtrlRead($label) < 200 Then          $hex = $hex + Dec(0x000001)          GUICtrlSetData($label,$hex)          GUISetBkColor($hex)          ;Sleep(200)          Switch GUIGetMsg()       Case -3          Exit          EndSwitch       Else          second2()          ExitLoop       EndIf       WEnd       EndFunc Func second2()    while 1             $hex = $hex - Dec(0x000001)             GUICtrlSetData($label,$hex)          GUISetBkColor($hex)          ;Sleep(200)          If GUICtrlRead($label) = 0 Then             first2()             ExitLoop          EndIf          Switch GUIGetMsg()       Case -3          Exit          EndSwitch       WEnd       EndFunc

Thanks :)


LoadTesting WebServer

$
0
0

Hi,

 

Presently I am working on a script to load test a webservice created using Node.JS . However, I am unable to speed up the processing. The following code is a work-around , but I would like to increase its over-all performance. 

 

Hints , appreciated.

 

Since,

1: InetGet provides a non-blocking method / ASYNC , it is being used .

2: Writing the results to the file using Little-Endian - as it is the fastest and requires least amount of code conversion.

AutoIt         
#include <Array.au3> Global Const $HTTPREQUEST_PROXYSETTING_DIRECT = 1 Global Const $HTTP_STATUS_OK = 200 Global $URL Global $count, $SecondCount Global $MaintainCount[100] Global $sFileData, $hFile FileDelete('consolidated.txt') $hFile = FileOpen('consolidated.txt', 34) For $i = 0 To 99 Step 1     $MaintainCount[$i] = 0 Next AdlibRegister('WriteToFile', 2000) ;~ AdlibRegister('Chk_Array', 150) $URL = 'http://192.168.1.14/getdata/default.aspx?adrm=TINGTONG&adrh=SomeDynamicValue' ;SomeDynamicValue is read from a txt file and that logic is not included. Presently using a static value. $count = 0 $SecondCount = 0 $begin = TimerInit() While 1     If $MaintainCount[$count] <> 0 Then         If InetGetInfo($MaintainCount[$count], 2) Then ;~          AdlibUnRegister('Chk_Array')             InetClose($MaintainCount[$count])             $fileContents = FileRead(@ScriptDir & '\1\' & $count & '.txt') ;           FileDelete(@ScriptDir & '\1\' & $count & '.txt')             $sFileData &= @HOUR & @MIN & @SEC & '|' & $fileContents & @CR             $MaintainCount[$count] = 0             Call('geturl', $count)             ConsoleWrite('IF    : ' & $count & ' : ' & $SecondCount & @CRLF) ;~          AdlibRegister('Chk_Array', 150)         EndIf     Else         Call('geturl', $count)         ConsoleWrite('Else  : ' & $count & ' : ' & $SecondCount & @CRLF)     EndIf     $count += 1     If $count = 100 Then         $count = 0         Chk_Array()     EndIf     If $SecondCount == 1000 Then ExitLoop ;~  Sleep(10) WEnd AdlibUnRegister('WriteToFile') ConsoleWrite('Completed: ' & TimerDiff($begin) / 1000 & @CRLF) Local $FinalCounter = 0 While 1     For $i = 0 To 99 Step 1         If $MaintainCount[$i] <> 0 Then             If InetGetInfo($MaintainCount[$i], 2) Then                 InetClose($MaintainCount[$i])                 $fileContents = FileRead(@ScriptDir & '\1\' & $i & '.txt') ;               FileDelete(@ScriptDir & '\1\' & $i & '.txt')                 $sFileData &= @HOUR & @MIN & @SEC & '|' & $fileContents & @CR                 $MaintainCount[$i] = 0                 ConsoleWrite('Final : ' & $i & ' : ' & $FinalCounter & @CRLF)                 $FinalCounter += 1             EndIf         EndIf     Next     If $FinalCounter == 99 Then         FileWrite($hFile, $sFileData)         ExitLoop     EndIf WEnd ConsoleWrite('Finally Completed: ' & TimerDiff($begin) / 1000 & @CRLF) Func Chk_Array() ;~  AdlibUnRegister('Chk_Array')     For $i = 0 To 99 Step 1         If $MaintainCount[$i] <> 0 Then             If InetGetInfo($MaintainCount[$i], 2) Then                 InetClose($MaintainCount[$i])                 $fileContents = FileRead(@ScriptDir & '\1\' & $i & '.txt')                 $sFileData &= @HOUR & @MIN & @SEC & '|' & $fileContents & @CR                 $MaintainCount[$i] = 0                 ConsoleWrite('Adlib : ' & $i & ' : ' & $SecondCount & @CRLF)             EndIf         EndIf     Next ;~  AdlibRegister('Chk_Array', 150) EndFunc   ;==>Chk_Array Func WriteToFile()     If StringInStr($sFileData, @CR, 2, 100) <> 0 Then         FileWrite($hFile, $sFileData)         $sFileData = ''     EndIf EndFunc   ;==>WriteToFile Func geturl($counter)     $sdata = InetGet($URL, @ScriptDir & '\1\' & $counter & '.txt', 8, 1)     $MaintainCount[$counter] = $sdata     $SecondCount += 1 EndFunc   ;==>geturl

Is there any alternative for InetGet ? So that instead of writing it into the file, it will store the results into the buffer , that way , Disk I/O wont play a spoilsport ?

 

A bit of the Past : The initial script completed 4 requests per second, now its around 8 requests per second.

 

Regards

ListView Click

$
0
0

Let me start by saying this is not necessary to my project.

This is more about me learning and understanding.

 

What I want to do is be able to click on any Item in the ListView and return a message.

This is an example I found and started tweaking to get it to do what I wanted.

I deleted some buttons and sent the click directly to a msgbox.

 

Double click an item returns a message.

AutoIt         
  1. #include <GUIConstantsEx.au3>
  2. #include <WindowsConstants.au3>
  3. #Include <GuiListView.au3>
  4.  
  5.  
  6. $Form1 = GUICreate('boo', 361, 270, 200, 200)
  7.  
  8. ;~ Create listview
  9.     $hListView = _GUICtrlListView_Create ($Form1, "", 0, 0, 260, 377) ; LEFT],[TOP],WIDTH],[HEIGHT]
  10.                  _GUICtrlListView_SetExtendedListViewStyle ($hListView, BitOR($LVS_AUTOARRANGE,$LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER,$LVS_EX_SUBITEMIMAGES))
  11.  
  12.   ; Add columns
  13.     _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
  14.     _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 150)
  15.  
  16.     ; Add items
  17.     _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
  18.     _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
  19.  
  20.     _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
  21.     _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
  22.  
  23. GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
  24.  
  25.  
  26. $msg = GUIGetMsg()
  27. Until $msg = $GUI_EVENT_CLOSE
  28.  
  29.  
  30.  
  31. ;~ ========================================================
  32. ;~ This thing is responcible for click events
  33. ;~ ========================================================
  34. Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
  35.  
  36.     Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
  37.     $hWndListView = $hListView
  38.     If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
  39.  
  40.     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
  41.     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  42.     $iCode = DllStructGetData($tNMHDR, "Code")
  43.     Switch $hWndFrom
  44.         Case $hWndListView
  45.             Switch $iCode
  46.  
  47.                 Case $NM_DBLCLK  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
  48.                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
  49.  
  50.                    $Index = DllStructGetData($tInfo, "Index")
  51.  
  52.                    $subitemNR = DllStructGetData($tInfo, "SubItem")
  53.  
  54.  
  55.                    ; make sure user clicks on the listview & only the activate
  56.                    If $Index <> -1 Then
  57.  
  58.                        ; col1 ITem index
  59.                         $item = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $Index),'|')
  60.                         $item = $item[1]
  61.  
  62.                         ;Col item 2 index
  63.                         $item2 = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $subitemNR),'|')
  64.                         $item2= $item2[2]
  65.  
  66.                         MsgBox(0, 'List View', "Please Select Drive from Drop Down List below")
  67.  
  68.                     EndIf
  69.  
  70.             EndSwitch
  71.     EndSwitch
  72.     Return $GUI_RUNDEFMSG
  73. EndFunc   ;==>WM_NOTIFY

What my problem is the Items are not set in the ListView in my script below.

This is my feeble attempt at applying the above to my script.

 

Import all Drivers

AutoIt         
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  3. #include <ButtonConstants.au3>
  4. #include <ComboConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <StaticConstants.au3>
  7. #include <WindowsConstants.au3>
  8. #include <ProgressConstants.au3>
  9. #include <SendMessage.au3>
  10. #include <GuiListView.au3>
  11.  
  12. $Form1 = GUICreate("Import all Drivers", 400, 400, 600, -1, BitOR($WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU), BitOR($WS_EX_OVERLAPPEDWINDOW, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
  13. GUISetBkColor(0xABCDFF)
  14. $ListView = GUICtrlCreateListView("FileSystem        | Drive | ", 50, 40, 300, 190)
  15. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  16. $aDrives = DriveGetDrive("Fixed")
  17. For $i = 1 To UBound($aDrives) - 1
  18.     $sData = DriveGetFileSystem($aDrives[$i]) & " | " & StringUpper($aDrives[$i]) & "" & DriveGetLabel($aDrives[$i])
  19.     GUICtrlCreateListViewItem($sData, $ListView)
  20. $Label1 = GUICtrlCreateLabel("List of Available Drives to Import From", 60, 20, 275, 24)
  21. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  22. $Label2 = GUICtrlCreateLabel("Select Drive from dropdown list below", 65, 230, 275, 24)
  23. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  24. $Combo1 = GUICtrlCreateCombo("", 100, 260, 200, 20, $CBS_DROPDOWNLIST)
  25. GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  26. $Button1 = GUICtrlCreateButton("OK", 100, 350, 75, 25)
  27. GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  28. $Button2 = GUICtrlCreateButton("Cancel", 220, 350, 75, 25)
  29. GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  30. For $i = 10 To 99
  31.     If DriveStatus(Chr($i) & ':') = 'READY' Then
  32.         If DriveGetType(Chr($i) & ":") = 'FIXED' Then GUICtrlSetData($Combo1, Chr($i) & ':')
  33.     EndIf
  34.         Case $GUI_EVENT_CLOSE, $Button2
  35.             Exit
  36.         Case $Button1
  37.             $version = StringLeft(FileGetVersion(GUICtrlRead($Combo1) & "\Windows\system32\WinVer.exe"), 3)
  38.             If StringLeft($version, 3) = "6.1" Then
  39.                 $version = "WIN7"
  40.             ElseIf StringLeft($version, 3) = "6.0" Then
  41.                 $version = "VISTA"
  42.             ElseIf StringLeft($version, 3) = "5.1" Then
  43.                 $version = "XP"
  44.             ElseIf Not FileExists($version) Then
  45.                 MsgBox(262144, "No OS found", "No Windows OS found")
  46.                 ContinueLoop
  47.             EndIf
  48.             $arch = (GUICtrlRead($Combo1) & "\Windows\system32\WinVer.exe")
  49.             Local $stType = DllStructCreate("dword;")
  50.             $aRet = DllCall("kernel32.dll", "hwnd", "GetBinaryType", "str", $arch, "ptr", DllStructGetPtr($stType))
  51.  
  52.             ; Local Const $SCS_32BIT_BINARY = 0 ; A 32-bit Windows-based application
  53.             ; Local Const $SCS_DOS_BINARY = 1 ; An MS-DOS – based application
  54.             ; Local Const $SCS_WOW_BINARY = 2 ; A 16-bit Windows-based application
  55.             ; Local Const $SCS_PIF_BINARY = 3 ; A PIF file that executes an MS-DOS – based application
  56.             ; Local Const $SCS_POSIX_BINARY = 4 ; A POSIX – based application
  57.             ; Local Const $SCS_OS216_BINARY = 5 ; A 16-bit OS/2-based application
  58.             ; Local Const $SCS_64BIT_BINARY = 6 ; A 64-bit Windows-based application
  59.  
  60.             If DllStructGetData($stType, 1) = "0" Then
  61.                 $arch = "_x32"
  62.             ElseIf DllStructGetData($stType, 1) = "6" Then
  63.                 $arch = "_x64"
  64.             EndIf
  65.             $1 = MsgBox(262144 + 4 + 32, "OSVersion & Arch", (GUICtrlRead($Combo1) & $version & $arch) & @CRLF & "Do you wish to continue?")
  66.             If $1 = 6 Then
  67.                 $hGUI = GUICreate("Test", 400, 40, -1, -1, $WS_POPUP, $WS_EX_TOPMOST, $WS_EX_LAYERED)
  68.                 GUISetBkColor(0xABCDFF)
  69.                 $Label3 = GUICtrlCreateLabel("Importing Drivers Please be Patient", 20, 0, 275, 24)
  70.                 GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  71.                 $idProgress = GUICtrlCreateProgress(0, 18, 400, 20, BitOR($PBS_MARQUEE, $PBS_SMOOTH))
  72.                 $hProgress = GUICtrlGetHandle($idProgress)
  73.                 _SendMessage($hProgress, $PBM_SETMARQUEE, True, 20) ; final parameter is update time in ms
  74.                 GUISetState()
  75.                 Do
  76.                     RunWait("Dpinst.exe /se /sw /s /path " & (GUICtrlRead($Combo1) & "\Windows"))
  77.                     Exit
  78.                 Until GUIGetMsg() = $GUI_EVENT_CLOSE
  79.                 Exit
  80.             EndIf
  81.     EndSwitch
  82.  
  83. Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
  84.  
  85.     Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
  86.     $hWndListView = $ListView
  87.     If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
  88.  
  89.     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
  90.     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  91.     $iCode = DllStructGetData($tNMHDR, "Code")
  92.     Switch $hWndFrom
  93.         Case $hWndListView
  94.             Switch $iCode
  95.  
  96.                 Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
  97.                     Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
  98.  
  99.                     $Index = DllStructGetData($tInfo, "Index")
  100.  
  101.                     $subitemNR = DllStructGetData($tInfo, "SubItem")
  102.  
  103.  
  104.                     ; make sure user clicks on the listview & only the activate
  105.                     If $Index <> -1 Then
  106.  
  107.                         ; col1 ITem index
  108.                         $item = StringSplit(_GUICtrlListView_GetItemTextString($ListView, $Index), '|')
  109.                         $item = $item[1]
  110.  
  111.                         ;Col item 2 index
  112.                         $item2 = StringSplit(_GUICtrlListView_GetItemTextString($ListView, $subitemNR), '|')
  113.                         $item2 = $item2[2]
  114.  
  115.                         MsgBox(0, 'List View', "Please Select Drive from Drop Down List below")
  116.  
  117.                     EndIf
  118.  
  119.             EndSwitch
  120.     EndSwitch
  121.     Return $GUI_RUNDEFMSG
  122. EndFunc   ;==>WM_NOTIFY

I think what I need to do is use the return value of each Item instead of the item itself.

I really have no Idea how to approach this.

 

 

This is all part of a Win7PE project I'm working on

I started on the above script about a week ago just prior to signing up to the forum.

 

Below is the first part of my project I started on a little over a month ago.

Although it has nothing to do with what I'm working on now,

I would eventually like to merge everything into one script.

 

Best Driver Import

AutoIt         
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  3.  
  4. #include <ButtonConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <WindowsConstants.au3>
  7.  
  8. Opt("GUIOnEventMode", 1)
  9. $Form1 = GUICreate("Driver Import", 450, 200, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
  10. GUISetBkColor(0xA6CAF0)
  11. $widthCell = 370
  12. GUICtrlCreateLabel("       Select the drivers you want and Click Import.", 40, 20, $widthCell)
  13. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  14. GUICtrlCreateLabel("      All Drivers Imports all MS and Non MS drivers.", 40, 40, $widthCell)
  15. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  16. GUICtrlCreateLabel("All non MS drivers should be sufficient in most cases.", 40, 60, $widthCell)
  17. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  18. GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
  19. $Checkbox1 = GUICtrlCreateCheckbox("Net/WiFi", 90, 90, 97, 17)
  20. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  21. GUICtrlSetOnEvent(-1, "Checkbox1Click")
  22. $Checkbox2 = GUICtrlCreateCheckbox("Video", 260, 90, 97, 17)
  23. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  24. GUICtrlSetOnEvent(-1, "Checkbox2Click")
  25. $Checkbox3 = GUICtrlCreateCheckbox("Audio", 90, 110, 97, 17)
  26. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  27. GUICtrlSetOnEvent(-1, "Checkbox3Click")
  28. $Checkbox4 = GUICtrlCreateCheckbox("Other", 260, 110, 97, 17)
  29. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  30. GUICtrlSetOnEvent(-1, "Checkbox4Click")
  31. GUICtrlSetState($Checkbox4, $GUI_DISABLE + $GUI_UNCHECKED)
  32. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  33. $Checkbox5 = GUICtrlCreateCheckbox("All Non MS", 90, 130, 97, 17)
  34. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  35. GUICtrlSetOnEvent(-1, "Checkbox5Click")
  36. $Checkbox6 = GUICtrlCreateCheckbox("All Drivers", 260, 130, 97, 17)
  37. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  38. GUICtrlSetOnEvent(-1, "Checkbox6Click")
  39. $Import = GUICtrlCreateButton("Import", 100, 170, 75, 25)
  40. GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  41. GUICtrlSetOnEvent($Import, "ImportClick")
  42. $Exit = GUICtrlCreateButton("Exit", 270, 170, 75, 25)
  43. GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  44. GUICtrlSetOnEvent($Exit, "ExitClick")
  45.  
  46.     Sleep(100)
  47.  
  48.  
  49. Func ImportClick()
  50.     If GUICtrlRead($Checkbox1) = $GUI_CHECKED Or GUICtrlRead($Checkbox2) = $GUI_CHECKED Or GUICtrlRead($Checkbox3) = $GUI_CHECKED Or GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
  51.         GUISetState(@SW_HIDE, $Form1)
  52.         RunWait("RunScanner.exe /t 10 /cp /sd /ac /m+ /y ddc.exe b /target:" & EnvGet("SYSTEMDRIVE") & "\driverbackup")
  53.         RunWait(DirCreate(EnvGet("SYSTEMDRIVE") & "\driverbackup\Install\"))
  54.     EndIf
  55.     If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
  56.         RunWait(DirMove(@HomeDrive & "\driverbackup\Net\", @HomeDrive & "\driverbackup\Install\", 1))
  57.         RunWait(DirMove(@HomeDrive & "\driverbackup\Bluetooth\", @HomeDrive & "\driverbackup\Install\", 1))
  58.     EndIf
  59.     If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
  60.         RunWait(DirMove(@HomeDrive & "\driverbackup\Display\", @HomeDrive & "\driverbackup\Install\", 1))
  61.     EndIf
  62.     If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
  63.         RunWait(DirMove(@HomeDrive & "\driverbackup\MEDIA\", @HomeDrive & "\driverbackup\Install\", 1))
  64.     EndIf
  65.     If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
  66.  
  67.     EndIf
  68.     If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then
  69.         GUISetState(@SW_HIDE, $Form1)
  70.         RunWait("RunScanner.exe /t 10 /cp /sd /ac /m+ /y ddc.exe b /target:" & EnvGet("SYSTEMDRIVE") & "\driverbackup")
  71.     EndIf
  72.     If GUICtrlRead($Checkbox6) = $GUI_CHECKED Then
  73.         Run("Import all Drivers.exe")
  74.         Exit
  75.     EndIf
  76.     If GUICtrlRead($Checkbox1) = $GUI_CHECKED Or GUICtrlRead($Checkbox2) = $GUI_CHECKED Or GUICtrlRead($Checkbox3) = $GUI_CHECKED Or GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
  77.         RunWait("Dpinst.exe /path " & EnvGet("SYSTEMDRIVE") & "\driverbackup\Install\")
  78.         GUISetState(@SW_SHOW, $Form1)
  79.         DirRemove(EnvGet("SYSTEMDRIVE") & "\driverbackup", 1)
  80.         Exit
  81.     EndIf
  82.     If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then
  83.         RunWait("Dpinst.exe /path " & EnvGet("SYSTEMDRIVE") & "\driverbackup\")
  84.         GUISetState(@SW_SHOW, $Form1)
  85.         DirRemove(EnvGet("SYSTEMDRIVE") & "\driverbackup", 1)
  86.         Exit
  87.     EndIf
  88. EndFunc   ;==>ImportClick
  89.  
  90. Func Checkbox1Click()
  91.     If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
  92.     EndIf
  93. EndFunc   ;==>Checkbox1Click
  94.  
  95. Func Checkbox2Click()
  96.     If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
  97.     EndIf
  98. EndFunc   ;==>Checkbox2Click
  99.  
  100. Func Checkbox3Click()
  101.     If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
  102.     EndIf
  103. EndFunc   ;==>Checkbox3Click
  104.  
  105. Func Checkbox4Click()
  106.     If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
  107.     EndIf
  108. EndFunc   ;==>Checkbox4Click
  109.  
  110. Func Checkbox5Click()
  111.     If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then
  112.         GUICtrlSetState($Checkbox1, $GUI_DISABLE + $GUI_UNCHECKED)
  113.         GUICtrlSetState($Checkbox2, $GUI_DISABLE + $GUI_UNCHECKED)
  114.         GUICtrlSetState($Checkbox3, $GUI_DISABLE + $GUI_UNCHECKED)
  115.         GUICtrlSetState($Checkbox4, $GUI_DISABLE + $GUI_UNCHECKED)
  116.         GUICtrlSetState($Checkbox6, $GUI_DISABLE + $GUI_UNCHECKED)
  117.     Else
  118.         GUICtrlSetState($Checkbox1, $GUI_ENABLE)
  119.         GUICtrlSetState($Checkbox2, $GUI_ENABLE)
  120.         GUICtrlSetState($Checkbox3, $GUI_ENABLE)
  121.         GUICtrlSetState($Checkbox4, $GUI_DISABLE + $GUI_UNCHECKED)
  122.         GUICtrlSetState($Checkbox6, $GUI_ENABLE)
  123.     EndIf
  124. EndFunc   ;==>Checkbox5Click
  125.  
  126. Func Checkbox6Click()
  127.     If GUICtrlRead($Checkbox6) = $GUI_CHECKED Then
  128.         GUICtrlSetState($Checkbox1, $GUI_DISABLE + $GUI_UNCHECKED)
  129.         GUICtrlSetState($Checkbox2, $GUI_DISABLE + $GUI_UNCHECKED)
  130.         GUICtrlSetState($Checkbox3, $GUI_DISABLE + $GUI_UNCHECKED)
  131.         GUICtrlSetState($Checkbox4, $GUI_DISABLE + $GUI_UNCHECKED)
  132.         GUICtrlSetState($Checkbox5, $GUI_DISABLE + $GUI_UNCHECKED)
  133.     Else
  134.         GUICtrlSetState($Checkbox1, $GUI_ENABLE)
  135.         GUICtrlSetState($Checkbox2, $GUI_ENABLE)
  136.         GUICtrlSetState($Checkbox3, $GUI_ENABLE)
  137.         GUICtrlSetState($Checkbox4, $GUI_DISABLE + $GUI_UNCHECKED)
  138.         GUICtrlSetState($Checkbox5, $GUI_ENABLE)
  139.     EndIf
  140.  
  141. EndFunc   ;==>Checkbox6Click
  142.  
  143. Func ExitClick()
  144.     DirRemove(EnvGet("SYSTEMDRIVE") & "\driverbackup", 1)
  145.     Exit
  146. EndFunc   ;==>ExitClick
  147.  
  148. Func Form1Close()
  149.     DirRemove(EnvGet("SYSTEMDRIVE") & "\driverbackup", 1)
  150.     Exit
  151. EndFunc   ;==>Form1Close

My PC I have 2 hard drives with 5 partitions, 3 containing OS. Win7 x86, Win7 x64 and XP.

ListView would show 5 drives.3 OS and 2 for file storage.

 

If you can help me out and show me what to do or just point me in the right direction

and see how bad I can screw things up.

 

Any help appreciated

Assign two different programs to two buttons

$
0
0

HI team,

 

I have two different programs and i want to use them using one single message box. For Example If I click on button no A then first program should execute and if i click on button no 2 then my second program should run...

 

Can anyone help me.....how can i write a code.....

any help would be appreciated. thanks!

 

Program no 1

Sleep(200) $url = "https://www.google.co.in/?gfe_rd=ctrl&ei=ab8ZU4PrKKrW8gf5lYDgDg&gws_rd=cr" $oIE = _IECreate($url) Sleep(100) _IELoadWait($oIE) Sleep(100) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window WinSetState($hIE, "" ,@SW_MAXIMIZE) Sleep(100)

Program no 2

Sleep(200) send("#r")                                ;--------------------to open a folder-------------- Sleep(200) send("C:\LTE Market List{enter}") sleep(200) WinWaitActive("LTE Market List") sleep(200) WinSetState("LTE Market List", "", @SW_MAXIMIZE) sleep(200) WinActivate("LTE Market List") sleep(200)                                 ;---------------------------to click on 1st sheet--------------- MouseClick("left", 249, 128, 1) Sleep(200) EndSwitch

Script Running Twice

$
0
0

Hello,

 

I've used AutoIt several years ago, and I want to use it again today for a new project. So I have installed the latest version on my Windows 7 machine.

 

I have started to write a few simple scripts, build exe files and execute them. But each time I double-click the .exe file runs twice !

 

For example the "msgbox.au3" example provided with the installation files will display the text box a first time, then I click "Ok", and the text box shows up again.

 

Here is the script :

 

#include <Constants.au3>

MsgBox($MB_SYSTEMMODAL, "AutoIt Example", "This is line 1" & @CRLF & "This is line 2" & @CRLF & "This is line 3")

 

What is wrong ???

Missing a RegExp prepare function?

$
0
0

I want to generate a regex from an user input and need a regex prepare function.
I couldn't find any in the documentation, am I missing something?
It should escape out all regex characters, so like "te.st" would become "te\.st".

running autoit script as administrator

$
0
0
Hi all
I’m farely new to autoit and am trying to write a script that interacts with the windows bootmanager using bcdedit
If I run bcdedit from a command prompt as the normal user I get the following
The boot configuration data store could not be opened. Access is denied.
If I right click on command prompt and choose run as administrator
And then run Bcdedit, it runs normally.
The script code looks as follows
 
#include <Constants.au3> #include <MsgBoxConstants.au3>  #include <Array.au3>  #include <String.au3>   ; main section ; This script requires full Administrative rights #RequireAdmin   ; run bcdedit and store list in array Local $iPID = Run(@ComSpec & ' /C bcdedit /enum /v', "c:\", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) Local $SBootManagerList = StdoutRead($iPID) MsgBox($MB_SYSTEMMODAL, "output", $SBootManagerList)
I’m not sure where to go to fix this. I tried to use the runas function which seems to fail, possibly because on the windows 8 machines the administrator account is disabled. Anyone got any suggestions on how I can get this to work?

do findnextfile works over a network?

$
0
0

Hi there,

 

quick question above it doesn't seem to work here is this correct?

 $path = '\\192.168.5.60\skripte\'&$paket&'\Install\'    $file = FileFindFirstFile($path&"*.*")    If $file = -1 Then       MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")       Return False    else       while 1          $filename = FileFindnextFile($file)          if @error then             MsgBox(1, "", "Error: No files/directories matched the search pattern.")             ExitLoop          else             $temp = FileGetTime($path&$filename,0,1)             $modtime = StringMid($temp,7,2) & "." & StringMid($temp,5,2) &"."& StringLeft($temp,4) &" "& StringMid($temp,9,2) &":"&StringMid($temp,11,2)             IniWrite(@scriptdir&"config.ini",$filename,"ModifiedTime",$modtime)          endif       wend    EndIf

greets Tekkion


Searching for a substring with Apostrophes

$
0
0

Hi,

 

 I guess it is a simple one...

 

 I need to find a substring (which is in a variable) within another string.

 

 The substring has " in it.

 

 For example: L"A for Los Angeles. US"A = United State of America.

 So I need to find the L"A or US"A.

 

 (I do not know if it correct in english, but it is correct in my language, and anyhow - it is just an example for you to understand what I mean.)

 

Thanks!

An easy one

$
0
0

Hello,

 

I cannot figure out how to disable ESC and keep it from closing my GUI. Any suggestions?

 

Thanks!

How to find image in screen?

$
0
0

I'm using PixelSearch function but it's not enought for me. Because there are same pixel, also the image is not static. So it sometimes on top, sometimes on left&bottom. So I need a function to find image in screen. is it possible? Or, have you got any advice? 

3rd Party Apps in Windows Media Center

$
0
0

Hello,

 

I have a third party app in Windows Media Center that I'm trying to use AutoIt to write a script to "click" on one of the buttons.

 

When I use the AutoIt Windows Info program, it will not read any relevant information about the 3rd party app in WMC.  It doesn't show any Visible Text or buttons.  Even when I try to use the Finder Tool.

 

Is this because of how WMC runs the 3rd party app within itself?

 

Thanks in advance for any help or insight this forum can give.

 

Greg

gives error shuts down form

$
0
0

this is the code I try to run:

Func volgerteller() $link = GUICtrlRead($List1)         $oIE = _IECreate("https://twitter.com/"&$link,1,0)   ;linkkk $oInput2s = _IETagNameGetCollection($oIE, "a") For $oInput2 In $oInput2s     If $oInput2.className() = "js-nav" Then         If StringInStr($oInput2.innerHTML(), 'Volgend') Then             ConsoleWrite(_StringBetween($oInput2.innerHTML(),'>','<')[0] & @CRLF)             ExitLoop         EndIf     EndIf Next $numbvolgers = (_StringBetween($oInput2.innerHTML(),'>','<')[0] & @CRLF) GUICtrlSetData($List2,"volgers"& $numbvolgers ) if @error then MsgBox(0, "", "gevonden" )

if I remove this line it doesn't shuts down immediately ( but the function will not work)

$numbvolgers = (_StringBetween($oInput2.innerHTML(),'>','<')[0] & @CRLF) GUICtrlSetData($List2,"volgers"& $numbvolgers )

so it has something to do with the last 2 lines,

 

this is the error that i get:

+>16:23:00 AU3Check ended.rc:0 >Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\joesoef pc\Desktop\autoit\program\test.au3"     --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop "C:\Program Files (x86)\AutoIt3\Include\String.au3" (42) : ==> Subscript used on non-accessible variable.: Func _StringBetween($sString, $sStart, $sEnd, $fCase = False) Func _StringBetween($sString, $sStart, $sEnd, $fCase = False^ ERROR ->16:23:00 AutoIt3.exe ended.rc:1 +>16:23:00 AutoIt3Wrapper Finished.. >Exit code: 1    Time: 1.065

 yesterday it worked fine I saved it, now I start the code and the form direclty shuts down..

Viewing all 12506 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>